Skip to content

Commit

Permalink
Remove waitForSelector for some dashboards page (#10)
Browse files Browse the repository at this point in the history
* Remove extra handling for dashboards sources

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

* Add note for tenant in url

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

* Add tenant in url note to help

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

* Remove invalid flow diagram

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

* Revert "Remove extra handling for dashboards sources"

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

This reverts commit a18a67e.

* Revert extra elements removal and remove waitForSelector only

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

* Revert "Remove invalid flow diagram"

Signed-off-by: Rupal Mahajan <maharup@amazon.com>

This reverts commit c1834f6.

Signed-off-by: Rupal Mahajan <maharup@amazon.com>
  • Loading branch information
rupal-bq authored Jan 21, 2023
1 parent f292be3 commit 4cf7732
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 29 deletions.
2 changes: 2 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ You can also find this information using help command.
opensearch-reporting-cli --help
```

NOTE: The tenant in the url has the higher priority than tenant value provided as command option. For example, if the command is `opensearch-reporting-cli -u http://localhost:5601/goto/069af6d6f3294421ec163b07fef91e5d?security_tenant=private -t global` then tenant value *private* will be used for generating report because url contains *security_tenant=private*.

## Environment Variable File

Reporting CLI also reads environment variables from .env file in the current directory.
Expand Down
3 changes: 3 additions & 0 deletions src/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export async function getCommandArguments() {
.default(DEFAULT_EMAIL_SUBJECT)
.env(ENV_VAR.EMAIL_SUBJECT))

program.addHelpText('after', `
Note: The tenant in the url has the higher priority than tenant value provided as command option.`);

program.parse(process.argv);
const options = program.opts();
spinner.start('Fetching the arguments values');
Expand Down
6 changes: 3 additions & 3 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export const AUTH = {
}

export const URL_SOURCE = {
DASHBOARDS: 'dashboards#',
VISUALIZE: "Visualize",
DISCOVER: "discover#",
DASHBOARDS: "/app/dashboards#",
VISUALIZE: "/app/visualize#",
DISCOVER: "/app/discover#",
NOTEBOOKS: "notebooks",
}

Expand Down
26 changes: 0 additions & 26 deletions src/download-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,6 @@ export async function downloadReport(url, format, width, height, filename, authT

// force wait for any resize to load after the above DOM modification.
await new Promise(resolve => setTimeout(resolve, 1000));

switch (reportSource) {
case REPORT_TYPE.DASHBOARD:
await page.waitForSelector(SELECTOR.DASHBOARD, {
visible: true,
});
break;
case REPORT_TYPE.VISUALIZATION:
await page.waitForSelector(SELECTOR.VISUALIZATION, {
visible: true,
});
break;
case REPORT_TYPE.NOTEBOOK:
await page.waitForSelector(SELECTOR.NOTEBOOK, {
visible: true,
});
break;
case REPORT_TYPE.DISCOVER:
await page.waitForSelector(SELECTOR.DISCOVER, {
visible: true,
});
break;
default:
break;
}

await waitForDynamicContent(page);
let buffer;
spinner.text = `Downloading Report...`;
Expand Down
2 changes: 2 additions & 0 deletions test/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Options:
--smtppassword <password> smtp password (env: OPENSEARCH_SMTP_PASSWORD)
--subject <subject> email Subject (default: "This is an email containing your opensearch dashboard report", env: OPENSEARCH_EMAIL_SUBJECT)
-h, --help display help for command
Note: The tenant in the url has the higher priority than tenant value provided as command option.
`;
let result = await cli(['-h'], '.');
expect(result.code).toBe(0);
Expand Down

0 comments on commit 4cf7732

Please sign in to comment.