Skip to content

Commit a0df781

Browse files
committed
Merge branch 'develop' into feat/global-color-schemes
2 parents 97e11d5 + 3219779 commit a0df781

File tree

22 files changed

+222
-163
lines changed

22 files changed

+222
-163
lines changed

.config/webpack.config.dev.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ module.exports = [
2626
},
2727
// Admin settings script.
2828
'admin_welcome': path.resolve( __dirname, '../src/welcome/admin.js' ),
29-
// V2 deprecated scripts, we build this here since that's how we did it before.
30-
'admin_welcome_v2': {
31-
import: path.resolve( __dirname, '../src/deprecated/v2/welcome/admin.js' ),
32-
filename: 'deprecated/[name].js'
33-
},
3429
'frontend_blocks_deprecated_v2': {
3530
import: path.resolve( __dirname, '../src/deprecated/v2/block-frontend.js' ),
3631
filename: 'deprecated/[name].js'

.config/webpack.config.prod.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ module.exports = [
2626
},
2727
// Admin settings script.
2828
'admin_welcome': path.resolve( __dirname, '../src/welcome/admin.js' ),
29-
// V2 deprecated script, we build this here since that's how we did it before.
30-
'admin_welcome_v2': {
31-
import: path.resolve( __dirname, '../src/deprecated/v2/welcome/admin.js' ),
32-
filename: 'deprecated/[name].js'
33-
},
3429
'frontend_blocks_deprecated_v2': {
3530
import: path.resolve( __dirname, '../src/deprecated/v2/block-frontend.js' ),
3631
filename: 'deprecated/[name].js'

e2e/test-utils/stackable.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export class StackableFixture {
88
this.page = page
99
}
1010

11-
// When loading the Stackable settings in the Admin, there are 4 requests to wp/v2/settings
12-
// This function waits for all 4 requests to finish to ensure Stackable settings are loaded and reflected on the page
11+
// Wait for Stackable Settings to be fetched
1312
async waitForSettings(): Promise<void> {
1413
return new Promise( ( resolve, reject ) => {
15-
let responseCount = 0
16-
1714
const cleanup = () => {
1815
this.page.off( 'requestfinished', finishedCallback )
1916
this.page.off( 'requestfinished', failedCallback )
@@ -29,14 +26,10 @@ export class StackableFixture {
2926
} )
3027

3128
if ( settings ) {
32-
responseCount++
33-
} else {
34-
throw Error( 'Failed to get Stackable settings' )
35-
}
36-
37-
if ( responseCount === 4 ) {
3829
cleanup()
3930
resolve()
31+
} else {
32+
throw Error( 'Failed to get Stackable settings' )
4033
}
4134
} catch ( error ) {
4235
cleanup()

e2e/tests/admin.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ test( 'Stackable settings should be saved', async ( {
4040
// Make sure all Stackable settings are loaded
4141
await settings
4242

43+
// There should be no PHP errors
44+
const pageError = await admin.getPageError()
45+
expect( pageError ).toBeNull()
46+
4347
// Retrieves the value of the first option, toggles it and check if the value changed
4448
const option = page.locator( '.ugb-admin-toggle-setting' ).first().getByRole( 'switch' )
4549
const val = await option.getAttribute( 'aria-checked' )

e2e/tests/block-editor.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ test.describe( 'Block Editor', () => {
9292
} )
9393

9494
test( 'The Stackable block added in the editor should be visible in the frontend', async ( {
95-
page, editor,
95+
page, editor, admin,
9696
} ) => {
9797
await editor.insertBlock( {
9898
name: 'stackable/text',
@@ -124,5 +124,9 @@ test.describe( 'Block Editor', () => {
124124
await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toBeVisible()
125125
await expect( preview.locator( `[data-block-id="${ uniqueId }"]` ) ).toContainText( 'test' )
126126
await expect( preview.locator( `[data-block-id="${ uniqueId }"] p` ) ).toHaveCSS( 'color', 'rgb(255, 0, 0)' )
127+
128+
// There should be no PHP errors on frontend
129+
const pageError = await admin.getPageError()
130+
expect( pageError ).toBeNull()
127131
} )
128132
} )

e2e/tests/global-settings.spec.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: /^Text$/ } ).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: /^Text$/ } ).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

plugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,5 @@ function is_frontend() {
294294
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/blocks.php' );
295295
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/disabled-blocks.php' );
296296
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/design-library/init.php' );
297-
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/admin.php' );
298297
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/optimization-settings.php' );
299298
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/v2/global-settings.php' );

src/block-components/typography/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export const Controls = props => {
165165
label={ __( 'Font Family', i18n ) }
166166
onChange={ updateAttributeHandler( 'fontFamily' ) }
167167
value={ getAttribute( 'fontFamily' ) }
168+
placeholder={ __( 'Theme Default', i18n ) }
168169
helpTooltip={ {
169170
video: 'typography-family',
170171
description: __( 'Sets the font set to be used for the element', i18n ),

src/block/icon-label/deprecated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const deprecated = [
1818

1919
const iconBlockAttributes = innerBlocks[ 0 ].attributes
2020
const hasIconSize = iconBlockAttributes.iconSize || iconBlockAttributes.iconSizeTablet || iconBlockAttributes.iconSizeMobile ? true : false
21-
const hasIconGap = attributes.iconGap || attributes.iconGapTablet || attributes.iconGapMobile ? true : false
22-
const hasIconGap2 = attributes.iconGap2 || attributes.iconGap2Tablet || attributes.iconGap2Mobile ? true : false
21+
const hasIconGap = attributes.iconGap || attributes.iconGap === 0 || attributes.iconGapTablet || attributes.iconGapMobile ? true : false
22+
const hasIconGap2 = attributes.iconGap2 || attributes.iconGap2 === 0 || attributes.iconGap2Tablet || attributes.iconGap2Mobile ? true : false
2323
return hasIconGap || ( hasIconSize && ! hasIconGap2 )
2424
},
2525
migrate: ( attributes, innerBlocks ) => {

src/components/advanced-autosuggest-control/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ class AdvancedAutosuggestControl extends Component {
223223
label={ this.props.label }
224224
screens={ this.props.screens }
225225
value={ this.props.value }
226+
defaultValue={ this.props?.defaultValue ?? '' }
226227
onChange={ value => { // Will be used to reset.
227-
if ( value === '' ) {
228-
this.onChange( null, { newValue: '' } )
228+
if ( value === '' || this.props?.defaultValue ) {
229+
this.onChange( null, { newValue: value } )
229230
}
230231
} }
231232
allowReset={ this.props.allowReset }

0 commit comments

Comments
 (0)