Skip to content

Commit

Permalink
Lightbox UI appearing with interactivity experiment disabled (#51025)
Browse files Browse the repository at this point in the history
* Fix lightbox ui appearing with interactivity experiment disabled

* Update e2e tests to enable the experiment
  • Loading branch information
cbravobernal authored May 29, 2023
1 parent 9a686da commit 226df91
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ function gutenberg_enable_experiments() {
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-pattern-enhancements', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnablePatternEnhancements = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-interactivity-api-core-blocks', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalInteractivityAPI = true', 'before' );
}

}

Expand Down
13 changes: 7 additions & 6 deletions packages/block-editor/src/hooks/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
const settings =
select( blockEditorStore ).getSettings()?.__experimentalFeatures
?.blocks?.[ props.name ]?.behaviors;

if (
! settings ||
// If every behavior is disabled, do not show the behaviors inspector control.
Expand Down Expand Up @@ -102,8 +101,10 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
};
}, 'withBehaviors' );

addFilter(
'editor.BlockEdit',
'core/behaviors/with-inspector-control',
withBehaviors
);
if ( window?.__experimentalInteractivityAPI ) {
addFilter(
'editor.BlockEdit',
'core/behaviors/with-inspector-control',
withBehaviors
);
}
25 changes: 24 additions & 1 deletion test/e2e/specs/editor/various/behaviors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,32 @@ test.describe( 'Testing behaviors functionality', () => {
await requestUtils.activateTheme( 'twentytwentyone' );
await requestUtils.deleteAllPosts();
} );
test.beforeEach( async ( { admin, page, requestUtils } ) => {
await requestUtils.deleteAllMedia();
await admin.visitAdminPage(
'/admin.php',
'page=gutenberg-experiments'
);

await page
.locator( `#gutenberg-interactivity-api-core-blocks` )
.setChecked( true );
await page.locator( `input[name="submit"]` ).click();
await page.waitForLoadState();
} );

test.afterEach( async ( { requestUtils } ) => {
test.afterEach( async ( { admin, page, requestUtils } ) => {
await requestUtils.deleteAllMedia();
await admin.visitAdminPage(
'/admin.php',
'page=gutenberg-experiments'
);

await page
.locator( `#gutenberg-interactivity-api-core-blocks` )
.setChecked( false );
await page.locator( `input[name="submit"]` ).click();
await page.waitForLoadState();
} );

test( '`No Behaviors` should be the default as defined in the core theme.json', async ( {
Expand Down

1 comment on commit 226df91

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 226df91.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5110187639
📝 Reported issues:

Please sign in to comment.