Skip to content

Commit cb33217

Browse files
committed
Move Page List tests to dedicated non Navigation spec
1 parent c9fb812 commit cb33217

File tree

2 files changed

+90
-80
lines changed

2 files changed

+90
-80
lines changed

test/e2e/specs/editor/blocks/navigation.spec.js

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,86 +1616,6 @@ test.describe( 'Navigation block', () => {
16161616
await expect( linkInput ).toBeEnabled();
16171617
} );
16181618
} );
1619-
1620-
test( 'Page List renders HTML formatting and entities in page titles', async ( {
1621-
editor,
1622-
admin,
1623-
requestUtils,
1624-
} ) => {
1625-
// Create a page with both HTML formatting and entities in the title
1626-
await requestUtils.createPage( {
1627-
title: '<strong>Bold &"qwerty"—</strong>',
1628-
status: 'publish',
1629-
} );
1630-
1631-
// Insert Navigation block
1632-
await admin.createNewPost();
1633-
await editor.insertBlock( { name: 'core/navigation' } );
1634-
1635-
// Wait for Page List block to be visible
1636-
const pageListBlock = editor.canvas.getByRole( 'document', {
1637-
name: 'Block: Page List',
1638-
} );
1639-
1640-
await expect( pageListBlock ).toBeVisible( {
1641-
// Wait for the Nav and Page List block API requests to resolve.
1642-
timeout: 10000,
1643-
} );
1644-
1645-
// Locate the page list item
1646-
const pageItems = pageListBlock.locator( 'li' );
1647-
1648-
// Wait for Page List to load pages
1649-
await pageItems.first().waitFor( { state: 'visible' } );
1650-
1651-
// Find the link element - try to find by text content
1652-
const links = pageListBlock.locator( 'a' );
1653-
const linkCount = await links.count();
1654-
expect( linkCount ).toBeGreaterThan( 0 );
1655-
1656-
// Find the link that contains our test page title
1657-
let link = null;
1658-
for ( let i = 0; i < linkCount; i++ ) {
1659-
const currentLink = links.nth( i );
1660-
const text = await currentLink.textContent();
1661-
if (
1662-
text &&
1663-
( text.includes( 'qwerty' ) || text.includes( 'Bold' ) )
1664-
) {
1665-
link = currentLink;
1666-
break;
1667-
}
1668-
}
1669-
1670-
expect( link ).not.toBeNull();
1671-
await expect( link ).toBeVisible();
1672-
1673-
// Verify text content shows decoded text (not raw HTML or entity codes)
1674-
const textContent = await link.textContent();
1675-
expect( textContent ).toContain( 'Bold' );
1676-
expect( textContent ).toContain( 'qwerty' );
1677-
// Verify HTML tags are not shown as raw markup
1678-
expect( textContent ).not.toContain( '<strong>' );
1679-
expect( textContent ).not.toContain( '</strong>' );
1680-
// Verify entity codes are not shown as raw codes
1681-
expect( textContent ).not.toContain( '&amp;' );
1682-
expect( textContent ).not.toContain( '&quot;' );
1683-
expect( textContent ).not.toContain( '&mdash;' );
1684-
1685-
// Verify HTML is rendered (check for strong tag)
1686-
const strongElement = link.locator( 'css=strong' );
1687-
await expect( strongElement ).toBeVisible();
1688-
await expect( strongElement ).toContainText( 'Bold' );
1689-
await expect( strongElement ).toContainText( 'qwerty' );
1690-
1691-
// Verify innerHTML contains the strong tag (not escaped)
1692-
const innerHTML = await link.innerHTML();
1693-
expect( innerHTML ).toContain( '<strong>' );
1694-
expect( innerHTML ).toContain( '</strong>' );
1695-
// Ensure it's not showing raw HTML as text
1696-
expect( innerHTML ).not.toContain( '&lt;strong&gt;' );
1697-
expect( innerHTML ).not.toContain( '&lt;/strong&gt;' );
1698-
} );
16991619
} );
17001620
} );
17011621

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
5+
6+
test.describe( 'Page List block', () => {
7+
test.afterEach( async ( { requestUtils } ) => {
8+
await requestUtils.deleteAllPages();
9+
} );
10+
11+
test( 'renders HTML formatting and entities in page titles', async ( {
12+
editor,
13+
admin,
14+
requestUtils,
15+
} ) => {
16+
// Create a page with both HTML formatting and entities in the title
17+
await requestUtils.createPage( {
18+
title: '<strong>Bold &"qwerty"—</strong>',
19+
status: 'publish',
20+
} );
21+
22+
// Insert Page List block directly
23+
await admin.createNewPost();
24+
await editor.insertBlock( { name: 'core/page-list' } );
25+
26+
// Wait for Page List block to be visible
27+
const pageListBlock = editor.canvas.getByRole( 'document', {
28+
name: 'Block: Page List',
29+
} );
30+
31+
await expect( pageListBlock ).toBeVisible( {
32+
// Wait for the Page List block API request to resolve.
33+
timeout: 10000,
34+
} );
35+
36+
// Locate the page list item
37+
const pageItems = pageListBlock.locator( 'li' );
38+
39+
// Wait for Page List to load pages
40+
await pageItems.first().waitFor( { state: 'visible' } );
41+
42+
// Find the link element - try to find by text content
43+
const links = pageListBlock.locator( 'a' );
44+
const linkCount = await links.count();
45+
expect( linkCount ).toBeGreaterThan( 0 );
46+
47+
// Find the link that contains our test page title
48+
let link = null;
49+
for ( let i = 0; i < linkCount; i++ ) {
50+
const currentLink = links.nth( i );
51+
const text = await currentLink.textContent();
52+
if (
53+
text &&
54+
( text.includes( 'qwerty' ) || text.includes( 'Bold' ) )
55+
) {
56+
link = currentLink;
57+
break;
58+
}
59+
}
60+
61+
expect( link ).not.toBeNull();
62+
await expect( link ).toBeVisible();
63+
64+
// Verify text content shows decoded text (not raw HTML or entity codes)
65+
const textContent = await link.textContent();
66+
expect( textContent ).toContain( 'Bold' );
67+
expect( textContent ).toContain( 'qwerty' );
68+
// Verify HTML tags are not shown as raw markup
69+
expect( textContent ).not.toContain( '<strong>' );
70+
expect( textContent ).not.toContain( '</strong>' );
71+
// Verify entity codes are not shown as raw codes
72+
expect( textContent ).not.toContain( '&amp;' );
73+
expect( textContent ).not.toContain( '&quot;' );
74+
expect( textContent ).not.toContain( '&mdash;' );
75+
76+
// Verify HTML is rendered (check for strong tag)
77+
const strongElement = link.locator( 'css=strong' );
78+
await expect( strongElement ).toBeVisible();
79+
await expect( strongElement ).toContainText( 'Bold' );
80+
await expect( strongElement ).toContainText( 'qwerty' );
81+
82+
// Verify innerHTML contains the strong tag (not escaped)
83+
const innerHTML = await link.innerHTML();
84+
expect( innerHTML ).toContain( '<strong>' );
85+
expect( innerHTML ).toContain( '</strong>' );
86+
// Ensure it's not showing raw HTML as text
87+
expect( innerHTML ).not.toContain( '&lt;strong&gt;' );
88+
expect( innerHTML ).not.toContain( '&lt;/strong&gt;' );
89+
} );
90+
} );

0 commit comments

Comments
 (0)