| | import { nextTestSetup } from 'e2e-utils' |
| | import { join } from 'path' |
| | import { createSandbox } from 'development-sandbox' |
| |
|
| | const isPPREnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' |
| |
|
| | describe('app-root-params - cache - at runtime', () => { |
| | const { next, isNextDev, skipped } = nextTestSetup({ |
| | files: join(__dirname, 'fixtures', 'use-cache-runtime'), |
| | skipStart: true, |
| | |
| | skipDeployment: true, |
| | }) |
| |
|
| | if (skipped) return |
| |
|
| | if (isNextDev) { |
| | it('should error when using rootParams within a "use cache" - dev', async () => { |
| | await using sandbox = await createSandbox( |
| | next, |
| | undefined, |
| | '/en/us/use-cache' |
| | ) |
| | const { session } = sandbox |
| | await session.assertHasRedbox() |
| | if (isPPREnabled) { |
| | |
| | |
| | expect(await session.getRedboxDescription()).toInclude( |
| | 'Required root params (lang, locale) were not provided in generateStaticParams' |
| | ) |
| | } else { |
| | expect(await session.getRedboxDescription()).toInclude( |
| | 'Route /[lang]/[locale]/use-cache used `unstable_rootParams()` inside `"use cache"` or `unstable_cache`' |
| | ) |
| | } |
| | }) |
| |
|
| | it('should error when using rootParams within `unstable_cache` - dev', async () => { |
| | await using sandbox = await createSandbox( |
| | next, |
| | undefined, |
| | '/en/us/unstable_cache' |
| | ) |
| | const { session } = sandbox |
| | await session.assertHasRedbox() |
| | if (isPPREnabled) { |
| | |
| | |
| | expect(await session.getRedboxDescription()).toInclude( |
| | 'Required root params (lang, locale) were not provided in generateStaticParams' |
| | ) |
| | } else { |
| | expect(await session.getRedboxDescription()).toInclude( |
| | 'Route /[lang]/[locale]/unstable_cache used `unstable_rootParams()` inside `"use cache"` or `unstable_cache`' |
| | ) |
| | } |
| | }) |
| | } else { |
| | beforeAll(async () => { |
| | try { |
| | await next.start() |
| | } catch (_) { |
| | |
| | } |
| | }) |
| |
|
| | it('should error when using rootParams within a "use cache" - start', async () => { |
| | if (isPPREnabled) { |
| | |
| | |
| | expect(next.cliOutput).toInclude( |
| | 'Required root params (lang, locale) were not provided in generateStaticParams' |
| | ) |
| | } else { |
| | await next.render$('/en/us/use-cache') |
| | expect(next.cliOutput).toInclude( |
| | 'Error: Route /[lang]/[locale]/use-cache used `unstable_rootParams()` inside `"use cache"` or `unstable_cache`' |
| | ) |
| | } |
| | }) |
| |
|
| | it('should error when using rootParams within `unstable_cache` - start', async () => { |
| | if (isPPREnabled) { |
| | |
| | |
| | expect(next.cliOutput).toInclude( |
| | 'Required root params (lang, locale) were not provided in generateStaticParams' |
| | ) |
| | } else { |
| | await next.render$('/en/us/unstable_cache') |
| | expect(next.cliOutput).toInclude( |
| | 'Error: Route /[lang]/[locale]/unstable_cache used `unstable_rootParams()` inside `"use cache"` or `unstable_cache`' |
| | ) |
| | } |
| | }) |
| | } |
| | }) |
| |
|
| | describe('app-root-params - cache - at build', () => { |
| | const { next, isNextDev } = nextTestSetup({ |
| | files: join(__dirname, 'fixtures', 'use-cache-build'), |
| | skipStart: true, |
| | }) |
| |
|
| | if (isNextDev) { |
| | |
| | it('noop in dev', () => {}) |
| | } else { |
| | it('should error when building a project that uses rootParams within `"use cache"`', async () => { |
| | try { |
| | await next.start() |
| | } catch { |
| | |
| | } |
| | expect(next.cliOutput).toInclude( |
| | 'Error: Route /[lang]/[locale]/use-cache used `unstable_rootParams()` inside `"use cache"` or `unstable_cache`' |
| | ) |
| | }) |
| | } |
| | }) |
| |
|