Skip to content

Commit

Permalink
Enhance the stability of SAML integ test (#1237) (#1272)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
(cherry picked from commit 7ffbf09)

Co-authored-by: Ryan Liang <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and RyanL1997 authored Dec 15, 2022
1 parent e9d4c75 commit f728d33
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion test/jest_integration/saml_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('start OpenSearch Dashboards server', () => {
const skipWelcomeBtnXPath = '//button[@data-test-subj="skipWelcomeScreen"]';
const tenantNameLabelXPath = '//*[@id="tenantName"]';
const pageTitleXPath = '//*[@id="osdOverviewPageHeader__title"]';
const tenantSwitchBtnXPath = '//button[@data-test-subj="switch-tenants"]';
// Browser Settings
const browser = 'firefox';
const options = new Options().headless();
Expand Down Expand Up @@ -327,11 +328,42 @@ describe('start OpenSearch Dashboards server', () => {
await driver.wait(until.elementsLocated(By.xpath(tenantNameLabelXPath)), 10000);

const tenantName = await driver.findElement(By.xpath(tenantNameLabelXPath)).getText();
const localStorageItem = await driver.executeScript(
`return window.localStorage.getItem("opendistro::security::tenant::saved")`
);

// Retry previous steps one more time if the webdriver doens't reload as expected
if (tenantName === 'Private' && localStorageItem === '""') {
await driver.wait(until.elementsLocated(By.xpath(tenantSwitchBtnXPath)), 10000);
await driver.findElement(By.xpath(tenantSwitchBtnXPath)).click();

await driver.executeScript('arguments[0].scrollIntoView(true);', radio);
await driver.executeScript('arguments[0].click();', radio);
await driver.wait(until.elementIsSelected(radio));

await driver.findElement(By.xpath('//button[@data-test-subj="confirm"]')).click();

await driver.wait(until.elementsLocated(By.xpath(userIconBtnXPath)), 10000);
await driver.findElement(By.xpath(userIconBtnXPath)).click();
await driver.findElement(By.xpath('//*[@data-test-subj="log-out-1"]')).click();

await driver.wait(until.elementsLocated(By.xpath(signInBtnXPath)), 10000);
await driver.findElement(By.xpath(signInBtnXPath)).click();

await driver.wait(until.elementsLocated(By.xpath(userIconBtnXPath)), 10000);
await driver.findElement(By.xpath(userIconBtnXPath)).click();
await driver.wait(until.elementsLocated(By.xpath(tenantNameLabelXPath)), 10000);

const newtenantName = await driver.findElement(By.xpath(tenantNameLabelXPath)).getText();
expect(newtenantName).toEqual('Global');
} else {
expect(localStorageItem).toEqual('""');
expect(tenantName).toEqual('Global');
}
await driver.manage().deleteAllCookies();
await driver.quit();

expect(tenantName).toEqual('Global');
expect(localStorageItem).toEqual('""');
});
});

Expand Down

0 comments on commit f728d33

Please sign in to comment.