Skip to content

Commit

Permalink
Fix and enable page creation test
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Dec 16, 2021
1 parent 04ecac4 commit 1ca2d28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ exports[`Navigation allows an empty navigation block to be created and manually
<!-- wp:navigation-link {\\"label\\":\\"Contact\\",\\"type\\":\\"page\\",\\"id\\":[number],\\"url\\":\\"https://this/is/a/test/search/get-in-touch\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->"
`;

exports[`Navigation allows pages to be created from the navigation block and their links added to menu 1`] = `""`;

exports[`Navigation encodes URL when create block if needed 1`] = `
"<!-- wp:navigation-link {\\"label\\":\\"wordpress.org/шеллы\\",\\"url\\":\\"https://wordpress.org/%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
Expand Down
37 changes: 17 additions & 20 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,50 +441,47 @@ describe( 'Navigation', () => {
expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
} );

// URL details endpoint is throwing a 404, which causes this test to fail.
it.skip( 'allows pages to be created from the navigation block and their links added to menu', async () => {
it( 'allows pages to be created from the navigation block and their links added to menu', async () => {
await createNewPost();
await insertBlock( 'Navigation' );
const startEmptyButton = await page.waitForXPath( START_EMPTY_XPATH );
await startEmptyButton.click();

const appender = await page.waitForSelector(
'.wp-block-navigation .block-list-appender'
);
await appender.click();

// Wait for URL input to be focused
await page.waitForSelector(
'input.block-editor-url-input__input:focus'
);

// Insert name for the new page.
await page.type(
'input[placeholder="Search or type url"]',
'A really long page name that will not exist'
);

// Wait for URL input to be focused
await page.waitForSelector(
const pageTitle = 'A really long page name that will not exist';
const input = await page.waitForSelector(
'input.block-editor-url-input__input:focus'
);
await input.type( pageTitle );

// Wait for the create button to appear and click it.
await page.waitForSelector(
'.block-editor-link-control__search-create'
);

const createPageButton = await page.$(
const createPageButton = await page.waitForSelector(
'.block-editor-link-control__search-create'
);

await createPageButton.click();

const draftLink = await page.waitForSelector(
'.wp-block-navigation-item__content'
);
await draftLink.click();

// Creating a draft is async, so wait for a sign of completion. In this
// case the link that shows in the URL popover once a link is added.
await page.waitForXPath(
`//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();

// Expect a Navigation Block with a link for "A really long page name that will not exist".
expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
} );
Expand Down

0 comments on commit 1ca2d28

Please sign in to comment.