Skip to content

Commit

Permalink
Fixing couple of flaky tests in rollups and transforms (#1701)
Browse files Browse the repository at this point in the history
Signed-off-by: Kshitij Tandon <[email protected]>
(cherry picked from commit d71a6b7)
  • Loading branch information
tandonks authored and github-actions[bot] committed Feb 7, 2025
1 parent fce054e commit 88be299
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,40 +221,57 @@ describe('Rollups', () => {
// Confirm we have our initial rollup
cy.contains(ROLLUP_ID);

// Intercept different rollups requests endpoints to wait before clicking disable and enable buttons
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}`).as('getRollup');
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}/_stop`).as('stopRollup');

// Click into rollup job details page
cy.get(`[data-test-subj="rollupLink_${ROLLUP_ID}"]`).click({
force: true,
});

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

cy.wait('@getRollup').wait(2000);

// Click Disable button
cy.get(`[data-test-subj="disableButton"]`)
.should('not.be.disabled')
.click({ force: true });

cy.wait('@stopRollup');
cy.wait('@getRollup');

// Confirm we get toaster saying rollup job is disabled
cy.contains(`${ROLLUP_ID} is disabled`);

// Extra wait required for page data to load, otherwise "Enable" button will be disabled
cy.wait(2000);

// Click Enable button
cy.get(`[data-test-subj="enableButton"]`)
.should('not.be.disabled')
.click({ force: true });

// Confirm we get toaster saying rollup job is enabled
cy.contains(`${ROLLUP_ID} is enabled`);
// First check which button is enabled (not disabled/grayed out)
cy.get(
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
).then(($buttons) => {
// Find which button is enabled
const enableButton = $buttons.filter(
'[data-test-subj="enableButton"]:not([disabled])'
);
const disableButton = $buttons.filter(
'[data-test-subj="disableButton"]:not([disabled])'
);

if (disableButton.length) {
// If disable button is enabled, means job is currently enabled
cy.get('[data-test-subj="disableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`${ROLLUP_ID} is disabled`);

cy.wait(2000);

// Then enable it
cy.get('[data-test-subj="enableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`${ROLLUP_ID} is enabled`);
} else if (enableButton.length) {
// If enable button is enabled, means job is currently disabled
cy.get('[data-test-subj="enableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`${ROLLUP_ID} is enabled`);

cy.wait(2000);

// Then disable it
cy.get('[data-test-subj="disableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`${ROLLUP_ID} is disabled`);
}
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,52 +198,66 @@ describe('Transforms', () => {
// Confirm we have our initial transform
cy.contains(TRANSFORM_ID);

// Intercept different transform requests endpoints to wait before clicking disable and enable buttons
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}`).as('getTransform');
cy.intercept(`/api/ism/transforms/${TRANSFORM_ID}/_stop`).as(
'stopTransform'
);

// Click into transform job details page
cy.get(`[data-test-subj="transformLink_${TRANSFORM_ID}"]`).click({
force: true,
});

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

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

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

// Click Disable button
cy.get(`[data-test-subj="disableButton"]`)
.should('not.be.disabled')
.click();

cy.wait('@stopTransform');
cy.wait('@getTransform');

// Confirm we get toaster saying transform job is disabled
cy.contains(`"${TRANSFORM_ID}" is disabled`);

// Extra wait required for page data to load, otherwise "Enable" button will be disabled
cy.wait(2000);

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

// Click Enable button
cy.get(`[data-test-subj="enableButton"]`)
.should('not.be.disabled')
.click({ force: true });

// Confirm we get toaster saying transform job is enabled
cy.contains(`"${TRANSFORM_ID}" is enabled`);
// Check which action is available (enable or disable)
cy.get(
'[data-test-subj="enableButton"], [data-test-subj="disableButton"]'
).then(($buttons) => {
const enableButton = $buttons.filter(
'[data-test-subj="enableButton"]:not([disabled])'
);
const disableButton = $buttons.filter(
'[data-test-subj="disableButton"]:not([disabled])'
);

if (disableButton.length) {
// If disable button is enabled, means transform is currently enabled
cy.get('[data-test-subj="disableButton"]')
.should('not.be.disabled')
.click();
cy.contains(`"${TRANSFORM_ID}" is disabled`);

cy.wait(1000);

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

// Then enable it
cy.get('[data-test-subj="enableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`"${TRANSFORM_ID}" is enabled`);
} else if (enableButton.length) {
// If enable button is enabled, means transform is currently disabled
cy.get('[data-test-subj="enableButton"]')
.should('not.be.disabled')
.click({ force: true });
cy.contains(`"${TRANSFORM_ID}" is enabled`);

cy.wait(1000);

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

// Then disable it
cy.get('[data-test-subj="disableButton"]')
.should('not.be.disabled')
.click();
cy.contains(`"${TRANSFORM_ID}" is disabled`);
}
});
});
});

Expand Down

0 comments on commit 88be299

Please sign in to comment.