|
1 | 1 | import { expect } from '@playwright/test'
|
2 | 2 | import { test } from '../utils/playwright-helpers.js'
|
| 3 | +import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' |
3 | 4 |
|
4 | 5 | export function waitFor(millis: number) {
|
5 | 6 | return new Promise((resolve) => setTimeout(resolve, millis))
|
@@ -340,10 +341,18 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
|
340 | 341 |
|
341 | 342 | expect(await page.textContent('h1')).toBe('404')
|
342 | 343 |
|
| 344 | + // https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header, |
| 345 | + // after that (14.2.10 and canary.147) 404 pages would have `private` directive, before that |
| 346 | + // it would not |
| 347 | + const shouldHavePrivateDirective = nextVersionSatisfies('^14.2.10 || >=15.0.0-canary.147') |
343 | 348 | expect(headers['netlify-cdn-cache-control']).toBe(
|
344 |
| - 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 349 | + (shouldHavePrivateDirective ? 'private, ' : '') + |
| 350 | + 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 351 | + ) |
| 352 | + expect(headers['cache-control']).toBe( |
| 353 | + (shouldHavePrivateDirective ? 'private,' : '') + |
| 354 | + 'no-cache,no-store,max-age=0,must-revalidate', |
345 | 355 | )
|
346 |
| - expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') |
347 | 356 | })
|
348 | 357 |
|
349 | 358 | test('should serve 404 page when requesting non existing page (marked with notFound: true in getStaticProps)', async ({
|
@@ -1039,10 +1048,17 @@ test.describe('Page Router with basePath and i18n', () => {
|
1039 | 1048 |
|
1040 | 1049 | expect(await page.textContent('h1')).toBe('404')
|
1041 | 1050 |
|
| 1051 | + // https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header, |
| 1052 | + // after that 404 pages would have `private` directive, before that it would not |
| 1053 | + const shouldHavePrivateDirective = nextVersionSatisfies('^14.2.10 || >=15.0.0-canary.147') |
1042 | 1054 | expect(headers['netlify-cdn-cache-control']).toBe(
|
1043 |
| - 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 1055 | + (shouldHavePrivateDirective ? 'private, ' : '') + |
| 1056 | + 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 1057 | + ) |
| 1058 | + expect(headers['cache-control']).toBe( |
| 1059 | + (shouldHavePrivateDirective ? 'private,' : '') + |
| 1060 | + 'no-cache,no-store,max-age=0,must-revalidate', |
1044 | 1061 | )
|
1045 |
| - expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') |
1046 | 1062 | })
|
1047 | 1063 |
|
1048 | 1064 | test('requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)', async ({
|
|
0 commit comments