-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After link copy, allow tenant change
Signed-off-by: leanneeliatra <[email protected]>
- Loading branch information
1 parent
306d79d
commit 14b23e3
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
cypress/integration/plugins/security-dashboards-plugin/change_tenant_successfully.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CURRENT_TENANT } from '../../../utils/commands'; | ||
import tenantDescription from '../../../fixtures/plugins/security-dashboards-plugin/tenants/testTenant.json'; | ||
|
||
const tenantName = 'test'; | ||
|
||
if (Cypress.env('SECURITY_ENABLED')) { | ||
describe('Switch tenants when visiting copyed links: ', () => { | ||
before(() => { | ||
cy.server(); | ||
|
||
cy.createTenant(tenantName, tenantDescription); | ||
}); | ||
if (Cypress.browser.name === 'chrome') { | ||
it('Checks that the tenant switcher can switch tenants despite a different tenant being present in the tenant query parameter.', function () { | ||
CURRENT_TENANT.newTenant = 'private'; | ||
function switchTenantTo(newTenant) { | ||
cy.getElementByTestId('account-popover').click(); | ||
cy.getElementByTestId('switch-tenants').click(); | ||
cy.get('.euiRadio__label[for="' + newTenant + '"]').click(); | ||
|
||
cy.intercept({ | ||
method: 'GET', | ||
url: '/api/v1/auth/dashboardsinfo', | ||
}).as('waitForReloadAfterTenantSwitch'); | ||
|
||
cy.intercept({ | ||
method: 'POST', | ||
url: '/api/v1/multitenancy/tenant', | ||
}).as('waitForUpdatingTenants'); | ||
|
||
cy.getElementByTestId('tenant-switch-modal') | ||
.find('[data-test-subj="confirm"]') | ||
.click(); | ||
cy.wait('@waitForUpdatingTenants'); | ||
|
||
// Make sure dashboards has really reloaded. | ||
// @waitForReloadAfterTenantSwitch should be triggered twice | ||
cy.wait('@waitForReloadAfterTenantSwitch'); | ||
cy.wait('@waitForReloadAfterTenantSwitch'); | ||
} | ||
cy.visit('/app/home', { | ||
// Clean up | ||
onBeforeLoad(win) { | ||
window.localStorage.clear(); | ||
window.sessionStorage.clear(); | ||
}, | ||
}).then(() => { | ||
cy.waitForLoader(); | ||
switchTenantTo('global'); | ||
cy.waitForLoader(); | ||
cy.getElementByTestId('account-popover').click(); | ||
cy.get('#tenantName').should('contain.text', 'Global'); | ||
}); | ||
}); | ||
} | ||
}); | ||
} |