Skip to content

Commit

Permalink
adds a test that tries setting nesting to zero and checks no submenus…
Browse files Browse the repository at this point in the history
… can be inserted
  • Loading branch information
draganescu committed Apr 1, 2022
1 parent c1c4b1a commit 51a2a9a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,46 @@ describe( 'Navigation', () => {
newMenuButton.click();
}

it( 'respects the nesting level', async () => {
await createNewPost();

await insertBlock( 'Navigation' );

const navBlock = await waitForBlock( 'Navigation' );

// Create empty Navigation block with no items
const startEmptyButton = await page.waitForXPath(
START_EMPTY_XPATH
);
await startEmptyButton.click();

await populateNavWithOneItem();

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

let code = await codeEditorInput.evaluate( ( el ) => el.value );
code = code.replace( '} /-->', ',"maxNestingLevel":0} /-->' );
await codeEditorInput.evaluate(
( el, newCode ) => ( el.value = newCode ),
code
);
await clickButton( 'Exit code editor' );

const blockAppender = navBlock.$( '.block-list-appender' );

expect( blockAppender ).not.toBeNull();

// Check the Submenu block is no longer present.
const navSubmenuSelector =
'[aria-label="Editor content"][role="region"] [aria-label="Block: Submenu"]';
const submenuBlock = await page.$( navSubmenuSelector );

expect( submenuBlock ).toBeFalsy();
} );

it( 'does not retain uncontrolled inner blocks when creating a new entity', async () => {
await createNewPost();
await clickOnMoreMenuItem( 'Code editor' );
Expand Down

0 comments on commit 51a2a9a

Please sign in to comment.