Unverified Commit e9df6ed9 authored by Josh Story's avatar Josh Story Committed by GitHub

Add instant validation tests for parallel slot config attribution (#91656)

Tests that unstable_instant configs placed at different positions across
a parallel route fork correctly attribute errors to the blocking
segment, with the cause pointing to the config that requires instant
behavior. Includes both invalid cases that produce errors and valid
cases that pass cleanly. Does not yet detect incompatible configurations
like false on one slot alongside an instant config on a sibling — that
will be handled in a followup.
parent 4693685b
......@@ -144,6 +144,27 @@ export default async function Page() {
<li>
<DebugLinks href="/suspense-in-root/static/false-below-static" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/slot-config-only" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/slot-layout-config" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/slot-runtime-config" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/children-config-with-slot" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/fork-layout-config-with-slot" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/both-configs" />
</li>
<li>
<DebugLinks href="/suspense-in-root/parallel/slot-config-children-suspended" />
</li>
</ul>
<h2>Head</h2>
......
export default function SlotDefault() {
return <p>Slot default</p>
}
export const unstable_instant = { prefetch: 'static' }
export default function SlotPage() {
return (
<p style={{ color: 'blue' }}>
This is a parallel slot page with unstable_instant (static)
</p>
)
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
export const unstable_instant = { prefetch: 'static' }
export default function Page() {
return (
<main>
<p>This is a static children page with unstable_instant (static)</p>
</main>
)
}
import { cookies } from 'next/headers'
export default async function SlotPage() {
await cookies()
return (
<p style={{ color: 'blue' }}>
This is a parallel slot page that awaits cookies() without Suspense
</p>
)
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
export const unstable_instant = { prefetch: 'static' }
export default function Page() {
return (
<main>
<p>This is a static children page with unstable_instant (static)</p>
</main>
)
}
import { cookies } from 'next/headers'
export default async function SlotPage() {
await cookies()
return (
<p style={{ color: 'blue' }}>
This is a parallel slot page that awaits cookies() without Suspense
</p>
)
}
import { ReactNode } from 'react'
export const unstable_instant = { prefetch: 'static' }
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
import { cookies } from 'next/headers'
export default async function ChildrenPage() {
await cookies()
return (
<main>
<p>This is the children page that awaits cookies() without Suspense</p>
</main>
)
}
export const unstable_instant = { prefetch: 'static' }
export default function SlotPage() {
return (
<p style={{ color: 'blue' }}>
This is a parallel slot page with unstable_instant (static)
</p>
)
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
import { Suspense } from 'react'
import { cookies } from 'next/headers'
export default function Page() {
return (
<main>
<p>This is the children page with cookies() properly inside Suspense</p>
<Suspense fallback={<p>Loading dynamic content...</p>}>
<DynamicContent />
</Suspense>
</main>
)
}
async function DynamicContent() {
await cookies()
return <p>Dynamic content loaded</p>
}
export default function SlotDefault() {
return <p>Slot default</p>
}
export const unstable_instant = { prefetch: 'static' }
export default function SlotPage() {
return (
<p style={{ color: 'blue' }}>
This is a parallel slot page with unstable_instant (static)
</p>
)
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
import { cookies } from 'next/headers'
export default async function ChildrenPage() {
await cookies()
return (
<main>
<p>This is the children page that awaits cookies() without Suspense</p>
</main>
)
}
import { ReactNode } from 'react'
export const unstable_instant = { prefetch: 'static' }
export default function SlotLayout({ children }: { children: ReactNode }) {
return (
<div>
<em>This is a layout inside the slot with unstable_instant (static)</em>
<hr />
{children}
</div>
)
}
export default function SlotPage() {
return <p style={{ color: 'blue' }}>This is a static parallel slot page</p>
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
import { cookies } from 'next/headers'
export default async function ChildrenPage() {
await cookies()
return (
<main>
<p>This is the children page that awaits cookies() without Suspense</p>
</main>
)
}
import { Suspense } from 'react'
import { connection } from 'next/server'
export const unstable_instant = {
prefetch: 'runtime',
samples: [{}],
}
export default function SlotPage() {
return (
<div>
<p style={{ color: 'blue' }}>
This is a parallel slot page with unstable_instant (runtime)
</p>
<Suspense
fallback={<p style={{ color: 'blue' }}>Loading slot dynamic...</p>}
>
<SlotDynamic />
</Suspense>
</div>
)
}
async function SlotDynamic() {
await connection()
return <p style={{ color: 'blue' }}>Slot dynamic content loaded</p>
}
import { ReactNode } from 'react'
export default function Layout({
children,
slot,
}: {
children: ReactNode
slot: ReactNode
}) {
return (
<>
<div style={{ border: '1px solid blue', padding: '1em' }}>{slot}</div>
{children}
</>
)
}
import { cookies } from 'next/headers'
export default async function ChildrenPage() {
await cookies()
return (
<main>
<p>This is the children page that awaits cookies() without Suspense</p>
</main>
)
}
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