Unverified Commit ad2c5b3e authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

test: properly gate some cache-component tests (#100828)

Don't use `decribe.skip`, so that these tests at least still run in the
non-cache-components mode.

Except for 3 files, these were already listed in
test/cache-components-tests-manifest.json

I am confused whether we are supposed to use `@gate` or that manifest
now. But that is another preexisting question

This hid the failure in https://github.com/vercel/next.js/pull/100830
parent 75718952
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
"test/development/app-dir/segment-explorer/segment-explorer.test.ts", "test/development/app-dir/segment-explorer/segment-explorer.test.ts",
"test/development/app-dir/serialize-circular-error/serialize-circular-error.test.ts", "test/development/app-dir/serialize-circular-error/serialize-circular-error.test.ts",
"test/development/app-dir/serialize-circular-error/serialize-circular-error.test.ts", "test/development/app-dir/serialize-circular-error/serialize-circular-error.test.ts",
"test/development/app-dir/source-mapping/source-mapping.test.ts",
"test/development/app-dir/ssr-in-rsc/ssr-in-rsc.test.ts", "test/development/app-dir/ssr-in-rsc/ssr-in-rsc.test.ts",
"test/development/app-dir/ssr-only-error/ssr-only-error.test.ts", "test/development/app-dir/ssr-only-error/ssr-only-error.test.ts",
"test/development/app-hmr/hmr-env.test.ts", "test/development/app-hmr/hmr-env.test.ts",
...@@ -343,6 +344,7 @@ ...@@ -343,6 +344,7 @@
"test/integration/app-dir-export/**/*", "test/integration/app-dir-export/**/*",
"test/integration/app-dynamic-error/test/index.test.ts", "test/integration/app-dynamic-error/test/index.test.ts",
"test/integration/app-types/app-types.test.ts", "test/integration/app-types/app-types.test.ts",
"test/production/adapter-config/adapter-config-cache-components.test.ts",
"test/production/app-dir-edge-runtime-with-wasm/index.test.ts", "test/production/app-dir-edge-runtime-with-wasm/index.test.ts",
"test/production/app-dir-prevent-304-caching/index.test.ts", "test/production/app-dir-prevent-304-caching/index.test.ts",
"test/production/app-dynamic-error/app-dynamic-error.test.ts", "test/production/app-dynamic-error/app-dynamic-error.test.ts",
...@@ -380,6 +382,7 @@ ...@@ -380,6 +382,7 @@
"test/production/app-dir/worker-restart/worker-restart.test.ts", "test/production/app-dir/worker-restart/worker-restart.test.ts",
"test/production/app-dir/resume-data-cache/resume-data-cache.test.ts", "test/production/app-dir/resume-data-cache/resume-data-cache.test.ts",
"test/production/app-dir/unstable-cache-foreground-revalidate/unstable-cache-foreground-revalidate.test.ts", "test/production/app-dir/unstable-cache-foreground-revalidate/unstable-cache-foreground-revalidate.test.ts",
"test/production/standalone-mode/required-server-files/required-server-files-ppr.test.ts",
"test/e2e/app-dir/parallel-routes-root-param-dynamic-child/parallel-routes-root-param-dynamic-child.test.ts", "test/e2e/app-dir/parallel-routes-root-param-dynamic-child/parallel-routes-root-param-dynamic-child.test.ts",
"test/e2e/app-dir/io/io.test.ts" "test/e2e/app-dir/io/io.test.ts"
] ]
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils' import { retry } from 'next-test-utils'
const isCacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('source-mapping', () => { describe('source-mapping', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
...@@ -175,7 +173,7 @@ describe.skip('source-mapping', () => { ...@@ -175,7 +173,7 @@ describe.skip('source-mapping', () => {
await expect(browser).toDisplayRedbox(` await expect(browser).toDisplayRedbox(`
{ {
"description": "Attempted to call useClient() from the server but useClient is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.", "description": "Attempted to call useClient() from the server but useClient is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.",
"environmentLabel": "${isCacheComponentsEnabled ? 'Prerender' : 'Server'}", "environmentLabel": "Prerender",
"label": "Runtime Error", "label": "Runtime Error",
"source": "app/server-client/page.js (5:12) @ Component "source": "app/server-client/page.js (5:12) @ Component
> 5 | useClient() > 5 | useClient()
......
...@@ -2,7 +2,8 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -2,7 +2,8 @@ import { nextTestSetup } from 'e2e-utils'
import { expectedParams as expected } from './expected' import { expectedParams as expected } from './expected'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('ppr-middleware-rewrite-force-dynamic-generate-static-params', () => { // @force-gate FIXME
describe('ppr-middleware-rewrite-force-dynamic-generate-static-params', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
......
import { unstable_noStore } from 'next/cache' import { connection } from 'next/server'
import Link from 'next/link' import Link from 'next/link'
import React, { Suspense } from 'react' import React, { Suspense } from 'react'
export function generateStaticParams() {
return [{ slug: ['1'] }, { slug: ['2'] }]
}
export default async function Page(props) { export default async function Page(props) {
const params = await props.params const params = await props.params
return ( return (
...@@ -19,7 +23,7 @@ export default async function Page(props) { ...@@ -19,7 +23,7 @@ export default async function Page(props) {
) )
} }
function Dynamic() { async function Dynamic() {
unstable_noStore() await connection()
return <div id="dynamic">Dynamic content</div> return <div id="dynamic">Dynamic content</div>
} }
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('prefetch-navigation', () => { describe('prefetch-navigation', () => {
const { next, isNextDev } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
......
...@@ -3,7 +3,8 @@ import { retry } from 'next-test-utils' ...@@ -3,7 +3,8 @@ import { retry } from 'next-test-utils'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('ppr', () => { // @force-gate FIXME
describe('ppr', () => {
const { next, isNextDev, isNextStart } = nextTestSetup({ const { next, isNextDev, isNextStart } = nextTestSetup({
files: __dirname, files: __dirname,
env: { env: {
......
process.env.TEST_CACHE_COMPONENTS = '1' process.env.TEST_CACHE_COMPONENTS = '1'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('adapter-config-cache-components', () => { // @force-gate FIXME
describe('adapter-config-cache-components', () => {
require('./adapter-config.test') require('./adapter-config.test')
}) })
...@@ -3,7 +3,7 @@ import path from 'path' ...@@ -3,7 +3,7 @@ import path from 'path'
describe('build-output-tree-view', () => { describe('build-output-tree-view', () => {
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('with mixed static and dynamic pages and app router routes', () => { describe('with mixed static and dynamic pages and app router routes', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: path.join(__dirname, 'fixtures/mixed'), files: path.join(__dirname, 'fixtures/mixed'),
skipStart: true, skipStart: true,
...@@ -24,8 +24,8 @@ describe('build-output-tree-view', () => { ...@@ -24,8 +24,8 @@ describe('build-output-tree-view', () => {
├ ○ /cache-life-custom ≈7m ≈2h ├ ○ /cache-life-custom ≈7m ≈2h
├ ○ /cache-life-hours 1h 1d ├ ○ /cache-life-hours 1h 1d
├ ƒ /dynamic ├ ƒ /dynamic
├ /ppr/[slug] 1w 30d ├ /ppr/[slug]
│ ├ ◐ /ppr/[slug] 1w 30d │ ├ ◐ /ppr/[slug]
│ ├ ◐ /ppr/days 1d 1w │ ├ ◐ /ppr/days 1d 1w
│ └ ◐ /ppr/weeks 1w 30d │ └ ◐ /ppr/weeks 1w 30d
└ ○ /revalidate 15m 1y └ ○ /revalidate 15m 1y
......
export const dynamic = 'force-static'
export async function GET() { export async function GET() {
return Response.json({ message: 'hello world' }) return Response.json({ message: 'hello world' })
} }
import { connection } from 'next/server'
export async function GET() { export async function GET() {
await connection()
return Response.json({ message: 'hello world' }) return Response.json({ message: 'hello world' })
} }
import { headers } from 'next/headers' import { headers } from 'next/headers'
export const instant = false
export default async function Page() { export default async function Page() {
await headers() await headers()
......
import { cacheLife } from 'next/cache' import { cacheLife } from 'next/cache'
import { notFound } from 'next/navigation'
import { connection } from 'next/server'
import { Suspense } from 'react'
type CacheLife = Parameters<typeof cacheLife>[0] async function getCachedValue(profile: string) {
async function getCachedValue(cacheLife: CacheLife) {
'use cache' 'use cache'
cacheLife(cacheLife) if (profile === 'days') {
cacheLife('days')
} else if (profile === 'weeks') {
cacheLife('weeks')
} else {
notFound()
}
return Math.random() return Math.random()
} }
export default async function Page({ export default function Page({
params, params,
}: { }: {
params: Promise<{ slug: CacheLife }> params: Promise<{ slug: string }>
}) { }) {
return (
<Suspense fallback={null}>
<Content params={params} />
</Suspense>
)
}
async function Content({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params const { slug } = await params
return <p>hello world {await getCachedValue(slug)}</p> return (
<>
<p>hello world {await getCachedValue(slug)}</p>
<Suspense fallback={null}>
<Dynamic />
</Suspense>
</>
)
}
async function Dynamic() {
await connection()
return <p>dynamic content</p>
} }
export function generateStaticParams() { export function generateStaticParams() {
......
export const revalidate = 900 'use cache'
import { cacheLife } from 'next/cache'
export default async function Page() {
cacheLife({ revalidate: 900 })
export default function Page() {
return <p>hello world</p> return <p>hello world</p>
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* @type {import('next').NextConfig} * @type {import('next').NextConfig}
*/ */
const nextConfig = { const nextConfig = {
experimental: { useCache: true },
cacheComponents: true, cacheComponents: true,
} }
......
...@@ -14,7 +14,8 @@ import { ...@@ -14,7 +14,8 @@ import {
import { ChildProcess } from 'node:child_process' import { ChildProcess } from 'node:child_process'
// TODO(NAR-423): Migrate to Cache Components. // TODO(NAR-423): Migrate to Cache Components.
describe.skip('required server files app router', () => { // @force-gate FIXME
describe('required server files app router', () => {
let server: ChildProcess let server: ChildProcess
let appPort: number | string let appPort: number | string
let delayedPostpone: string let delayedPostpone: string
......
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