Skip to content

Commit 85cb5d5

Browse files
authored
test: adjust page-router i18n tests for next 13 (#3107)
1 parent 9d94cfd commit 85cb5d5

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

tests/e2e/page-router.test.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,10 @@ test.describe('Page Router with basePath and i18n', () => {
13921392

13931393
expect(await page.textContent('p')).toBe('Custom 404 page for locale: en')
13941394

1395-
// https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header,
1396-
// after that 404 pages would have `private` directive, before that it would not
1397-
const shouldHavePrivateDirective = nextVersionSatisfies('^14.2.10 || >=15.0.0-canary.147')
1398-
expect(headers['debug-netlify-cdn-cache-control']).toBe(
1399-
(shouldHavePrivateDirective ? 'private, ' : '') +
1400-
'no-cache, no-store, max-age=0, must-revalidate, durable',
1401-
)
1402-
expect(headers['cache-control']).toBe(
1403-
(shouldHavePrivateDirective ? 'private,' : '') +
1404-
'no-cache,no-store,max-age=0,must-revalidate',
1395+
expect(headers['debug-netlify-cdn-cache-control']).toMatch(
1396+
/no-cache, no-store, max-age=0, must-revalidate, durable/m,
14051397
)
1398+
expect(headers['cache-control']).toMatch(/no-cache,no-store,max-age=0,must-revalidate/m)
14061399
})
14071400

14081401
test('requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)', async ({
@@ -1417,12 +1410,16 @@ test.describe('Page Router with basePath and i18n', () => {
14171410

14181411
expect(await page.textContent('p')).toBe('Custom 404 page for locale: en')
14191412

1420-
expect(headers['debug-netlify-cdn-cache-control']).toBe(
1421-
nextVersionSatisfies('>=15.0.0-canary.187')
1422-
? 's-maxage=31536000, durable'
1423-
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
1424-
)
1425-
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
1413+
// Prior to v14.2.4 notFound pages are not cacheable
1414+
// https://github.com/vercel/next.js/pull/66674
1415+
if (nextVersionSatisfies('>= 14.2.4')) {
1416+
expect(headers['debug-netlify-cdn-cache-control']).toBe(
1417+
nextVersionSatisfies('>=15.0.0-canary.187')
1418+
? 's-maxage=31536000, durable'
1419+
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
1420+
)
1421+
expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate')
1422+
}
14261423
})
14271424

14281425
test.describe('static assets and function invocations', () => {

0 commit comments

Comments
 (0)