From 7452701b8eafb2fce7c28124e5b7645d8bc2f78b Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Tue, 19 May 2020 10:28:59 -0700 Subject: [PATCH] e2e-test: Fix dirty state e2e test (#22448) 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. --- .../experiments/multi-entity-editing.test.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/e2e-tests/specs/experiments/multi-entity-editing.test.js b/packages/e2e-tests/specs/experiments/multi-entity-editing.test.js index 39a71c6183a7e..63e09b2d826e0 100644 --- a/packages/e2e-tests/specs/experiments/multi-entity-editing.test.js +++ b/packages/e2e-tests/specs/experiments/multi-entity-editing.test.js @@ -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 ) { @@ -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' );