Skip to content

Commit 03a90b3

Browse files
authored
test: loose some assertions for fallback: true e2e tests to allow non breaking next@canary changes (#2976)
1 parent a31456e commit 03a90b3

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

tests/e2e/page-router.test.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,15 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
157157

158158
const fallbackWasServed =
159159
useFallback && headers1['cache-status'].includes('"Next.js"; fwd=miss')
160-
expect(headers1['netlify-cache-tag']).toBe(
161-
fallbackWasServed ? undefined : `_n_t_${encodeURI(pagePath).toLowerCase()}`,
162-
)
160+
if (!fallbackWasServed) {
161+
expect(headers1['netlify-cache-tag']).toBe(`_n_t_${encodeURI(pagePath).toLowerCase()}`)
162+
}
163163
expect(headers1['netlify-cdn-cache-control']).toBe(
164164
fallbackWasServed
165-
? undefined
165+
? // fallback should not be cached
166+
nextVersionSatisfies('>=15.4.0-canary.95')
167+
? `private, no-cache, no-store, max-age=0, must-revalidate, durable`
168+
: undefined
166169
: nextVersionSatisfies('>=15.0.0-canary.187')
167170
? 's-maxage=31536000, durable'
168171
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
@@ -722,14 +725,17 @@ test.describe('Page Router with basePath and i18n', () => {
722725
const fallbackWasServedImplicitLocale =
723726
useFallback && headers1ImplicitLocale['cache-status'].includes('"Next.js"; fwd=miss')
724727

725-
expect(headers1ImplicitLocale['netlify-cache-tag']).toBe(
726-
fallbackWasServedImplicitLocale
727-
? undefined
728-
: `_n_t_/en${encodeURI(pagePath).toLowerCase()}`,
729-
)
728+
if (!fallbackWasServedImplicitLocale) {
729+
expect(headers1ImplicitLocale['netlify-cache-tag']).toBe(
730+
`_n_t_/en${encodeURI(pagePath).toLowerCase()}`,
731+
)
732+
}
730733
expect(headers1ImplicitLocale['netlify-cdn-cache-control']).toBe(
731734
fallbackWasServedImplicitLocale
732-
? undefined
735+
? // fallback should not be cached
736+
nextVersionSatisfies('>=15.4.0-canary.95')
737+
? `private, no-cache, no-store, max-age=0, must-revalidate, durable`
738+
: undefined
733739
: nextVersionSatisfies('>=15.0.0-canary.187')
734740
? 's-maxage=31536000, durable'
735741
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',
@@ -1144,12 +1150,17 @@ test.describe('Page Router with basePath and i18n', () => {
11441150

11451151
const fallbackWasServed =
11461152
useFallback && headers1['cache-status'].includes('"Next.js"; fwd=miss')
1147-
expect(headers1['netlify-cache-tag']).toBe(
1148-
fallbackWasServed ? undefined : `_n_t_/de${encodeURI(pagePath).toLowerCase()}`,
1149-
)
1153+
if (!fallbackWasServed) {
1154+
expect(headers1['netlify-cache-tag']).toBe(
1155+
`_n_t_/de${encodeURI(pagePath).toLowerCase()}`,
1156+
)
1157+
}
11501158
expect(headers1['netlify-cdn-cache-control']).toBe(
11511159
fallbackWasServed
1152-
? undefined
1160+
? // fallback should not be cached
1161+
nextVersionSatisfies('>=15.4.0-canary.95')
1162+
? `private, no-cache, no-store, max-age=0, must-revalidate, durable`
1163+
: undefined
11531164
: nextVersionSatisfies('>=15.0.0-canary.187')
11541165
? 's-maxage=31536000, durable'
11551166
: 's-maxage=31536000, stale-while-revalidate=31536000, durable',

0 commit comments

Comments
 (0)