Skip to content

Commit 8d7ed8a

Browse files
committed
Merge branch 'develop' into feat/global-block-layout
# Conflicts: # src/dynamic-breakpoints.php
2 parents d8610b0 + a81cf9d commit 8d7ed8a

File tree

25 files changed

+2446
-2229
lines changed

25 files changed

+2446
-2229
lines changed

e2e/readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ WP_BASE_URL=http://local.local/
3232
WP_AUTH_STORAGE=wp-auth.json
3333
WP_USERNAME=admin
3434
WP_PASSWORD=password
35+
STACKABLE_SLUG={ STACKABLE SLUG }
36+
WP_TEST_POSTID={ POST_ID }
37+
WP_STK_LICENSE={ STACKABLE LICENSE }
3538
```
3639

40+
In Freemius, make sure the license key is:
41+
- new
42+
- lifetime unlimited quota
43+
- has an owner
44+
- non-blocking and white-labeled
45+
3746
Run this command to run e2e:
3847

3948
```bash

e2e/tests/block-editor.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ test.describe( 'Block Editor', () => {
3939
} )
4040

4141
await editor.selectBlocks( editor.canvas.getByLabel( 'Block: Text' ) )
42+
43+
const settings = page.getByLabel( 'Settings', { exact: true } )
44+
45+
if ( await settings.getAttribute( 'aria-pressed' ) === 'false' ) {
46+
await settings.click()
47+
}
48+
4249
await expect( page.getByLabel( 'Layout Tab' ) ).toBeVisible()
4350
await expect( page.getByLabel( 'Style Tab' ) ).toBeVisible()
4451
await expect( page.getByLabel( 'Advanced Tab' ) ).toBeVisible()
@@ -52,6 +59,12 @@ test.describe( 'Block Editor', () => {
5259
name: 'stackable/text',
5360
} )
5461

62+
const settings = page.getByLabel( 'Settings', { exact: true } )
63+
64+
if ( await settings.getAttribute( 'aria-pressed' ) === 'false' ) {
65+
await settings.click()
66+
}
67+
5568
// Add content and color to Stackable Text Block
5669
await editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ).fill( 'test' )
5770
await page.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()

e2e/tests/global-settings.spec.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test, expect } from 'e2e/test-utils'
2-
import { createColor, getRgb } from '~stackable/plugins/global-settings/colors/util'
32

4-
test.describe( 'Global Settigs', () => {
3+
test.describe( 'Global Settings', () => {
54
let pid = null
65

76
// Create Posts for testing
@@ -62,7 +61,15 @@ test.describe( 'Global Settigs', () => {
6261

6362
// Delete added Global Color
6463
await page.getByLabel( 'Stackable Settings' ).click()
65-
await panel.locator( `.ugb-global-settings-color-picker__color-indicators > div > div:nth-child(${ count }) > button.stk-global-settings-color-picker__delete-button` ).click()
64+
65+
page.on( 'dialog', async dialog => await dialog.accept() )
66+
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )
67+
68+
await globalColors.getByLabel( 'Delete' ).nth( count - 1 ).click()
69+
70+
await deleteRequest
71+
const _count = ( await globalColors.evaluate( node => Array.from( node.childNodes ) ) ).length
72+
expect( _count ).toBeLessThan( count )
6673
} )
6774

6875
test( 'Global Typography Styles should be applied when adding a heading', async ( {
@@ -93,18 +100,21 @@ test.describe( 'Global Settigs', () => {
93100

94101
await expect( editor.canvas.locator( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ).toHaveCSS( 'font-size', '32px' )
95102

96-
// Reset Global Typography Styles
97-
await page.getByLabel( 'Stackable Settings' ).click()
98-
await page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).getByRole( 'button', { name: 'Reset' } ).click()
103+
// Reset Global Typography Styles
104+
await page.getByLabel( 'Stackable Settings' ).click()
105+
106+
const resetButton = page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).getByLabel( 'Reset' )
107+
const deleteRequest = page.waitForResponse( response => response.url().includes( 'wp/v2/settings' ) && response.request().method() === 'POST' )
108+
await resetButton.click()
109+
110+
await deleteRequest
111+
await expect( resetButton ).not.toBeVisible()
99112
} )
100113

101114
test( 'When a default block is created, adding the block should have the default block\'s attributes', async ( {
102115
page,
103116
editor,
104117
} ) => {
105-
// Generate a color
106-
const color = createColor()
107-
108118
await page.getByLabel( 'Stackable Settings' ).click()
109119
await page.getByRole( 'button', { name: 'Block Defaults' } ).click()
110120

@@ -116,16 +126,20 @@ test.describe( 'Global Settigs', () => {
116126

117127
// Set a color for the default Text Block
118128
await defaultBlockPage.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
119-
await defaultBlockPage.getByLabel( 'Hex color' ).fill( color )
129+
await defaultBlockPage.getByLabel( 'Hex color' ).fill( 'ff0000' )
120130
await defaultBlockPage.locator( '.stk-color-palette-control .stk-control-content > .components-dropdown > .components-button' ).first().click()
121131

132+
const updateRequest = defaultBlockPage.waitForResponse( response => response.url().includes( 'update_block_style' ) && response.request().method() === 'POST' )
133+
122134
// In older WP versions, the button text is 'Update' instead of 'Save'
123135
if ( await defaultBlockPage.getByRole( 'button', { name: 'Save', exact: true } ).isVisible() ) {
124136
await defaultBlockPage.getByRole( 'button', { name: 'Save', exact: true } ).click()
125137
} else {
126138
await defaultBlockPage.getByRole( 'button', { name: 'Update' } ).click()
127139
}
128140

141+
// Make sure default block has been updated before closing the tab
142+
await updateRequest
129143
await defaultBlockPage.close()
130144

131145
// Insert a Stackable Text Block, and check if the color is the same as the one set in the default block
@@ -137,12 +151,11 @@ test.describe( 'Global Settigs', () => {
137151
},
138152
} )
139153

140-
await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', `rgb(${ getRgb( color ) })` )
154+
await expect( editor.canvas.locator( '[data-type="stackable/text"] > .stk-block-text > p[role="textbox"]' ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
141155

142156
// Reset Default Block
143157
await page.getByLabel( 'Stackable Settings' ).click()
144158
await page.getByRole( 'button', { name: 'Block Defaults' } ).click()
145159
await page.locator( '.components-panel__body', { hasText: 'Block Defaults' } ).locator( '.stk-block-default-control', { hasText: /^Text$/ } ).first().getByLabel( 'Reset' ).click()
146160
} )
147161
} )
148-

0 commit comments

Comments
 (0)