Skip to content

Commit dc1c7da

Browse files
committed
test: some cleanup in cypress test, extra assertion and some more comments
1 parent d4ea6e6 commit dc1c7da

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cypress/e2e/default/i18n.cy.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ describe('Localization', () => {
3737
})
3838

3939
it(`function handler doesn't produce locale when first language in 'Accept-Language' header is not matching any of locales`, () => {
40-
// make sure we don't use cached results
41-
cy.setCookie('__prerender_bypass', '1')
4240
cy.request({
4341
url: `/`,
4442
followRedirect: false,
@@ -49,11 +47,16 @@ describe('Localization', () => {
4947
// > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
5048
// while Next.js matches on every language: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
5149
'Accept-Language': 'jp, fr;q=0.9',
52-
Accept: '*/*',
50+
// make sure we don't use cached results
5351
cookie: '__prerender_bypass=1',
5452
},
5553
}).then((response) => {
56-
// we don't expect for function handler to return a redirect
54+
// make sure we didn't hit SSR handler - not ODB and nothing else handles this request
55+
// once platform starts supporting more languages in Accept-Language header - this test
56+
// will start failing because then we will get platform level redirect
57+
expect(response.headers['x-nf-render-mode']).to.eq('ssr')
58+
59+
// we don't expect for function handler to respond with a redirect
5760
// locale redirects should be handled by Netlify redirects
5861
// otherwise we could wrongly cache locale redirect generated by ODB
5962
expect(response.status).to.eq(200)

0 commit comments

Comments
 (0)