Skip to content

Commit

Permalink
Merge pull request #1883 from dscho/404-page
Browse files Browse the repository at this point in the history
playwright: verify that the 404 page is styled
  • Loading branch information
ttaylorr authored Sep 26, 2024
2 parents 8494c7f + 63b2080 commit e635a81
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 2 additions & 3 deletions script/serve-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ const handler = (request, response) => {
fileStream.pipe(response);
} catch(e) {
console.log(`Could not read ${filename}`);
response.writeHead(404, {'Content-Type': 'text/plain'});
response.write('404 Not Found\n');
response.end();
response.writeHead(404, {'Content-Type': 'text/html'});
fs.createReadStream(path.join(basePath, '404.html')).pipe(response);
return;
}
};
Expand Down
15 changes: 15 additions & 0 deletions tests/git-scm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,18 @@ test('book', async ({ page }) => {
}
await expect(page.getByRole('document')).toHaveText(/Snapshotlar, Fərqlər Yox/)
})

test('404', async ({ page }) => {
await page.goto(`${url}does-not.exist`)

await expect(page.locator('.inner h1')).toHaveText(`That page doesn't exist.`)

// the 404 page should be styled
await expect(page.locator('link[rel="stylesheet"]')).toHaveAttribute('href', /application(\.min)?\.css$/)

// the search box is shown
await expect(page.locator('#search-text')).toBeVisible()

// the usual navbar is shown
await expect(page.getByRole('link', { name: 'Community' })).toBeVisible()
})

0 comments on commit e635a81

Please sign in to comment.