Skip to content

Commit 63b2080

Browse files
committed
playwright: verify that the 404 page is styled
The 404 page is not only a place to tell the user that what they were looking for cannot be found, but also to guide them to what _can_ be found, including the search box and the navigation box. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7f4e3a3 commit 63b2080

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

script/serve-public.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ const handler = (request, response) => {
4141
fileStream.pipe(response);
4242
} catch(e) {
4343
console.log(`Could not read ${filename}`);
44-
response.writeHead(404, {'Content-Type': 'text/plain'});
45-
response.write('404 Not Found\n');
46-
response.end();
44+
response.writeHead(404, {'Content-Type': 'text/html'});
45+
fs.createReadStream(path.join(basePath, '404.html')).pipe(response);
4746
return;
4847
}
4948
};

tests/git-scm.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,18 @@ test('book', async ({ page }) => {
230230
}
231231
await expect(page.getByRole('document')).toHaveText(/Snapshotlar, Fərqlər Yox/)
232232
})
233+
234+
test('404', async ({ page }) => {
235+
await page.goto(`${url}does-not.exist`)
236+
237+
await expect(page.locator('.inner h1')).toHaveText(`That page doesn't exist.`)
238+
239+
// the 404 page should be styled
240+
await expect(page.locator('link[rel="stylesheet"]')).toHaveAttribute('href', /application(\.min)?\.css$/)
241+
242+
// the search box is shown
243+
await expect(page.locator('#search-text')).toBeVisible()
244+
245+
// the usual navbar is shown
246+
await expect(page.getByRole('link', { name: 'Community' })).toBeVisible()
247+
})

0 commit comments

Comments
 (0)