feat(seo): redirect / to /fr/ or /en/ server-side based on Accept-Language
This commit is contained in:
@@ -39,6 +39,26 @@ afterAll(async () => {
|
||||
await fs.rm(frontendDist, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe('root redirect', () => {
|
||||
it('redirects to /en/ when Accept-Language prefers English', async () => {
|
||||
const response = await request(app).get('/').set('Accept-Language', 'en-US,en;q=0.9');
|
||||
expect(response.status).toBe(301);
|
||||
expect(response.headers.location).toBe('/en/');
|
||||
});
|
||||
|
||||
it('redirects to /fr/ when Accept-Language prefers French', async () => {
|
||||
const response = await request(app).get('/').set('Accept-Language', 'fr-FR,fr;q=0.9,en;q=0.5');
|
||||
expect(response.status).toBe(301);
|
||||
expect(response.headers.location).toBe('/fr/');
|
||||
});
|
||||
|
||||
it('defaults to /fr/ when Accept-Language is absent', async () => {
|
||||
const response = await request(app).get('/');
|
||||
expect(response.status).toBe(301);
|
||||
expect(response.headers.location).toBe('/fr/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('static asset serving', () => {
|
||||
it('sends HTML pages with Cache-Control: no-cache', async () => {
|
||||
const response = await request(app).get('/fr/');
|
||||
|
||||
Reference in New Issue
Block a user