Skip to content

Commit

Permalink
fix(cypress): Wait for color change in pickRandomColor
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Feb 5, 2024
1 parent 360ca48 commit e8fa96b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cypress/e2e/theming/themingUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ export const validateBodyThemingCss = function(expectedColor = defaultPrimary, e
*/
export const validateUserThemingDefaultCss = function(expectedColor = defaultPrimary, expectedBackground: string|null = defaultBackground) {
const defaultSelectButton = Cypress.$('[data-user-theming-background-default]')
const customColor = Cypress.$('[data-user-theming-background-color]')
if (defaultSelectButton.length === 0 || customColor.length === 0) {
if (defaultSelectButton.length === 0) {
return false
}

const defaultOptionBackground = defaultSelectButton.css('background-image')
const colorPickerOptionColor = customColor.css('background-color')
const colorPickerOptionColor = defaultSelectButton.css('background-color')

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

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'))
}

0 comments on commit e8fa96b

Please sign in to comment.