Skip to content

Commit e5b54a8

Browse files
aditi-1601Aditi Chaudhry
andauthored
fix ism e2e: dismissToast and failOnStatusCode for managed service (#2103)
Signed-off-by: Aditi Chaudhry <aditiac@amazon.com> Co-authored-by: Aditi Chaudhry <aditiac@amazon.com>
1 parent 4b56ceb commit e5b54a8

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

cypress/integration/plugins/index-management-dashboards-plugin/managed_indices_spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Managed indices', () => {
2929
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
3030
cy.contains('Edit rollover alias', { timeout: 60000 });
3131

32-
cy.get('[data-test-subj="toastCloseButton"]').click({ force: true });
32+
cy.dismissToast();
3333
});
3434

3535
describe('can have policies removed', () => {
@@ -90,7 +90,7 @@ describe('Managed indices', () => {
9090
// Wait up to 5 seconds for the managed index to execute
9191
// eslint-disable-next-line cypress/no-unnecessary-waiting
9292
cy.wait(5000).reload();
93-
cy.get('[data-test-subj="toastCloseButton"]').click({ force: true });
93+
cy.dismissToast();
9494

9595
// Confirm managed index successfully initialized the policy
9696
cy.contains('Successfully initialized', { timeout: 20000 });
@@ -100,7 +100,7 @@ describe('Managed indices', () => {
100100
// Wait up to 5 seconds for managed index to execute
101101
// eslint-disable-next-line cypress/no-unnecessary-waiting
102102
cy.wait(5000).reload();
103-
cy.get('[data-test-subj="toastCloseButton"]').click({ force: true });
103+
cy.dismissToast();
104104

105105
// Confirm we have a Failed execution, wait up to 20 seconds as OSD takes a while to load
106106
cy.contains('Failed', { timeout: 20000 });
@@ -127,7 +127,7 @@ describe('Managed indices', () => {
127127

128128
// Reload the page
129129
cy.reload();
130-
cy.get('[data-test-subj="toastCloseButton"]').click({ force: true });
130+
cy.dismissToast();
131131

132132
// Confirm we see managed index attempting to retry, give 20 seconds for OSD load
133133
cy.contains('Pending retry of failed managed index', { timeout: 20000 });
@@ -138,7 +138,7 @@ describe('Managed indices', () => {
138138
// Wait up to 5 seconds for managed index to execute
139139
// eslint-disable-next-line cypress/no-unnecessary-waiting
140140
cy.wait(5000).reload();
141-
cy.get('[data-test-subj="toastCloseButton"]').click({ force: true });
141+
cy.dismissToast();
142142

143143
// Confirm managed index successfully rolled over
144144
cy.contains('Successfully rolled over', { timeout: 20000 });

cypress/utils/commands.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ Cypress.Commands.add('login', () => {
9999
// This function does not delete all indices
100100
Cypress.Commands.add('deleteAllIndices', () => {
101101
cy.log('Deleting all indices');
102-
cy.request(
103-
'DELETE',
104-
`${Cypress.env(
102+
cy.request({
103+
method: 'DELETE',
104+
url: `${Cypress.env(
105105
'openSearchUrl'
106-
)}/index*,sample*,opensearch_dashboards*,test*,cypress*`
107-
);
106+
)}/index*,sample*,opensearch_dashboards*,test*,cypress*`,
107+
failOnStatusCode: false,
108+
});
108109
});
109110

110111
Cypress.Commands.add('deleteADSystemIndices', () => {

cypress/utils/plugins/index-management-dashboards-plugin/commands.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,11 @@ Cypress.Commands.add('removeIndexAlias', (alias) => {
171171
failOnStatusCode: false,
172172
});
173173
});
174+
175+
Cypress.Commands.add('dismissToast', () => {
176+
cy.get('body').then(($body) => {
177+
if ($body.find(`[data-test-subj="toastCloseButton"]`).length) {
178+
cy.get(`[data-test-subj="toastCloseButton"]`).click({ force: true });
179+
}
180+
});
181+
});

0 commit comments

Comments
 (0)