Skip to content

Commit fbdd55b

Browse files
authored
Fix test hang on tenant selection dialog (#1839)
forecaster_list_spec test was getting stuck on the "Select your tenant" dialog in the frontend, preventing execution from proceeding. This change ensures the dialog is dismissed so the test can continue without manual intervention. Testing done: * ran forecaster_list_spec test in 3.2 cluster with all plugins. Signed-off-by: Kaituo Li <[email protected]>
1 parent 5503fd8 commit fbdd55b

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

cypress/integration/plugins/anomaly-detection-dashboards-plugin/forecaster_list_spec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// ============================================================================
1919

2020
import { AD_FIXTURE_BASE_PATH } from '../../../utils/constants';
21+
import { setStorageItem } from '../../../utils/plugins/dashboards-assistant/helpers';
22+
import { BASE_PATH } from '../../../utils/constants';
2123

2224
const setupIndexWithData = (indexName) => {
2325
// Create index mapping first
@@ -79,23 +81,18 @@ context('list forecaster workflow', () => {
7981
const TEST_INDEX_NAME = 'sample-forecast-index';
8082
const TEST_INDEX_NAME_2 = 'sample-forecast-index-2';
8183

82-
beforeEach(() => {
83-
// Set the default tenant to 'global' to avoid the "Select your tenant" pop-up
84-
// as the timing of the pop-up is not deterministic.
85-
// I checked brownser'sDevTools → Application → Local Storage (and Session Storage)
86-
// → look for keys containing “security” and “tenant”. I found:
87-
// opendistro::security::tenant::savedopendistro::security::tenant::saved:""""
88-
// Just to be safe, instead of using the key directly, we use the following code
89-
// to find the key and set the value to 'global'.
90-
cy.visit('/', {
91-
onBeforeLoad(win) {
92-
const key = Object.keys(win.localStorage).find(
93-
(k) => k.includes('security') && k.includes('tenant')
94-
);
95-
if (key) win.localStorage.setItem(key, 'global');
96-
},
97-
});
84+
let restoreTenantSwitchModal;
9885

86+
beforeEach(() => {
87+
// disable the tenant switch modal
88+
restoreTenantSwitchModal = setStorageItem(
89+
sessionStorage,
90+
'opendistro::security::tenant::show_popup',
91+
'false'
92+
);
93+
// Visit OSD
94+
// requrired otherwise we encounter connection issue in later test
95+
cy.visit(`${BASE_PATH}/app/home`);
9996
cy.deleteAllIndices();
10097
cy.deleteForecastIndices();
10198

@@ -107,6 +104,9 @@ context('list forecaster workflow', () => {
107104
afterEach(() => {
108105
cy.deleteAllIndices();
109106
cy.deleteForecastIndices();
107+
if (restoreTenantSwitchModal) {
108+
restoreTenantSwitchModal();
109+
}
110110
});
111111

112112
it('Full creation - based on real index', () => {

0 commit comments

Comments
 (0)