@@ -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
@@ -80,26 +85,26 @@ test.describe( 'Global Settings', () => {
8085 await page . getByLabel ( 'Stackable Settings' ) . click ( )
8186 await page . getByRole ( 'button' , { name : 'Global Typography' } ) . click ( )
8287
83- // Set Global Typography Styles of Heading 2 to have a font-size of 32
88+ // Set Global Typography Styles of Heading 2 to have a text-transform uppercase
8489 await page . locator ( '.ugb-global-settings-typography-control' ) . nth ( 1 ) . locator ( '.components-base-control__field > .ugb-button-icon-control__wrapper > .components-button' ) . click ( )
85- await page . locator ( '.stk-popover .components-base-control:nth-of-type(2 )' , { hasText : / S i z e / } ) . getByRole ( 'textbox ' ) . fill ( '32 ' )
90+ await page . locator ( '.stk-popover .components-base-control:nth-of-type(4 )' , { hasText : / T r a n s f o r m / } ) . getByRole ( 'listbox ' ) . selectOption ( 'uppercase ' )
8691 await page . locator ( '.ugb-global-settings-typography-control' ) . nth ( 1 ) . locator ( '.components-base-control__field > .ugb-button-icon-control__wrapper > .components-button' ) . click ( )
8792
88- // Verify if the Heading 2 in Global Typography Styles has correct font size
89- await expect ( page . getByRole ( 'heading' , { name : 'Heading 2' } ) ) . toHaveCSS ( 'font-size ' , '32px ' )
93+ // Verify if the Heading 2 in Global Typography Styles has correct text-transform
94+ await expect ( page . getByRole ( 'heading' , { name : 'Heading 2' } ) ) . toHaveCSS ( 'text-transform ' , 'uppercase ' )
9095
9196 // Open Block Settings
9297 await page . getByLabel ( 'Settings' , { exact : true } ) . click ( )
9398
94- // Check if the added Stackable Heading Block has a font-size of 32
99+ // Check if the added Stackable Heading Block has a text-transform uppercase
95100 editor . insertBlock ( {
96101 name : 'stackable/heading' ,
97102 attributes : {
98103 text : 'test' ,
99104 } ,
100105 } )
101106
102- await expect ( editor . canvas . locator ( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ) . toHaveCSS ( 'font-size ' , '32px ' )
107+ await expect ( editor . canvas . locator ( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ) . toHaveCSS ( 'text-transform ' , 'uppercase ' )
103108
104109 // Reset Global Typography Styles
105110 await page . getByLabel ( 'Stackable Settings' ) . click ( )
@@ -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