Skip to content

Commit 58f2d33

Browse files
committed
fix: fixed deploy tests for failing ppr tests
1 parent f6e9bd9 commit 58f2d33

File tree

2 files changed

+97
-105
lines changed

2 files changed

+97
-105
lines changed

test/e2e/app-dir/ppr-full/ppr-full.test.ts

Lines changed: 96 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -351,143 +351,135 @@ describe('ppr-full', () => {
351351
expect($('[data-agent]').closest('[hidden]').length).toBe(1)
352352
})
353353

354-
it('should render the dynamic shell on the second visit', async () => {
355-
const random = Math.random().toString(16).slice(2)
356-
const pathname = `/fallback/dynamic/params/on-second-visit-${random}`
357-
358-
let $ = await next.render$(pathname)
359-
expect($('[data-slug]').closest('[hidden]').length).toBe(1)
360-
expect($('[data-agent]').closest('[hidden]').length).toBe(1)
354+
if (!isNextDeploy) {
355+
it('should render the route shell on the second visit', async () => {
356+
const random = Math.random().toString(16).slice(2)
357+
const pathname = `/fallback/dynamic/params/on-second-visit-${random}`
361358

362-
await retry(async () => {
363-
$ = await next.render$(pathname)
364-
expect($('[data-slug]').closest('[hidden]').length).toBe(0)
359+
let $ = await next.render$(pathname)
360+
expect($('[data-slug]').closest('[hidden]').length).toBe(1)
365361
expect($('[data-agent]').closest('[hidden]').length).toBe(1)
362+
363+
await retry(async () => {
364+
$ = await next.render$(pathname)
365+
expect($('[data-slug]').closest('[hidden]').length).toBe(0)
366+
expect($('[data-agent]').closest('[hidden]').length).toBe(1)
367+
})
366368
})
367-
})
368369

369-
it('should render the dynamic shell as static if the page is static', async () => {
370-
const random = Math.random().toString(16).slice(2)
371-
const pathname = `/fallback/params/on-second-visit-${random}`
370+
it('should render the dynamic shell as static if the page is static', async () => {
371+
const random = Math.random().toString(16).slice(2)
372+
const pathname = `/fallback/params/on-second-visit-${random}`
372373

373-
// Expect that the slug had to be resumed.
374-
let $ = await next.render$(pathname)
375-
expect($('[data-slug]').closest('[hidden]').length).toBe(1)
374+
// Expect that the slug had to be resumed.
375+
let $ = await next.render$(pathname)
376+
expect($('[data-slug]').closest('[hidden]').length).toBe(1)
376377

377-
// The slug didn't have to be resumed, and it should all be static.
378-
await retry(async () => {
379-
$ = await next.render$(pathname)
380-
expect($('[data-slug]').closest('[hidden]').length).toBe(0)
378+
// The slug didn't have to be resumed, and it should all be static.
379+
await retry(async () => {
380+
$ = await next.render$(pathname)
381+
expect($('[data-slug]').closest('[hidden]').length).toBe(1)
381382

382-
const {
383-
timings: { streamFirstChunk, start, streamEnd },
384-
chunks,
385-
} = await measurePPRTimings(async () => {
386-
const res = await next.fetch(pathname)
387-
expect(res.status).toBe(200)
388-
if (isNextDeploy) {
389-
expect(res.headers.get('x-vercel-cache')).toBe('HIT')
390-
} else {
383+
const {
384+
timings: { streamFirstChunk, start, streamEnd },
385+
chunks,
386+
} = await measurePPRTimings(async () => {
387+
const res = await next.fetch(pathname)
388+
expect(res.status).toBe(200)
391389
expect(res.headers.get('x-nextjs-cache')).toBe('HIT')
392-
}
393390

394-
return res.body
395-
}, 1000)
391+
return res.body
392+
}, 1000)
396393

397-
expect(chunks.dynamic).toBe('')
398-
expect(streamFirstChunk - start).toBeLessThan(500)
399-
expect(streamEnd - start).toBeLessThan(500)
394+
expect(chunks.dynamic).toBe('')
395+
expect(streamFirstChunk - start).toBeLessThan(500)
396+
expect(streamEnd - start).toBeLessThan(500)
397+
})
400398
})
401-
})
402399

403-
it('will only revalidate the page', async () => {
404-
const random = Math.random().toString(16).slice(2)
405-
const pathname = `/fallback/dynamic/params/revalidate-${random}`
400+
it('will only revalidate the page', async () => {
401+
const random = Math.random().toString(16).slice(2)
402+
const pathname = `/fallback/dynamic/params/revalidate-${random}`
406403

407-
let $ = await next.render$(pathname)
408-
const fallbackID = $('[data-layout]').data('layout') as string
404+
let $ = await next.render$(pathname)
405+
const fallbackID = $('[data-layout]').data('layout') as string
409406

410-
let dynamicID: string
411-
await retry(async () => {
412-
$ = await next.render$(pathname)
413-
dynamicID = $('[data-layout]').data('layout') as string
407+
let dynamicID: string
408+
await retry(async () => {
409+
$ = await next.render$(pathname)
410+
dynamicID = $('[data-layout]').data('layout') as string
414411

415-
// These should be different,
416-
expect(dynamicID).not.toBe(fallbackID)
417-
})
412+
// These should be different,
413+
expect(dynamicID).not.toBe(fallbackID)
414+
})
418415

419-
// Now let's revalidate the page.
420-
await next.fetch(
421-
`/api/revalidate?pathname=${encodeURIComponent(pathname)}`
422-
)
416+
// Now let's revalidate the page.
417+
await next.fetch(
418+
`/api/revalidate?pathname=${encodeURIComponent(pathname)}`
419+
)
423420

424-
// We expect to get the fallback shell again.
425-
if (!isNextDeploy) {
421+
// We expect to get the fallback shell again.
426422
$ = await next.render$(pathname)
427423
expect($('[data-layout]').data('layout')).toBe(fallbackID)
428-
}
429424

430-
// Let's wait for the page to be revalidated.
431-
await retry(async () => {
432-
$ = await next.render$(pathname)
433-
const newDynamicID = $('[data-layout]').data('layout') as string
434-
expect(newDynamicID).not.toBe(dynamicID)
425+
// Let's wait for the page to be revalidated.
426+
await retry(async () => {
427+
$ = await next.render$(pathname)
428+
const newDynamicID = $('[data-layout]').data('layout') as string
429+
expect(newDynamicID).not.toBe(dynamicID)
430+
})
435431
})
436-
})
437432

438-
it('will revalidate the page and fallback shell', async () => {
439-
const random = Math.random().toString(16).slice(2)
440-
const pathname = `/fallback/dynamic/params/revalidate-${random}`
433+
it('will revalidate the page and fallback shell', async () => {
434+
const random = Math.random().toString(16).slice(2)
435+
const pathname = `/fallback/dynamic/params/revalidate-${random}`
441436

442-
let $ = await next.render$(pathname)
443-
const fallbackID = $('[data-layout]').data('layout') as string
437+
let $ = await next.render$(pathname)
438+
const fallbackID = $('[data-layout]').data('layout') as string
444439

445-
let dynamicID: string
446-
await retry(async () => {
447-
$ = await next.render$(pathname)
448-
dynamicID = $('[data-layout]').data('layout') as string
440+
let dynamicID: string
441+
await retry(async () => {
442+
$ = await next.render$(pathname)
443+
dynamicID = $('[data-layout]').data('layout') as string
449444

450-
// These should be different,
451-
expect(dynamicID).not.toBe(fallbackID)
452-
})
445+
// These should be different,
446+
expect(dynamicID).not.toBe(fallbackID)
447+
})
453448

454-
// Now let's revalidate the page.
455-
await next.fetch(
456-
`/api/revalidate?pathname=${encodeURIComponent(pathname)}`
457-
)
449+
// Now let's revalidate the page.
450+
await next.fetch(
451+
`/api/revalidate?pathname=${encodeURIComponent(pathname)}`
452+
)
458453

459-
// We expect to get the fallback shell.
460-
$ = await next.render$(pathname)
454+
// We expect to get the fallback shell.
455+
$ = await next.render$(pathname)
461456

462-
// When deployed to Vercel, it will serve a stale version of the dynamic shell
463-
// Whereas with `next start` it will serve the fallback shell
464-
if (isNextDeploy) {
465-
expect($('[data-layout]').data('layout')).toBe(dynamicID)
466-
} else {
457+
// When deployed to Vercel, it will serve a stale version of the dynamic shell
458+
// Whereas with `next start` it will serve the fallback shell
467459
expect($('[data-layout]').data('layout')).toBe(fallbackID)
468-
}
469460

470-
// Let's wait for the page to be revalidated.
471-
let revalidatedDynamicID: string
472-
await retry(async () => {
473-
$ = await next.render$(pathname)
474-
revalidatedDynamicID = $('[data-layout]').data('layout') as string
475-
expect(revalidatedDynamicID).not.toBe(dynamicID)
476-
expect(revalidatedDynamicID).not.toBe(fallbackID)
461+
// Let's wait for the page to be revalidated.
462+
let revalidatedDynamicID: string
463+
await retry(async () => {
464+
$ = await next.render$(pathname)
465+
revalidatedDynamicID = $('[data-layout]').data('layout') as string
466+
expect(revalidatedDynamicID).not.toBe(dynamicID)
467+
expect(revalidatedDynamicID).not.toBe(fallbackID)
468+
})
477469
})
478-
})
479470

480-
/**
481-
* This test is really here to just to force the the suite to have the expected route
482-
* as part of the build. If this failed we'd get a build error and all the tests would fail
483-
*/
484-
it('will allow dynamic fallback shells even when static is enforced', async () => {
485-
const random = Math.random().toString(16).slice(2)
486-
const pathname = `/fallback/dynamic/params/revalidate-${random}`
471+
/**
472+
* This test is really here to just to force the the suite to have the expected route
473+
* as part of the build. If this failed we'd get a build error and all the tests would fail
474+
*/
475+
it('will allow dynamic fallback shells even when static is enforced', async () => {
476+
const random = Math.random().toString(16).slice(2)
477+
const pathname = `/fallback/dynamic/params/revalidate-${random}`
487478

488-
let $ = await next.render$(pathname)
489-
expect($('[data-slug]').text()).toBe(`revalidate-${random}`)
490-
})
479+
let $ = await next.render$(pathname)
480+
expect($('[data-slug]').text()).toBe(`revalidate-${random}`)
481+
})
482+
}
491483
})
492484

493485
it('should allow client layouts without postponing fallback if params are not accessed', async () => {

test/lib/next-modes/next-deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class NextDeployInstance extends NextInstance {
150150
// Use the vercel inspect command to get the CLI output from the build.
151151
const buildLogs = await execa(
152152
'vercel',
153-
['inspect', '--logs', this._url, ...vercelFlags],
153+
['logs', this._url, ...vercelFlags],
154154
{
155155
env: vercelEnv,
156156
reject: false,

0 commit comments

Comments
 (0)