Skip to content

Commit

Permalink
Fix flaky Navigation block e2e test by mocking out URL details endpoi…
Browse files Browse the repository at this point in the history
…nt to avoid 404 (#37501)
  • Loading branch information
getdave authored Dec 17, 2021
1 parent eb25c6c commit a26dc17
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,19 @@ describe( 'Navigation', () => {
} );

it( 'allows pages to be created from the navigation block and their links added to menu', async () => {
// The URL Details endpoint 404s for the created page, since it will
// be a draft that is inaccessible publicly. To avoid this we mock
// out the endpoint response to be empty which will be handled gracefully
// in the UI whilst avoiding any 404s.
await setUpResponseMocking( [
{
match: ( request ) =>
request.url().includes( `rest_route` ) &&
request.url().includes( `url-details` ),
onRequestMatch: createJSONResponse( [] ),
},
] );

await createNewPost();
await insertBlock( 'Navigation' );
const startEmptyButton = await page.waitForXPath( START_EMPTY_XPATH );
Expand Down Expand Up @@ -469,12 +482,6 @@ describe( 'Navigation', () => {
`//a[contains(@class, "block-editor-link-control__search-item-title") and contains(., "${ pageTitle }")]`
);

// The URL Details endpoint 404s for the created page, since it will
// be a draft that is inaccessible publicly. Wait for the HTTP request
// to finish, since this seems to make the test more stable.
await page.waitForNetworkIdle();
expect( console ).toHaveErrored();

await publishPost();

// Expect a Navigation Block with a link for "A really long page name that will not exist".
Expand Down

0 comments on commit a26dc17

Please sign in to comment.