Skip to content

Commit ad20704

Browse files
authored
Fix: WP 6.8 Compatibility (#3489)
* adjust wp version, print current wp version * update tests, add php 7.3 and wp 6.5.5 * fix adding slides to carousel block * update failing test * update global settings test * add break, await response to finish
1 parent a9fcc83 commit ad20704

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

.github/workflows/playwright.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ jobs:
1313
matrix:
1414
include:
1515
- php_version: '7.3'
16-
wp_version: 6.4.5
16+
wp_version: 6.5.5
1717

1818
- php_version: '7.3'
1919
wp_version: null
2020

21-
- php_version: '8.2'
22-
wp_version: 6.4.5
23-
2421
- php_version: '8.2'
2522
wp_version: 6.5.5
2623

2724
- php_version: '8.2'
2825
wp_version: 6.6.2
2926

27+
- php_version: '8.2'
28+
wp_version: 6.7.2
29+
3030
- php_version: '8.2'
3131
wp_version: null
3232

@@ -71,6 +71,8 @@ jobs:
7171
npm install -g @wordpress/env
7272
- name: Start wp-env
7373
run: wp-env start
74+
- name: Print current WP version
75+
run: wp-env run tests-cli wp core version
7476
- name: Create post with existing blocks
7577
run: |
7678
POST_ID=$(wp-env run tests-cli wp post create wp-content/plugins/Stackable/e2e/config/post-content.txt --post_title="Existing Blocks" --post_status=publish --porcelain)

e2e/tests/block-editor.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ test.describe( 'Block Editor', () => {
2424
} ) => {
2525
// Insert Stackable Text Block through block inserter
2626
// Also checks if Stackable Block is in the list of blocks in the Editor
27-
await page.getByLabel( 'Toggle block inserter' ).click()
27+
if ( await page.getByLabel( 'Toggle block inserter' ).isVisible() ) {
28+
// For WP version 6.7 and below
29+
await page.getByLabel( 'Toggle block inserter' ).click()
30+
} else {
31+
// For WP version 6.8
32+
await page.getByLabel( 'Block Inserter' ).click()
33+
}
34+
2835
await page.locator( '.editor-block-list-item-stackable-text' ).click()
2936

3037
await expect( editor.canvas.getByLabel( 'Block: Text' ) ).toBeVisible()

e2e/tests/global-settings.spec.ts

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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()

src/block/column/block.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
],
1414
"parent": [
1515
"stackable/columns",
16+
"stackable/carousel",
1617
"stackable/feature",
1718
"stackable/feature-grid",
1819
"stackable/horizontal-scroller",

src/stk-block-types.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ function stackable_get_blocks_array( $blocks = array() ) {
223223
],
224224
'parent' => [
225225
'stackable/columns',
226+
'stackable/carousel',
226227
'stackable/feature',
227228
'stackable/feature-grid',
228229
'stackable/horizontal-scroller',

0 commit comments

Comments
 (0)