Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky navigation editor test by waiting for required elements #34767

Merged
merged 1 commit into from
Sep 13, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,23 @@ describe( 'Navigation editor', () => {
} );

it( 'shows the trailing block appender within the navigation block when no blocks are selected', async () => {
// The test requires the presence of existing menus.
await setUpResponseMocking( [
...getMenuMocks( { GET: assignMockMenuIds( menusFixture ) } ),
...getMenuItemMocks( { GET: menuItemsFixture } ),
] );
await visitNavigationEditor();

// Wait for at least one block to be present on the page.
await page.waitForSelector( '.wp-block' );

// And for this test to be valid, no blocks should be selected, which
// should be the case when the editor loads.
const selectedBlocks = await page.$$( '.wp-block.is-selected' );
expect( selectedBlocks.length ).toBe( 0 );

const blockListAppender = await page.$(
// And when no blocks are selected, the trailing appender is present.
const blockListAppender = await page.waitForSelector(
'.block-list-appender button[aria-label="Add block"]'
);
expect( blockListAppender ).toBeTruthy();
Expand Down