Skip to content

Commit

Permalink
Clean up test and code
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Dec 27, 2023
1 parent 275db0f commit 395b0ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/download-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ module.exports = async function downloadReport(url, format, width, height, filen
const page = await browser.newPage();
const overridePage = await browser.newPage();
page.setDefaultNavigationTimeout(0);
page.setDefaultTimeout(300000);
page.setDefaultTimeout(3000);
overridePage.setDefaultNavigationTimeout(0);
overridePage.setDefaultTimeout(300000);
overridePage.setDefaultTimeout(3000);

// auth
if (authType !== undefined && authType !== AUTH.NONE && username !== undefined && password !== undefined) {
Expand Down Expand Up @@ -203,6 +203,7 @@ const getUrl = async (url) => {
};

const basicAuthentication = async (page, overridePage, url, username, password, tenant, multitenancy) => {
console.log("blhaohborhobharobh")
await page.goto(url, { waitUntil: 'networkidle0' });
await new Promise(resolve => setTimeout(resolve, 10000));
await page.type('input[data-test-subj="user-name"]', username);
Expand All @@ -216,14 +217,15 @@ const basicAuthentication = async (page, overridePage, url, username, password,
} else {
await page.click('label[for="custom"]');
await page.click('button[data-test-subj="comboBoxToggleListButton"]');
await page.type('input[data-test-subj="comboBoxInput"]', tenant);
await page.type('input[data-test-subj="comboBoxSearchInput"]', tenant);
}
} else {
if ((await page.$('button[type=submit]')) !== null)
throw new Error('Invalid credentials');
}
}
catch (err) {
console.error(err)
spinner.fail('Invalid username or password');
exit(1);
}
Expand Down Expand Up @@ -320,7 +322,7 @@ const cognitoAuthentication = async (page, overridePage, url, username, password

if (multitenancy === true) {
// Check if tenant was selected successfully.
if ((await overridePage.$('button[data-test-subj="confirm"]')) !== null) {
if ((await page.$('button[data-test-subj="confirm"]')) !== null) {
spinner.fail('Invalid tenant');
exit(1);
}
Expand Down
3 changes: 1 addition & 2 deletions test/misc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ describe('download report errors', () => {
}, 150000);

test('download csv report from custom tenant', async () => {
let result = await cli(['-u', `${url}/app/data-explorer/discover/#/571aaf70-4c88-11e8-b3d7-01146121b73d`, '-a', 'basic', '-c', credentials,
let result = await cli(['-u', `${url}/app/data-explorer/discover/#/view/571aaf70-4c88-11e8-b3d7-01146121b73d`, '-a', 'basic', '-c', credentials,
'-n', 'testcsvoncustomtenant', '-t', 'admin_tenant', '-f', 'csv'], '.');
expect(result.error).toBe(null);
expect(result.code).toBe(0);
const expectedFile = './testcsvoncustomtenant.csv';
const stats = fs.statSync(expectedFile);
Expand Down

0 comments on commit 395b0ea

Please sign in to comment.