Add failing test for lazy elements in `"use cache"` input

parent a6075ff9
import { Foo } from '../../client'
export default async function Page() {
'use cache'
return (
<p>
<Foo />
</p>
)
}
'use cache'
export default async function Root({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}
import { nextTestSetup } from 'e2e-utils'
import { retry, waitFor } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
const GENERIC_RSC_ERROR =
'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.'
......@@ -458,4 +459,18 @@ describe('use-cache', () => {
const text = await browser.elementByCss('h2').text()
expect(text).toBe('This page could not be found.')
})
// TODO: Fails with Turbopack.
it('should support lazy elements as input for "use cache" functions', async () => {
const outputIndex = next.cliOutput.length
const browser = await next.browser('/input-with-lazy')
const text = await browser.elementByCss('p').text()
expect(text).toBe('foo')
const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex))
expect(cliOutput).not.toContain(
'Error: Route "/input-with-lazy": A component accessed data, headers, params, searchParams, or a short-lived cache'
)
})
})
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