@@ -31,14 +31,18 @@ describe('Remove the default background and restore it', { testIsolation: false
3131
3232 it ( 'Remove the default background' , function ( ) {
3333 cy . intercept ( '*/apps/theming/ajax/updateStylesheet' ) . as ( 'removeBackground' )
34+ cy . intercept ( '*/apps/theming/theme/default.css?*' ) . as ( 'cssLoaded' )
3435
3536 cy . findByRole ( 'checkbox' , { name : / r e m o v e b a c k g r o u n d i m a g e / i } )
3637 . should ( 'exist' )
3738 . should ( 'not.be.checked' )
3839 . check ( { force : true } )
3940
4041 cy . wait ( '@removeBackground' )
41- cy . waitUntil ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
42+ cy . wait ( '@cssLoaded' )
43+
44+ cy . window ( )
45+ . should ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
4246 cy . waitUntil ( ( ) => cy . window ( ) . then ( ( win ) => {
4347 const backgroundPlain = getComputedStyle ( win . document . body ) . getPropertyValue ( '--image-background' )
4448 return backgroundPlain !== ''
@@ -49,15 +53,17 @@ describe('Remove the default background and restore it', { testIsolation: false
4953 cy . logout ( )
5054 cy . visit ( '/' )
5155
52- cy . waitUntil ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
56+ cy . window ( )
57+ . should ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
5358 cy . screenshot ( )
5459 } )
5560
5661 it ( 'Undo theming settings and validate login page again' , function ( ) {
5762 cy . resetAdminTheming ( )
5863 cy . visit ( '/' )
5964
60- cy . waitUntil ( validateBodyThemingCss )
65+ cy . window ( )
66+ . should ( ( ) => validateBodyThemingCss ( ) )
6167 cy . screenshot ( )
6268 } )
6369} )
@@ -80,18 +86,22 @@ describe('Remove the default background with a custom background color', functio
8086
8187 it ( 'Change the background color' , function ( ) {
8288 cy . intercept ( '*/apps/theming/ajax/updateStylesheet' ) . as ( 'setColor' )
89+ cy . intercept ( '*/apps/theming/theme/default.css?*' ) . as ( 'cssLoaded' )
8390
8491 pickColor ( cy . findByRole ( 'button' , { name : / B a c k g r o u n d c o l o r / } ) )
8592 . then ( ( color ) => {
8693 selectedColor = color
8794 } )
8895
8996 cy . wait ( '@setColor' )
90- cy . waitUntil ( ( ) => validateBodyThemingCss (
91- defaultPrimary ,
92- defaultBackground ,
93- selectedColor ,
94- ) )
97+ cy . wait ( '@cssLoaded' )
98+
99+ cy . window ( )
100+ . should ( ( ) => validateBodyThemingCss (
101+ defaultPrimary ,
102+ defaultBackground ,
103+ selectedColor ,
104+ ) )
95105 } )
96106
97107 it ( 'Remove the default background' , function ( ) {
@@ -108,15 +118,17 @@ describe('Remove the default background with a custom background color', functio
108118 cy . logout ( )
109119 cy . visit ( '/' )
110120
111- cy . waitUntil ( ( ) => validateBodyThemingCss ( defaultPrimary , null , selectedColor ) )
121+ cy . window ( )
122+ . should ( ( ) => validateBodyThemingCss ( defaultPrimary , null , selectedColor ) )
112123 cy . screenshot ( )
113124 } )
114125
115126 it ( 'Undo theming settings and validate login page again' , function ( ) {
116127 cy . resetAdminTheming ( )
117128 cy . visit ( '/' )
118129
119- cy . waitUntil ( validateBodyThemingCss )
130+ cy . window ( )
131+ . should ( ( ) => validateBodyThemingCss ( ) )
120132 cy . screenshot ( )
121133 } )
122134} )
@@ -148,14 +160,18 @@ describe('Remove the default background with a bright color', function() {
148160
149161 it ( 'Change the background color' , function ( ) {
150162 cy . intercept ( '*/apps/theming/ajax/updateStylesheet' ) . as ( 'setColor' )
163+ cy . intercept ( '*/apps/theming/theme/default.css?*' ) . as ( 'cssLoaded' )
151164
152165 pickColor ( cy . findByRole ( 'button' , { name : / B a c k g r o u n d c o l o r / } ) , 4 )
153166 . then ( ( color ) => {
154167 selectedColor = color
155168 } )
156169
157170 cy . wait ( '@setColor' )
158- cy . waitUntil ( ( ) => validateBodyThemingCss ( defaultPrimary , null , selectedColor ) )
171+ cy . wait ( '@cssLoaded' )
172+
173+ cy . window ( )
174+ . should ( ( ) => validateBodyThemingCss ( defaultPrimary , null , selectedColor ) )
159175 } )
160176
161177 it ( 'See the header being inverted' , function ( ) {
@@ -232,45 +248,54 @@ describe('The user default background settings reflect the admin theming setting
232248
233249 it ( 'Change the default background' , function ( ) {
234250 cy . intercept ( '*/apps/theming/ajax/uploadImage' ) . as ( 'setBackground' )
251+ cy . intercept ( '*/apps/theming/theme/default.css?*' ) . as ( 'cssLoaded' )
235252
236253 cy . fixture ( 'image.jpg' , null ) . as ( 'background' )
237254 cy . get ( 'input[type="file"][name="background"]' )
238255 . should ( 'exist' )
239256 . selectFile ( '@background' , { force : true } )
240257
241258 cy . wait ( '@setBackground' )
242- cy . waitUntil ( ( ) => validateBodyThemingCss (
243- defaultPrimary ,
244- '/apps/theming/image/background?v=' ,
245- null ,
246- ) )
259+ cy . wait ( '@cssLoaded' )
260+
261+ cy . window ( )
262+ . should ( ( ) => validateBodyThemingCss (
263+ defaultPrimary ,
264+ '/apps/theming/image/background?v=' ,
265+ null ,
266+ ) )
247267 } )
248268
249269 it ( 'Change the background color' , function ( ) {
250270 cy . intercept ( '*/apps/theming/ajax/updateStylesheet' ) . as ( 'setColor' )
271+ cy . intercept ( '*/apps/theming/theme/default.css?*' ) . as ( 'cssLoaded' )
251272
252273 pickColor ( cy . findByRole ( 'button' , { name : / B a c k g r o u n d c o l o r / } ) )
253274 . then ( ( color ) => {
254275 selectedColor = color
255276 } )
256277
257278 cy . wait ( '@setColor' )
258- cy . waitUntil ( ( ) => validateBodyThemingCss (
259- defaultPrimary ,
260- '/apps/theming/image/background?v=' ,
261- selectedColor ,
262- ) )
279+ cy . wait ( '@cssLoaded' )
280+
281+ cy . window ( )
282+ . should ( ( ) => validateBodyThemingCss (
283+ defaultPrimary ,
284+ '/apps/theming/image/background?v=' ,
285+ selectedColor ,
286+ ) )
263287 } )
264288
265289 it ( 'Login page should match admin theming settings' , function ( ) {
266290 cy . logout ( )
267291 cy . visit ( '/' )
268292
269- cy . waitUntil ( ( ) => validateBodyThemingCss (
270- defaultPrimary ,
271- '/apps/theming/image/background?v=' ,
272- selectedColor ,
273- ) )
293+ cy . window ( )
294+ . should ( ( ) => validateBodyThemingCss (
295+ defaultPrimary ,
296+ '/apps/theming/image/background?v=' ,
297+ selectedColor ,
298+ ) )
274299 } )
275300
276301 it ( 'Login as user' , function ( ) {
@@ -290,10 +315,11 @@ describe('The user default background settings reflect the admin theming setting
290315 . should ( 'exist' )
291316 . and ( 'have.attr' , 'aria-pressed' , 'true' )
292317
293- cy . waitUntil ( ( ) => validateUserThemingDefaultCss (
294- selectedColor ,
295- '/apps/theming/image/background?v=' ,
296- ) )
318+ cy . window ( )
319+ . should ( ( ) => validateUserThemingDefaultCss (
320+ selectedColor ,
321+ '/apps/theming/image/background?v=' ,
322+ ) )
297323 } )
298324} )
299325
@@ -326,7 +352,8 @@ describe('The user default background settings reflect the admin theming setting
326352 cy . logout ( )
327353 cy . visit ( '/' )
328354
329- cy . waitUntil ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
355+ cy . window ( )
356+ . should ( ( ) => validateBodyThemingCss ( defaultPrimary , null ) )
330357 } )
331358
332359 it ( 'Login as user' , function ( ) {
@@ -346,6 +373,7 @@ describe('The user default background settings reflect the admin theming setting
346373 . should ( 'exist' )
347374 . and ( 'have.attr' , 'aria-pressed' , 'true' )
348375
349- cy . waitUntil ( ( ) => validateUserThemingDefaultCss ( defaultPrimary , null ) )
376+ cy . window ( )
377+ . should ( ( ) => validateUserThemingDefaultCss ( defaultPrimary , null ) )
350378 } )
351379} )
0 commit comments