Commit f32a048b authored by Zack Tanner's avatar Zack Tanner

failing test for prefetchInlining + revalidation

parent e464ca39
import { revalidatePath } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server'
export async function GET(req: NextRequest) {
const path = req.nextUrl.searchParams.get('path') || '/'
try {
revalidatePath(path)
return NextResponse.json({ revalidated: true, path })
} catch {
return NextResponse.json({ revalidated: false, path }, { status: 500 })
}
}
import { ReactNode } from 'react'
export default function OnDemandRevalidateLayout({
children,
}: {
children: ReactNode
}) {
return <div>{children}</div>
}
import { cacheLife } from 'next/cache'
async function CachedValue() {
'use cache'
cacheLife({ stale: 120 })
return <p id="page-on-demand-revalidate-value">{Math.random()}</p>
}
export default function OnDemandRevalidatePage() {
return (
<>
<p id="page-on-demand-revalidate">On-demand revalidate page</p>
<CachedValue />
</>
)
}
import type * as Playwright from 'playwright'
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { createRouterAct } from 'router-act'
// Bit values from PrefetchHint enum (const enum, so we duplicate values here)
......@@ -233,6 +234,55 @@ describe('prefetch inlining', () => {
)
})
it.failing(
'preserves prefetch hints after on-demand revalidation',
async () => {
const beforeTree = await fetchRouteTreePrefetch(
next,
'/test-on-demand-revalidate'
)
expect(renderInliningTree(beforeTree.tree)).toMatchInlineSnapshot(`
"
⇣ root
⇣ └── "test-on-demand-revalidate"
outlined ■ └── "__PAGE__" (+metadata)
"
`)
const before$ = await next.render$('/test-on-demand-revalidate')
const beforeValue = before$('#page-on-demand-revalidate-value').text()
expect(beforeValue).toMatch(/^0\.\d+$/)
const revalidateRes = await next.fetch(
'/api/revalidate-path?path=/test-on-demand-revalidate'
)
expect(revalidateRes.status).toBe(200)
expect(await revalidateRes.json()).toEqual({
revalidated: true,
path: '/test-on-demand-revalidate',
})
await retry(
async () => {
const $ = await next.render$('/test-on-demand-revalidate')
const afterValue = $('#page-on-demand-revalidate-value').text()
expect(afterValue).toMatch(/^0\.\d+$/)
expect(afterValue).not.toBe(beforeValue)
},
15000,
1000
)
const afterTree = await fetchRouteTreePrefetch(
next,
'/test-on-demand-revalidate'
)
expect(renderInliningTree(afterTree.tree)).toBe(
renderInliningTree(beforeTree.tree)
)
}
)
it('parallel routes: parent inlines into one slot only', async () => {
// Layout with two parallel slots (children + @sidebar), all small. The
// layout can only be inlined into one child — the first slot that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment