@@ -54,13 +54,12 @@ export const validateBodyThemingCss = function(expectedColor = defaultPrimary, e
5454 */
5555export 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