Skip to content

Commit 7c94962

Browse files
Fixing couple of flaky tests in rollups and transforms (#1701) (#1704)
Signed-off-by: Kshitij Tandon <tandonks@amazon.com> (cherry picked from commit d71a6b7) Co-authored-by: Kshitij Tandon <tandonks@amazon.com>
1 parent fce054e commit 7c94962

File tree

2 files changed

+91
-60
lines changed

2 files changed

+91
-60
lines changed

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

+42-25
Original file line numberDiff line numberDiff line change
@@ -221,40 +221,57 @@ describe('Rollups', () => {
221221
// Confirm we have our initial rollup
222222
cy.contains(ROLLUP_ID);
223223

224-
// Intercept different rollups requests endpoints to wait before clicking disable and enable buttons
225-
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}`).as('getRollup');
226-
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}/_stop`).as('stopRollup');
227-
228224
// Click into rollup job details page
229225
cy.get(`[data-test-subj="rollupLink_${ROLLUP_ID}"]`).click({
230226
force: true,
231227
});
232228

233229
cy.contains(`${ROLLUP_ID}`);
234230

235-
cy.wait('@getRollup').wait(2000);
236-
237-
// Click Disable button
238-
cy.get(`[data-test-subj="disableButton"]`)
239-
.should('not.be.disabled')
240-
.click({ force: true });
241-
242-
cy.wait('@stopRollup');
243-
cy.wait('@getRollup');
244-
245-
// Confirm we get toaster saying rollup job is disabled
246-
cy.contains(`${ROLLUP_ID} is disabled`);
247-
248-
// Extra wait required for page data to load, otherwise "Enable" button will be disabled
249231
cy.wait(2000);
250232

251-
// Click Enable button
252-
cy.get(`[data-test-subj="enableButton"]`)
253-
.should('not.be.disabled')
254-
.click({ force: true });
255-
256-
// Confirm we get toaster saying rollup job is enabled
257-
cy.contains(`${ROLLUP_ID} is enabled`);
233+
// First check which button is enabled (not disabled/grayed out)
234+
cy.get(
235+
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
236+
).then(($buttons) => {
237+
// Find which button is enabled
238+
const enableButton = $buttons.filter(
239+
'[data-test-subj="enableButton"]:not([disabled])'
240+
);
241+
const disableButton = $buttons.filter(
242+
'[data-test-subj="disableButton"]:not([disabled])'
243+
);
244+
245+
if (disableButton.length) {
246+
// If disable button is enabled, means job is currently enabled
247+
cy.get('[data-test-subj="disableButton"]')
248+
.should('not.be.disabled')
249+
.click({ force: true });
250+
cy.contains(`${ROLLUP_ID} is disabled`);
251+
252+
cy.wait(2000);
253+
254+
// Then enable it
255+
cy.get('[data-test-subj="enableButton"]')
256+
.should('not.be.disabled')
257+
.click({ force: true });
258+
cy.contains(`${ROLLUP_ID} is enabled`);
259+
} else if (enableButton.length) {
260+
// If enable button is enabled, means job is currently disabled
261+
cy.get('[data-test-subj="enableButton"]')
262+
.should('not.be.disabled')
263+
.click({ force: true });
264+
cy.contains(`${ROLLUP_ID} is enabled`);
265+
266+
cy.wait(2000);
267+
268+
// Then disable it
269+
cy.get('[data-test-subj="disableButton"]')
270+
.should('not.be.disabled')
271+
.click({ force: true });
272+
cy.contains(`${ROLLUP_ID} is disabled`);
273+
}
274+
});
258275
});
259276
});
260277

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

+49-35
Original file line numberDiff line numberDiff line change
@@ -198,52 +198,66 @@ describe('Transforms', () => {
198198
// Confirm we have our initial transform
199199
cy.contains(TRANSFORM_ID);
200200

201-
// Intercept different transform requests endpoints to wait before clicking disable and enable buttons
202-
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}`).as('getTransform');
203-
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}/_stop`).as(
204-
'stopTransform'
205-
);
206-
207201
// Click into transform job details page
208202
cy.get(`[data-test-subj="transformLink_${TRANSFORM_ID}"]`).click({
209203
force: true,
210204
});
211205

212206
cy.contains(`${TRANSFORM_ID}`);
213207

214-
/* Wait required for page data to load, otherwise "Disable" button will
215-
* appear greyed out and unavailable. Cypress automatically retries,
216-
* but only after menu is open, doesn't re-render.
217-
*/
218-
cy.wait('@getTransform').wait(2000);
208+
/* Wait required for page data to load */
209+
cy.wait(1000);
219210

220211
// Click into Actions menu
221212
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
222213

223-
// Click Disable button
224-
cy.get(`[data-test-subj="disableButton"]`)
225-
.should('not.be.disabled')
226-
.click();
227-
228-
cy.wait('@stopTransform');
229-
cy.wait('@getTransform');
230-
231-
// Confirm we get toaster saying transform job is disabled
232-
cy.contains(`"${TRANSFORM_ID}" is disabled`);
233-
234-
// Extra wait required for page data to load, otherwise "Enable" button will be disabled
235-
cy.wait(2000);
236-
237-
// Click into Actions menu
238-
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
239-
240-
// Click Enable button
241-
cy.get(`[data-test-subj="enableButton"]`)
242-
.should('not.be.disabled')
243-
.click({ force: true });
244-
245-
// Confirm we get toaster saying transform job is enabled
246-
cy.contains(`"${TRANSFORM_ID}" is enabled`);
214+
// Check which action is available (enable or disable)
215+
cy.get(
216+
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
217+
).then(($buttons) => {
218+
const enableButton = $buttons.filter(
219+
'[data-test-subj="enableButton"]:not([disabled])'
220+
);
221+
const disableButton = $buttons.filter(
222+
'[data-test-subj="disableButton"]:not([disabled])'
223+
);
224+
225+
if (disableButton.length) {
226+
// If disable button is enabled, means transform is currently enabled
227+
cy.get('[data-test-subj="disableButton"]')
228+
.should('not.be.disabled')
229+
.click();
230+
cy.contains(`"${TRANSFORM_ID}" is disabled`);
231+
232+
cy.wait(1000);
233+
234+
// Click into Actions menu again
235+
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
236+
237+
// Then enable it
238+
cy.get('[data-test-subj="enableButton"]')
239+
.should('not.be.disabled')
240+
.click({ force: true });
241+
cy.contains(`"${TRANSFORM_ID}" is enabled`);
242+
} else if (enableButton.length) {
243+
// If enable button is enabled, means transform is currently disabled
244+
cy.get('[data-test-subj="enableButton"]')
245+
.should('not.be.disabled')
246+
.click({ force: true });
247+
cy.contains(`"${TRANSFORM_ID}" is enabled`);
248+
249+
cy.wait(1000);
250+
251+
// Click into Actions menu again
252+
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
253+
254+
// Then disable it
255+
cy.get('[data-test-subj="disableButton"]')
256+
.should('not.be.disabled')
257+
.click();
258+
cy.contains(`"${TRANSFORM_ID}" is disabled`);
259+
}
260+
});
247261
});
248262
});
249263

0 commit comments

Comments
 (0)