Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e37a5e0

Browse files
authored
test: adjust assertions for /_not-found being possibly added to prerender manifest (#3043)
1 parent 199d473 commit e37a5e0

File tree

3 files changed

+85
-53
lines changed

3 files changed

+85
-53
lines changed

‎tests/integration/cache-handler.test.ts

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
getBlobEntries,
1818
startMockBlobStore,
1919
} from '../utils/helpers.js'
20-
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
20+
import {
21+
nextVersionSatisfies,
22+
shouldHaveAppRouterNotFoundInPrerenderManifest,
23+
} from '../utils/next-version-helpers.mjs'
2124

2225
// Disable the verbose logging of the lambda-local runtime
2326
getLogger().level = 'alert'
@@ -212,14 +215,17 @@ describe('app router', () => {
212215
console.timeEnd('runPlugin')
213216
// check if the blob entries where successful set on the build plugin
214217
const blobEntries = await getBlobEntries(ctx)
215-
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([
216-
'/404',
217-
'/index',
218-
'/posts/1',
219-
'/posts/2',
220-
'404.html',
221-
'500.html',
222-
])
218+
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual(
219+
[
220+
'/404',
221+
shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined,
222+
'/index',
223+
'/posts/1',
224+
'/posts/2',
225+
'404.html',
226+
'500.html',
227+
].filter(Boolean),
228+
)
223229

224230
// test the function call
225231
const post1 = await invokeFunction(ctx, { url: 'posts/1' })
@@ -362,23 +368,26 @@ describe('plugin', () => {
362368
await runPlugin(ctx)
363369
// check if the blob entries where successful set on the build plugin
364370
const blobEntries = await getBlobEntries(ctx)
365-
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([
366-
'/404',
367-
'/api/revalidate-handler',
368-
'/api/static/first',
369-
'/api/static/second',
370-
'/api/zero-length-response',
371-
'/index',
372-
'/product/事前レンダリング,test',
373-
'/revalidate-fetch',
374-
'/static-fetch-1',
375-
'/static-fetch-2',
376-
'/static-fetch-3',
377-
'/static-fetch/1',
378-
'/static-fetch/2',
379-
'404.html',
380-
'500.html',
381-
])
371+
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual(
372+
[
373+
'/404',
374+
shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined,
375+
'/api/revalidate-handler',
376+
'/api/static/first',
377+
'/api/static/second',
378+
'/api/zero-length-response',
379+
'/index',
380+
'/product/事前レンダリング,test',
381+
'/revalidate-fetch',
382+
'/static-fetch-1',
383+
'/static-fetch-2',
384+
'/static-fetch-3',
385+
'/static-fetch/1',
386+
'/static-fetch/2',
387+
'404.html',
388+
'500.html',
389+
].filter(Boolean),
390+
)
382391
})
383392
})
384393

‎tests/integration/simple-app.test.ts

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ import {
3434
getBlobEntries,
3535
startMockBlobStore,
3636
} from '../utils/helpers.js'
37-
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
37+
import {
38+
nextVersionSatisfies,
39+
shouldHaveAppRouterNotFoundInPrerenderManifest,
40+
} from '../utils/next-version-helpers.mjs'
3841

3942
const mockedCp = cp as Mock<(typeof import('node:fs/promises'))['cp']>
4043

@@ -95,26 +98,29 @@ test<FixtureTestContext>('Test that the simple next app is working', async (ctx)
9598
await runPlugin(ctx)
9699
// check if the blob entries where successful set on the build plugin
97100
const blobEntries = await getBlobEntries(ctx)
98-
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([
99-
'/404',
100-
'/api/cached-permanent',
101-
'/api/cached-revalidate',
102-
'/config-redirect',
103-
'/config-redirect/dest',
104-
'/config-rewrite',
105-
'/config-rewrite/dest',
106-
'/image/local',
107-
'/image/migration-from-v4-runtime',
108-
'/image/remote-domain',
109-
'/image/remote-pattern-1',
110-
'/image/remote-pattern-2',
111-
'/index',
112-
'/other',
113-
'/route-resolves-to-not-found',
114-
'404.html',
115-
'500.html',
116-
'fully-static.html',
117-
])
101+
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual(
102+
[
103+
'/404',
104+
shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined,
105+
'/api/cached-permanent',
106+
'/api/cached-revalidate',
107+
'/config-redirect',
108+
'/config-redirect/dest',
109+
'/config-rewrite',
110+
'/config-rewrite/dest',
111+
'/image/local',
112+
'/image/migration-from-v4-runtime',
113+
'/image/remote-domain',
114+
'/image/remote-pattern-1',
115+
'/image/remote-pattern-2',
116+
'/index',
117+
'/other',
118+
'/route-resolves-to-not-found',
119+
'404.html',
120+
'500.html',
121+
'fully-static.html',
122+
].filter(Boolean),
123+
)
118124

119125
// test the function call
120126
const home = await invokeFunction(ctx)
@@ -385,12 +391,15 @@ test.skipIf(process.env.NEXT_VERSION !== 'canary')<FixtureTestContext>(
385391
await runPlugin(ctx)
386392
// check if the blob entries where successful set on the build plugin
387393
const blobEntries = await getBlobEntries(ctx)
388-
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual([
389-
'/404',
390-
'/index',
391-
'404.html',
392-
'500.html',
393-
])
394+
expect(blobEntries.map(({ key }) => decodeBlobKey(key)).sort()).toEqual(
395+
[
396+
'/404',
397+
shouldHaveAppRouterNotFoundInPrerenderManifest() ? '/_not-found' : undefined,
398+
'/index',
399+
'404.html',
400+
'500.html',
401+
].filter(Boolean),
402+
)
394403

395404
// test the function call
396405
const home = await invokeFunction(ctx)

‎tests/utils/next-version-helpers.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ export function nextVersionSatisfies(condition) {
2424
return satisfies(checkVersion, condition, { includePrerelease: true }) || version === condition
2525
}
2626

27+
export function isNextCanary() {
28+
return [process.env.NEXT_RESOLVED_VERSION, process.env.NEXT_VERSION].some((tagOrVersionOrEmpty) =>
29+
tagOrVersionOrEmpty?.includes('canary'),
30+
)
31+
}
32+
33+
export function shouldHaveAppRouterNotFoundInPrerenderManifest() {
34+
// https://github.com/vercel/next.js/pull/82199
35+
36+
// The canary versions are out of band, as there stable/latest patch versions higher than base of canary versions
37+
// and change was not backported to stable versions
38+
return nextVersionSatisfies('>=15.4.2-canary.33') && isNextCanary()
39+
}
40+
2741
/**
2842
* Check if current next version requires React 19
2943
* @param {string} version Next version

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /