Skip to content

Commit

Permalink
The default option changes how we have to do the e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Jun 15, 2023
1 parent ce79f31 commit 286541f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 83 deletions.
3 changes: 1 addition & 2 deletions packages/block-editor/src/hooks/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function BehaviorsControl( {
];

// If every behavior is disabled, do not show the behaviors inspector control.
if ( options.length === 0 ) {
if ( behaviorsOptions.length === 0 ) {
return null;
}
// Block behaviors take precedence over theme behaviors.
Expand All @@ -89,7 +89,6 @@ function BehaviorsControl( {
<InspectorControls group="advanced">
<SelectControl
label={ __( 'Behaviors' ) }
// At the moment we are only supporting one behavior (Lightbox)
value={ value() }
options={ options }
onChange={ onChange }
Expand Down
81 changes: 0 additions & 81 deletions test/e2e/specs/editor/various/behaviors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,6 @@ test.describe( 'Testing behaviors functionality', () => {
await page.waitForLoadState();
} );

test( '`No Behaviors` should be the default as defined in the core theme.json', async ( {
admin,
editor,
requestUtils,
page,
behaviorUtils,
} ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
await admin.createNewPost();
const media = await behaviorUtils.createMedia();
await editor.insertBlock( {
name: 'core/image',
attributes: {
alt: filename,
id: media.id,
url: media.source_url,
},
} );

await editor.openDocumentSettingsSidebar();
const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );
await editorSettings
.getByRole( 'button', { name: 'Advanced' } )
.click();
const select = editorSettings.getByRole( 'combobox', {
name: 'Behavior',
} );

// By default, no behaviors should be selected.
await expect( select ).toHaveValue( '' );

// By default, you should be able to select the Lightbox behavior.
await expect( select.getByRole( 'option' ) ).toHaveCount( 3 );
} );

test( 'Behaviors UI can be disabled in the `theme.json`', async ( {
admin,
editor,
Expand Down Expand Up @@ -173,50 +136,6 @@ test.describe( 'Testing behaviors functionality', () => {
// lightbox even though the theme.json has it set to false.
} );

test( 'You can set the default value for the behaviors in the theme.json', async ( {
admin,
editor,
requestUtils,
page,
behaviorUtils,
} ) => {
// In this theme, the default value for settings.behaviors.blocks.core/image.lightbox is `true`.
await requestUtils.activateTheme( 'behaviors-enabled' );
await admin.createNewPost();
const media = await behaviorUtils.createMedia();

await editor.insertBlock( {
name: 'core/image',
attributes: {
alt: filename,
id: media.id,
url: media.source_url,
},
} );

await editor.openDocumentSettingsSidebar();
const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );
await editorSettings
.getByRole( 'button', { name: 'Advanced' } )
.click();
const select = editorSettings.getByRole( 'combobox', {
name: 'Behavior',
} );

// The behaviors dropdown should be present and the value should be set to
// `lightbox`.
await expect( select ).toHaveValue( 'lightbox' );

// There should be 2 options available: `No behaviors` and `Lightbox`.
await expect( select.getByRole( 'option' ) ).toHaveCount( 3 );

// We can change the value of the behaviors dropdown to `No behaviors`.
await select.selectOption( { label: 'No behaviors' } );
await expect( select ).toHaveValue( '' );
} );

test( 'Lightbox behavior is disabled if the Image has a link', async ( {
admin,
editor,
Expand Down

0 comments on commit 286541f

Please sign in to comment.