Skip to content

Commit 0b33c2c

Browse files
committed
Fixing couple of flaky tests in rollups and transforms
Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
1 parent 460fd45 commit 0b33c2c

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
@@ -257,40 +257,57 @@ describe('Rollups', () => {
257257
// Confirm we have our initial rollup
258258
cy.contains(ROLLUP_ID);
259259

260-
// Intercept different rollups requests endpoints to wait before clicking disable and enable buttons
261-
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}`).as('getRollup');
262-
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}/_stop`).as('stopRollup');
263-
264260
// Click into rollup job details page
265261
cy.get(`[data-test-subj="rollupLink_${ROLLUP_ID}"]`).click({
266262
force: true,
267263
});
268264

269265
cy.contains(`${ROLLUP_ID}`);
270266

271-
cy.wait('@getRollup').wait(2000);
272-
273-
// Click Disable button
274-
cy.get(`[data-test-subj="disableButton"]`)
275-
.should('not.be.disabled')
276-
.click({ force: true });
277-
278-
cy.wait('@stopRollup');
279-
cy.wait('@getRollup');
280-
281-
// Confirm we get toaster saying rollup job is disabled
282-
cy.contains(`${ROLLUP_ID} is disabled`);
283-
284-
// Extra wait required for page data to load, otherwise "Enable" button will be disabled
285267
cy.wait(2000);
286268

287-
// Click Enable button
288-
cy.get(`[data-test-subj="enableButton"]`)
289-
.should('not.be.disabled')
290-
.click({ force: true });
291-
292-
// Confirm we get toaster saying rollup job is enabled
293-
cy.contains(`${ROLLUP_ID} is enabled`);
269+
// First check which button is enabled (not disabled/grayed out)
270+
cy.get(
271+
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
272+
).then(($buttons) => {
273+
// Find which button is enabled
274+
const enableButton = $buttons.filter(
275+
'[data-test-subj="enableButton"]:not([disabled])'
276+
);
277+
const disableButton = $buttons.filter(
278+
'[data-test-subj="disableButton"]:not([disabled])'
279+
);
280+
281+
if (disableButton.length) {
282+
// If disable button is enabled, means job is currently enabled
283+
cy.get('[data-test-subj="disableButton"]')
284+
.should('not.be.disabled')
285+
.click({ force: true });
286+
cy.contains(`${ROLLUP_ID} is disabled`);
287+
288+
cy.wait(2000);
289+
290+
// Then enable it
291+
cy.get('[data-test-subj="enableButton"]')
292+
.should('not.be.disabled')
293+
.click({ force: true });
294+
cy.contains(`${ROLLUP_ID} is enabled`);
295+
} else if (enableButton.length) {
296+
// If enable button is enabled, means job is currently disabled
297+
cy.get('[data-test-subj="enableButton"]')
298+
.should('not.be.disabled')
299+
.click({ force: true });
300+
cy.contains(`${ROLLUP_ID} is enabled`);
301+
302+
cy.wait(2000);
303+
304+
// Then disable it
305+
cy.get('[data-test-subj="disableButton"]')
306+
.should('not.be.disabled')
307+
.click({ force: true });
308+
cy.contains(`${ROLLUP_ID} is disabled`);
309+
}
310+
});
294311
});
295312
});
296313
});

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

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

245-
// Intercept different transform requests endpoints to wait before clicking disable and enable buttons
246-
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}`).as('getTransform');
247-
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}/_stop`).as(
248-
'stopTransform'
249-
);
250-
251245
// Click into transform job details page
252246
cy.get(`[data-test-subj="transformLink_${TRANSFORM_ID}"]`).click({
253247
force: true,
254248
});
255249

256250
cy.contains(`${TRANSFORM_ID}`);
257251

258-
/* Wait required for page data to load, otherwise "Disable" button will
259-
* appear greyed out and unavailable. Cypress automatically retries,
260-
* but only after menu is open, doesn't re-render.
261-
*/
262-
cy.wait('@getTransform').wait(2000);
252+
/* Wait required for page data to load */
253+
cy.wait(1000);
263254

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

267-
// Click Disable button
268-
cy.get(`[data-test-subj="disableButton"]`)
269-
.should('not.be.disabled')
270-
.click();
271-
272-
cy.wait('@stopTransform');
273-
cy.wait('@getTransform');
274-
275-
// Confirm we get toaster saying transform job is disabled
276-
cy.contains(`"${TRANSFORM_ID}" is disabled`);
277-
278-
// Extra wait required for page data to load, otherwise "Enable" button will be disabled
279-
cy.wait(2000);
280-
281-
// Click into Actions menu
282-
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
283-
284-
// Click Enable button
285-
cy.get(`[data-test-subj="enableButton"]`)
286-
.should('not.be.disabled')
287-
.click({ force: true });
288-
289-
// Confirm we get toaster saying transform job is enabled
290-
cy.contains(`"${TRANSFORM_ID}" is enabled`);
258+
// Check which action is available (enable or disable)
259+
cy.get(
260+
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
261+
).then(($buttons) => {
262+
const enableButton = $buttons.filter(
263+
'[data-test-subj="enableButton"]:not([disabled])'
264+
);
265+
const disableButton = $buttons.filter(
266+
'[data-test-subj="disableButton"]:not([disabled])'
267+
);
268+
269+
if (disableButton.length) {
270+
// If disable button is enabled, means transform is currently enabled
271+
cy.get('[data-test-subj="disableButton"]')
272+
.should('not.be.disabled')
273+
.click();
274+
cy.contains(`"${TRANSFORM_ID}" is disabled`);
275+
276+
cy.wait(1000);
277+
278+
// Click into Actions menu again
279+
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
280+
281+
// Then enable it
282+
cy.get('[data-test-subj="enableButton"]')
283+
.should('not.be.disabled')
284+
.click({ force: true });
285+
cy.contains(`"${TRANSFORM_ID}" is enabled`);
286+
} else if (enableButton.length) {
287+
// If enable button is enabled, means transform is currently disabled
288+
cy.get('[data-test-subj="enableButton"]')
289+
.should('not.be.disabled')
290+
.click({ force: true });
291+
cy.contains(`"${TRANSFORM_ID}" is enabled`);
292+
293+
cy.wait(1000);
294+
295+
// Click into Actions menu again
296+
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
297+
298+
// Then disable it
299+
cy.get('[data-test-subj="disableButton"]')
300+
.should('not.be.disabled')
301+
.click();
302+
cy.contains(`"${TRANSFORM_ID}" is disabled`);
303+
}
304+
});
291305
});
292306
});
293307
});

0 commit comments

Comments
 (0)