Commit 19bce018 authored by Tobias Koppers's avatar Tobias Koppers

Add e2e test for (slot) segment in flight router state for parallel routes

Tests that parallel slots produce "(slot)" in the FlightRouterState, covering
both direct pages in slots and nested routes in slots. Documents the current
behavioral difference between Turbopack (always emits (slot)) and webpack
(only emits (slot) for nested routes).
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 6a733742
export default function SlotDefault() {
return <p>Slot default</p>
}
export default function SlotPage() {
return <p>Slot content</p>
}
export default function RootLayout({
children,
slot,
}: {
children: React.ReactNode
slot: React.ReactNode
}) {
return (
<html>
<body>
<div id="children">{children}</div>
<div id="slot">{slot}</div>
</body>
</html>
)
}
export default function Page() {
return <p>Main page</p>
}
export default function NestedSlotDefault() {
return <p>Nested slot default</p>
}
export default function NestedSlotPage() {
return <p>Nested slot content</p>
}
export default function WithNestedLayout({
children,
slot,
}: {
children: React.ReactNode
slot: React.ReactNode
}) {
return (
<div>
<div id="nested-children">{children}</div>
<div id="nested-slot">{slot}</div>
</div>
)
}
export default function WithNestedPage() {
return <p>With nested page</p>
}
/** @type {import('next').NextConfig} */
const nextConfig = {}
module.exports = nextConfig
import { nextTestSetup } from 'e2e-utils'
describe('parallel-routes-slot-flight', () => {
const { next } = nextTestSetup({
files: __dirname,
})
// Helper to extract flight data from script tags
function extractFlightData(html: string): string {
const matches = html.match(
/self\.__next_f\.push\(\[[\d,]+"([^"]*(?:\\.[^"]*)*)"\]\)/g
)
return matches ? matches.join('\n') : ''
}
// Scenario B: nested route in slot - (slot) should be present in BOTH bundlers
it('should include (slot) in flight state for nested routes in parallel slot', async () => {
const html = await next.render('/with-nested/nested')
const flightData = extractFlightData(html)
expect(flightData).toContain('(slot)')
})
// Scenario A: direct page in slot - behavior differs between bundlers
it('should include (slot) in flight state for direct page in parallel slot', async () => {
const html = await next.render('/')
const flightData = extractFlightData(html)
if (process.env.TURBOPACK) {
// Turbopack always wraps parallel slot content in a (slot) level
expect(flightData).toContain('(slot)')
} else {
// Webpack does NOT emit (slot) for direct pages in parallel slots
// This documents the current discrepancy
expect(flightData).not.toContain('(slot)')
}
})
})
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