Skip to content

Commit fc412c1

Browse files
susnuxShGKme
authored andcommitted
fix(cypress): Wait for color change in pickRandomColor
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> [skip ci]
1 parent e0e8719 commit fc412c1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cypress/e2e/theming/themingUtils.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ export const validateBodyThemingCss = function(expectedColor = defaultPrimary, e
5454
*/
5555
export const validateUserThemingDefaultCss = function(expectedColor = defaultPrimary, expectedBackground: string|null = defaultBackground) {
5656
const defaultSelectButton = Cypress.$('[data-user-theming-background-default]')
57-
const customColor = Cypress.$('[data-user-theming-background-color]')
58-
if (defaultSelectButton.length === 0 || customColor.length === 0) {
57+
if (defaultSelectButton.length === 0) {
5958
return false
6059
}
6160

6261
const defaultOptionBackground = defaultSelectButton.css('background-image')
63-
const colorPickerOptionColor = customColor.css('background-color')
62+
const colorPickerOptionColor = defaultSelectButton.css('background-color')
6463

6564
const isValidBackgroundImage = !expectedBackground
6665
? defaultOptionBackground === 'none'
@@ -77,12 +76,20 @@ export const pickRandomColor = function(): Cypress.Chainable<string> {
7776

7877
const colorPreviewSelector = '[data-user-theming-background-color],[data-admin-theming-setting-primary-color]'
7978

79+
let oldColor = ''
80+
cy.get(colorPreviewSelector).then(($el) => {
81+
oldColor = $el.css('background-color')
82+
})
83+
8084
// Open picker
8185
cy.contains('button', 'Change color').click()
8286

8387
// Click on random color
8488
cy.get('.color-picker__simple-color-circle').eq(randColour).click()
8589

90+
// Wait for color change
91+
cy.waitUntil(() => Cypress.$(colorPreviewSelector).css('background-color') !== oldColor)
92+
8693
// Get the selected color from the color preview block
8794
return cy.get(colorPreviewSelector).then(($el) => $el.css('background-color'))
8895
}

0 commit comments

Comments
 (0)