@@ -120,6 +120,14 @@ test.describe( 'Global Settings', () => {
120120
121121 // Open the Default Text Block Editor
122122 const defaultBlockPagePromise = page . waitForEvent ( 'popup' )
123+
124+ // Reset the block defaults first if it has been edited
125+ const resetButton = page . locator ( '.components-panel__body' , { hasText : 'Block Defaults' } ) . locator ( '.stk-block-default-control' , { hasText : / ^ T e x t $ / } ) . first ( ) . getByLabel ( 'Reset' )
126+
127+ if ( await resetButton . isVisible ( ) ) {
128+ await resetButton . click ( )
129+ }
130+
123131 const textBlock = page . locator ( '.components-panel__body' , { hasText : 'Block Defaults' } ) . locator ( '.stk-block-default-control' , { hasText : / ^ T e x t $ / } ) . first ( ) . getByLabel ( 'Edit' )
124132 await textBlock . click ( )
125133 const defaultBlockPage = await defaultBlockPagePromise
@@ -129,12 +137,15 @@ test.describe( 'Global Settings', () => {
129137 await defaultBlockPage . getByLabel ( 'Hex color' ) . fill ( 'ff0000' )
130138 await defaultBlockPage . locator ( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ) . first ( ) . click ( )
131139
132- const updateRequest = defaultBlockPage . waitForResponse ( response => response . url ( ) . includes ( 'update_block_style' ) && response . request ( ) . method ( ) === 'POST' )
140+ // The default timeout is 30s, extend it to 90s
141+ const updateRequest = defaultBlockPage . waitForResponse ( response => response . url ( ) . includes ( 'update_block_style' ) && response . request ( ) . method ( ) === 'POST' , { timeout : 90_000 } )
133142
134143 // In older WP versions, the button text is 'Update' instead of 'Save'
135- if ( await defaultBlockPage . getByRole ( 'button' , { name : 'Save' , exact : true } ) . isVisible ( ) ) {
144+ if ( await defaultBlockPage . getByRole ( 'button' , {
145+ name : 'Save' , exact : true , disabled : false ,
146+ } ) . isVisible ( ) ) {
136147 await defaultBlockPage . getByRole ( 'button' , { name : 'Save' , exact : true } ) . click ( )
137- } else {
148+ } else if ( await defaultBlockPage . getByRole ( 'button' , { name : 'Update' , disabled : false } ) . isVisible ( ) ) {
138149 await defaultBlockPage . getByRole ( 'button' , { name : 'Update' } ) . click ( )
139150 }
140151
0 commit comments