diff options
Diffstat (limited to 'cypress/e2e/theming/themingUtils.ts')
-rw-r--r-- | cypress/e2e/theming/themingUtils.ts | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/cypress/e2e/theming/themingUtils.ts b/cypress/e2e/theming/themingUtils.ts index f9f4a9b0fd2..c0140293c22 100644 --- a/cypress/e2e/theming/themingUtils.ts +++ b/cypress/e2e/theming/themingUtils.ts @@ -21,23 +21,29 @@ */ import { colord } from 'colord' +export const defaultPrimary = '#0082c9' +export const defaultAccessiblePrimary = '#006aa3' +export const defaultBackground = 'kamil-porembinski-clouds.jpg' + /** * Validate the current page body css variables * * @param {string} expectedColor the expected color * @param {string|null} expectedBackground the expected background */ -export const validateBodyThemingCss = function(expectedColor = '#0082c9', expectedBackground: string|null = 'kamil-porembinski-clouds.jpg') { +export const validateBodyThemingCss = function(expectedColor = defaultPrimary, expectedBackground: string|null = defaultBackground) { return cy.window().then((win) => { const guestBackgroundColor = getComputedStyle(win.document.body).backgroundColor const guestBackgroundImage = getComputedStyle(win.document.body).backgroundImage - const isValidBackgroundImage = expectedBackground === null + const isValidBackgroundColor = colord(guestBackgroundColor).isEqual(expectedColor) + const isValidBackgroundImage = !expectedBackground ? guestBackgroundImage === 'none' : guestBackgroundImage.includes(expectedBackground) - return colord(guestBackgroundColor).isEqual(expectedColor) - && isValidBackgroundImage + console.debug({ guestBackgroundColor: colord(guestBackgroundColor).toHex(), guestBackgroundImage, expectedColor, expectedBackground, isValidBackgroundColor, isValidBackgroundImage }) + + return isValidBackgroundColor && isValidBackgroundImage }) } @@ -47,7 +53,7 @@ export const validateBodyThemingCss = function(expectedColor = '#0082c9', expect * @param {string} expectedColor the expected color * @param {string} expectedBackground the expected background */ -export const validateUserThemingDefaultCss = function(expectedColor = '#0082c9', expectedBackground: string|null = 'kamil-porembinski-clouds.jpg') { +export const validateUserThemingDefaultCss = function(expectedColor = defaultPrimary, expectedBackground: string|null = defaultBackground) { return cy.window().then((win) => { const defaultSelectButton = win.document.querySelector('[data-user-theming-background-default]') const customColorSelectButton = win.document.querySelector('[data-user-theming-background-color]') @@ -59,9 +65,11 @@ export const validateUserThemingDefaultCss = function(expectedColor = '#0082c9', const defaultOptionBorderColor = getComputedStyle(defaultSelectButton).borderColor const colorPickerOptionColor = getComputedStyle(customColorSelectButton).backgroundColor - const isValidBackgroundImage = expectedBackground === null + const isValidBackgroundImage = !expectedBackground ? defaultOptionBackground === 'none' : defaultOptionBackground.includes(expectedBackground) + + console.debug(colord(defaultOptionBorderColor).toHex(), colord(colorPickerOptionColor).toHex(), expectedColor, isValidBackgroundImage) return isValidBackgroundImage && colord(defaultOptionBorderColor).isEqual(expectedColor) |