From 9708e4df91f15386f72e2d63fe2388a0593f60a9 Mon Sep 17 00:00:00 2001 From: Rohit Ashiwal Date: Fri, 16 Feb 2024 04:55:37 +0530 Subject: [PATCH] rollups/transform: wait for page to render Signed-off-by: Rohit Ashiwal --- .../rollups_spec.js | 25 +++++++++++++------ .../transforms_spec.js | 22 +++++++++++++--- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js index 4be179ce0..4210d4e66 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/rollups_spec.js @@ -257,6 +257,10 @@ 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, @@ -264,21 +268,26 @@ describe('Rollups', () => { cy.contains(`${ROLLUP_ID}`); - // Disable button is enabled - cy.get(`[data-test-subj="disableButton"]`).should('not.be.disabled'); + cy.wait('@getRollup').wait(2000); // Click Disable button - cy.get(`[data-test-subj="disableButton"]`).trigger('click', { - force: true, - }); + 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"]`).trigger('click', { - force: true, - }); + 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`); diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/transforms_spec.js b/cypress/integration/plugins/index-management-dashboards-plugin/transforms_spec.js index d65eadcf9..0b097ff54 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/transforms_spec.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/transforms_spec.js @@ -239,6 +239,12 @@ 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, @@ -250,24 +256,32 @@ describe('Transforms', () => { * appear greyed out and unavailable. Cypress automatically retries, * but only after menu is open, doesn't re-render. */ - cy.wait(1000); + cy.wait('@getTransform').wait(2000); // Click into Actions menu cy.get(`[data-test-subj="actionButton"]`).click({ force: true }); // Click Disable button - cy.get(`[data-test-subj="disableButton"]`).click(); + 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`); - cy.wait(1000); + // 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"]`).click({ force: true }); + 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`);