Skip to content

Commit

Permalink
Test assert uncontrolled blocks are always respected
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Jul 26, 2022
1 parent eb0280e commit ff5669f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,51 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
expect( linkText ).toBe( 'WordPress' );
} );

it( 'does not automatically use the first Navigation Menu if uncontrolled inner blocks are present', async () => {
const pageTitle = 'A Test Page';

await createNavigationMenu( {
title: 'Example Navigation',
content:
'<!-- wp:navigation-link {"label":"First Nav Menu Item","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
} );

await rest( {
method: 'POST',
path: `/wp/v2/pages/`,
data: {
status: 'publish',
title: pageTitle,
content: 'Hello world',
},
} );

await createNewPost();

await clickOnMoreMenuItem( 'Code editor' );

const codeEditorInput = await page.waitForSelector(
'.editor-post-text-editor'
);
await codeEditorInput.click();

const markup =
'<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
await page.keyboard.type( markup );
await clickButton( 'Exit code editor' );

await waitForBlock( 'Navigation' );

const hasUncontrolledInnerBlocks = await page.evaluate( () => {
const blocks = wp.data
.select( 'core/block-editor' )
.getBlocks();
return !! blocks[ 0 ]?.innerBlocks?.length;
} );

expect( hasUncontrolledInnerBlocks ).toBe( true );
} );

it( 'does not automatically use first Navigation Menu if more than one exists', async () => {
await createNavigationMenu( {
title: 'Example Navigation',
Expand Down

0 comments on commit ff5669f

Please sign in to comment.