From 49e85f8177aa60320ba947373f7e2ea7022124d8 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 24 Jan 2024 17:34:52 +0100 Subject: [PATCH] fix(cypress): Wait for color change in `pickRandomColor` Signed-off-by: Ferdinand Thiessen --- cypress/e2e/theming/themingUtils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cypress/e2e/theming/themingUtils.ts b/cypress/e2e/theming/themingUtils.ts index 7b570a8cb55b3..7994aae35780d 100644 --- a/cypress/e2e/theming/themingUtils.ts +++ b/cypress/e2e/theming/themingUtils.ts @@ -77,12 +77,20 @@ export const pickRandomColor = function(): Cypress.Chainable { const colorPreviewSelector = '[data-user-theming-background-color],[data-admin-theming-setting-primary-color]' + let oldColor = '' + cy.get(colorPreviewSelector).then(($el) => { + oldColor = $el.css('background-color') + }) + // Open picker cy.contains('button', 'Change color').click() // Click on random color cy.get('.color-picker__simple-color-circle').eq(randColour).click() + // Wait for color change + cy.waitUntil(() => Cypress.$(colorPreviewSelector).css('background-color') !== oldColor) + // Get the selected color from the color preview block return cy.get(colorPreviewSelector).then(($el) => $el.css('background-color')) }