|
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,20 @@ 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( |
| 348 | + '>=14.2.10 <15.0.0 || >=15.0.0-canary.147', |
| 349 | + ) |
343 | 350 | expect(headers['netlify-cdn-cache-control']).toBe(
|
344 |
| - 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 351 | + (shouldHavePrivateDirective ? 'private, ' : '') + |
| 352 | + 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 353 | + ) |
| 354 | + expect(headers['cache-control']).toBe( |
| 355 | + (shouldHavePrivateDirective ? 'private,' : '') + |
| 356 | + 'no-cache,no-store,max-age=0,must-revalidate', |
345 | 357 | )
|
346 |
| - expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') |
347 | 358 | })
|
348 | 359 |
|
349 | 360 | test('should serve 404 page when requesting non existing page (marked with notFound: true in getStaticProps)', async ({
|
@@ -1039,10 +1050,19 @@ test.describe('Page Router with basePath and i18n', () => {
|
1039 | 1050 |
|
1040 | 1051 | expect(await page.textContent('h1')).toBe('404')
|
1041 | 1052 |
|
| 1053 | + // https://github.com/vercel/next.js/pull/69802 made changes to returned cache-control header, |
| 1054 | + // after that 404 pages would have `private` directive, before that it would not |
| 1055 | + const shouldHavePrivateDirective = nextVersionSatisfies( |
| 1056 | + '>=14.2.10 <15.0.0 || >=15.0.0-canary.147', |
| 1057 | + ) |
1042 | 1058 | expect(headers['netlify-cdn-cache-control']).toBe(
|
1043 |
| - 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 1059 | + (shouldHavePrivateDirective ? 'private, ' : '') + |
| 1060 | + 'no-cache, no-store, max-age=0, must-revalidate, durable', |
| 1061 | + ) |
| 1062 | + expect(headers['cache-control']).toBe( |
| 1063 | + (shouldHavePrivateDirective ? 'private,' : '') + |
| 1064 | + 'no-cache,no-store,max-age=0,must-revalidate', |
1044 | 1065 | )
|
1045 |
| - expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') |
1046 | 1066 | })
|
1047 | 1067 |
|
1048 | 1068 | 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