@@ -51,10 +51,15 @@ test.describe( 'Global Settings', () => {
5151
5252 // Verify the newly added global color is in the color picker
5353 await expect ( page . getByRole ( 'heading' , { name : 'Global Colors' } ) ) . toBeVisible ( )
54- await expect ( page . getByLabel ( `Color: Custom Color ${ count } ` ) ) . toBeVisible ( )
54+
55+ // For WP 6.7 and below, the label for colors has a prefix `Color: `
56+ // For WP 6.8 the prefix was removed.
57+ const regex = new RegExp ( `^(?:Color:\\s*)?Custom Color ${ count } $` )
58+
59+ await expect ( page . getByLabel ( regex ) ) . toBeVisible ( )
5560
5661 // Verify the color value
57- await page . getByLabel ( `Color: Custom Color ${ count } ` ) . click ( )
62+ await page . getByLabel ( regex ) . click ( )
5863 await expect ( page . getByLabel ( 'Hex color' ) ) . toHaveValue ( hexValue )
5964
6065 // Click on the color picker button to close the popup
@@ -139,7 +144,7 @@ test.describe( 'Global Settings', () => {
139144 await defaultBlockPage . locator ( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ) . first ( ) . click ( )
140145
141146 // The default timeout is 30s, extend it to 90s
142- const updateRequest = defaultBlockPage . waitForRequest ( request => request . url ( ) . includes ( 'update_block_style' ) && request . method ( ) === 'POST' , { timeout : 90_000 } )
147+ const updateRequest = defaultBlockPage . waitForResponse ( response => response . url ( ) . includes ( 'update_block_style' ) && response . request ( ) . method ( ) === 'POST' , { timeout : 90_000 } )
143148
144149 // In older WP versions, the button text is 'Update' instead of 'Save'
145150 if ( await defaultBlockPage . getByRole ( 'button' , {
@@ -150,20 +155,28 @@ test.describe( 'Global Settings', () => {
150155 await defaultBlockPage . getByRole ( 'button' , { name : 'Update' } ) . click ( )
151156 }
152157
153- // Make sure default block has been updated before closing the tab
154- await updateRequest
155- await defaultBlockPage . close ( )
158+ // Make sure default block has been updated
159+ await ( await updateRequest ) . finished ( )
156160
157161 // Insert a Stackable Text Block, and check if the color is the same as the one set in the default block
158- await page . reload ( )
159- await editor . insertBlock ( {
160- name : 'stackable/text' ,
161- attributes : {
162- text : 'test' ,
163- } ,
164- } )
165-
166- await expect ( editor . canvas . locator ( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' )
162+ const timeouts = [ 1_000 , 5_000 , 30_000 ]
163+ for ( const timeout of timeouts ) {
164+ try {
165+ await page . reload ( )
166+ await editor . insertBlock ( {
167+ name : 'stackable/text' ,
168+ attributes : {
169+ text : 'test' ,
170+ } ,
171+ } )
172+
173+ await expect ( editor . canvas . locator ( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ) . toHaveCSS ( 'color' , 'rgb(255, 0, 0)' )
174+ break
175+ } catch ( e ) {
176+ // Ignore the error and try again because the default block might not be updated yet
177+ await page . waitForTimeout ( timeout )
178+ }
179+ }
167180
168181 // Reset Default Block
169182 await page . getByLabel ( 'Stackable Settings' ) . click ( )
0 commit comments