Unverified Commit 8e1b85fb authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test: avoid runtime data in error recurrence

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 9ec44ac7
import Link from 'next/link'
// Shared by `/server-console` and `/server-console/recur` so a test can patch
// one source file and still reach the error from a second, statically routed
// document. `'disabled'` is never passed at runtime: it is a stable literal
// that the test rewrites to `'recur'` to silence the parent while keeping the
// nested route failing, so avoid "simplifying" this comparison away.
export default function ServerConsole({
error,
}: {
error?: 'recur' | 'disabled'
}) {
if (error !== 'disabled') {
console.error(new Error('server console failed'))
}
return (
<>
<p id="content">Before edit</p>
<Link id="recur" href="/server-console/recur" prefetch={false}>
Recur
</Link>
</>
)
}
import Link from 'next/link'
import ServerConsole from './content'
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ error?: string }>
}) {
const { error } = await searchParams
if (error !== 'disabled') {
console.error(new Error('server console failed'))
}
return (
<>
<p id="content">Before edit</p>
<Link id="recur" href="/server-console?error=recur" prefetch={false}>
Recur
</Link>
</>
)
export default function Page() {
return <ServerConsole />
}
import ServerConsole from '../content'
export default function Page() {
return <ServerConsole error="recur" />
}
......@@ -273,7 +273,7 @@ describe('runtime-error-events', () => {
it('clears server-only errors without reloading the document', async () => {
const observer = await observe(next.url)
const original = await next.readFile('app/server-console/page.tsx')
const original = await next.readFile('app/server-console/content.tsx')
const browser = await next.browser('/server-console')
let lateObserver: Awaited<ReturnType<typeof observe>> | undefined
try {
......@@ -286,7 +286,7 @@ describe('runtime-error-events', () => {
const documentId = await browser.eval(() => Reflect.get(self, '__next_r'))
const previousCount = observer.messages.length
await next.patchFile(
'app/server-console/page.tsx',
'app/server-console/content.tsx',
original
.replace("error !== 'disabled'", "error === 'recur'")
.replace('Before edit', 'After edit')
......@@ -330,7 +330,7 @@ describe('runtime-error-events', () => {
observer.close()
lateObserver?.close()
await browser.close()
await next.patchFile('app/server-console/page.tsx', original)
await next.patchFile('app/server-console/content.tsx', original)
}
})
......
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