Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export default {
label={ __( 'Wrapping' ) }
hasValue={ hasWrapValue }
onDeselect={ resetWrap }
isShownByDefault
panelId={ clientId }
>
<FlexWrapControl
Expand Down
38 changes: 33 additions & 5 deletions packages/block-editor/src/layouts/test/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
* WordPress dependencies
Expand Down Expand Up @@ -47,36 +48,63 @@ describe( 'getLayoutStyle', () => {
} );

describe( 'FlexLayoutInspectorControls', () => {
it( 'should render the wrap toggle by default', () => {
it( 'should not render the wrap toggle by default', () => {
renderInspectorControls();

expect(
screen.queryByRole( 'checkbox', {
name: 'Allow to wrap to multiple lines',
} )
).not.toBeInTheDocument();
} );

it( 'should render the wrap toggle when it has a value', () => {
renderInspectorControls( {
layout: { flexWrap: 'nowrap' },
} );

expect(
screen.getByRole( 'checkbox', {
name: 'Allow to wrap to multiple lines',
} )
).toBeInTheDocument();
} );

it( 'should render the wrap toggle when allowWrap is true', () => {
it( 'should allow the wrap toggle to be selected from the tools panel menu', async () => {
const user = userEvent.setup();
renderInspectorControls( {
layoutBlockSupport: { allowWrap: true },
} );

await user.click(
screen.getByRole( 'button', { name: /Layout options/i } )
);
await user.click(
screen.getByRole( 'menuitemcheckbox', {
name: 'Show Wrapping',
} )
);

expect(
screen.getByRole( 'checkbox', {
name: 'Allow to wrap to multiple lines',
} )
).toBeInTheDocument();
} );

it( 'should not render the wrap toggle when allowWrap is false', () => {
it( 'should not include the wrap toggle in the tools panel menu when allowWrap is false', async () => {
const user = userEvent.setup();
renderInspectorControls( {
layoutBlockSupport: { allowWrap: false },
} );

await user.click(
screen.getByRole( 'button', { name: /Layout options/i } )
);

expect(
screen.queryByRole( 'checkbox', {
name: 'Allow to wrap to multiple lines',
screen.queryByRole( 'menuitemcheckbox', {
name: 'Show Wrapping',
} )
).not.toBeInTheDocument();
} );
Expand Down
Loading