Skip to content

Commit

Permalink
Add test coverage for HTML chars on Draft Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed May 20, 2022
1 parent d29de3e commit 8703fa2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,58 @@ describe( 'Navigation', () => {
);
} );

it( 'correctly decodes special characters in the created Page title for display', 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
// Insert name for the new page.
const pageTitle = 'This & That & Some < other > chars';
const input = await page.waitForSelector(
'input.block-editor-url-input__input:focus'
);
await input.type( pageTitle );

// When creating a page, the URLControl makes a request to the
// url-details endpoint to fetch information about the page.
// Because the draft is inaccessible publicly, this request
// returns a 404 response. Wait for the response and expect
// the error to have occurred.
const createPageButton = await page.waitForSelector(
'.block-editor-link-control__search-create'
);
const responsePromise = page.waitForResponse(
( response ) =>
response.url().includes( 'url-details' ) &&
response.status() === 404
);
const createPagePromise = createPageButton.click();
await Promise.all( [ responsePromise, createPagePromise ] );

await waitForBlock( 'Navigation' );

const innerLinkBlock = await waitForBlock( 'Custom Link' );

const linkText = await innerLinkBlock.$eval(
'[aria-label="Navigation link text"]',
( element ) => {
return element.innerText;
}
);

expect( linkText ).toContain( pageTitle );

expect( console ).toHaveErroredWith(
'Failed to load resource: the server responded with a status of 404 (Not Found)'
);
} );

it( 'renders buttons for the submenu opener elements when the block is set to open on click instead of hover', async () => {
await createClassicMenu( { name: 'Test Menu 2' }, menuItemsFixture );
await createNewPost();
Expand Down

0 comments on commit 8703fa2

Please sign in to comment.