@@ -10,14 +10,16 @@ const mountAtPath = async (
1010) => {
1111 return await mount (
1212 < MemoryRouter initialEntries = { [ path ] } >
13- < Routes >
14- < Route path = "/posts/:slug" element = { < Post baseDir = { baseDir } /> } />
15- </ Routes >
13+ < main >
14+ < Routes >
15+ < Route path = "/posts/:slug" element = { < Post baseDir = { baseDir } /> } />
16+ </ Routes >
17+ </ main >
1618 </ MemoryRouter > ,
1719 )
1820}
1921
20- test ( 'renders existing markdown post' , async ( { mount } ) => {
22+ test ( 'renders header and existing markdown post' , async ( { mount } ) => {
2123 const component = await mountAtPath ( mount , '/posts/yo' , 'posts' )
2224
2325 await expect ( component . getByRole ( 'heading' , { name : 'Hey' } ) ) . toBeVisible ( )
@@ -79,10 +81,11 @@ test('handles markdown with potentially malicious HTML content', async ({ mount
7981 await expect ( component . getByRole ( 'heading' , { name : 'Safe Heading' } ) ) . toBeVisible ( )
8082
8183 // Verify that HTML tags (script, img) are stripped by remark
82- // The HTML elements should not be present in the rendered output
83- // We verify by checking no script or img roles/elements exist
84- const scriptCount = await component . locator ( 'script' ) . count ( )
85- const imgCount = await component . locator ( 'img' ) . count ( )
84+ // The HTML elements should not be present in the rendered article content
85+ // We verify by checking no script or img elements exist in the article
86+ const article = component . locator ( 'article' )
87+ const scriptCount = await article . locator ( 'script' ) . count ( )
88+ const imgCount = await article . locator ( 'img' ) . count ( )
8689 expect ( scriptCount ) . toBe ( 0 )
8790 expect ( imgCount ) . toBe ( 0 )
8891} )
0 commit comments