feat(seo): return a real 404 status for unmatched routes

This commit is contained in:
2026-08-02 10:23:07 +02:00
parent b2636e20cf
commit c07663aa7b
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -17,6 +17,8 @@ beforeAll(async () => {
frontendDist = await fs.mkdtemp(path.join(os.tmpdir(), 'converter-dist-'));
await fs.mkdir(path.join(frontendDist, 'fr'), { recursive: true });
await fs.mkdir(path.join(frontendDist, 'assets'), { recursive: true });
await fs.mkdir(path.join(frontendDist, '404'), { recursive: true });
await fs.writeFile(path.join(frontendDist, '404', 'index.html'), '<html><body>not found</body></html>');
await fs.writeFile(
path.join(frontendDist, 'fr', 'index.html'),
`<html><body>fr home ${'x'.repeat(2000)}</body></html>`
@@ -77,3 +79,17 @@ describe('static asset serving', () => {
expect(response.headers['content-encoding']).toBe('gzip');
});
});
describe('404 handling', () => {
it('returns a real 404 status for an unknown path', async () => {
const response = await request(app).get('/this-page-does-not-exist/');
expect(response.status).toBe(404);
expect(response.text).toContain('not found');
});
it('still serves a known route with 200', async () => {
const response = await request(app).get('/fr/');
expect(response.status).toBe(200);
expect(response.text).toContain('fr home');
});
});