Skip to content

Commit

Permalink
e2e-test: Fix dirty state e2e test (#22448)
Browse files Browse the repository at this point in the history
In #22140, a change was made to the inserter to insert the block at the current selection. Since the e2e test had selected test inside a nested template part, the block was being inserted there, though it was supposed to be inserted at the end of the document. Before that PR, the behavior was to insert it at the end of the document, and not at the current selection.

The fix is to select the document in the block breadcrumb before adding the block. This clears any selection so that adding the block block dirties the root entity and not a nested entity.
  • Loading branch information
noahtallen committed May 19, 2020
1 parent 2b41fbc commit 7452701
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/e2e-tests/specs/experiments/multi-entity-editing.test.js
Expand Up @@ -127,6 +127,13 @@ const openEntitySavePanel = async () => {
return true;
};

const clickBreadcrumbItem = async ( item ) => {
const [ breadcrumbItem ] = await page.$x(
`//button[contains(@class, "block-editor-block-breadcrumb__button")][contains(text(), "${ item }")]`
);
await breadcrumbItem.click();
};

const isEntityDirty = async ( name ) => {
const isOpen = await openEntitySavePanel();
if ( ! isOpen ) {
Expand Down Expand Up @@ -226,9 +233,11 @@ describe( 'Multi-entity editor states', () => {
removeErrorMocks();
} );

// Todo: Solve issue affecting test
// eslint-disable-next-line jest/no-disabled-tests
it.skip( 'should only dirty the parent entity when editing the parent', async () => {
it( 'should only dirty the parent entity when editing the parent', async () => {
// Clear selection so that the block is not added to the template part.
await clickBreadcrumbItem( 'Document' );

// Add paragraph block to the end of the document.
await page.click( '.block-editor-button-block-appender' );
await page.waitForSelector( '.block-editor-inserter__menu' );
await page.click( 'button.editor-block-list-item-paragraph' );
Expand Down

0 comments on commit 7452701

Please sign in to comment.