Unverified Commit 6f98e9fc authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Isolate deploy e2e revalidation scope per suite (#100718)

`revalidatePath`/`revalidateTag` invalidate cache at Vercel **project**
scope, not per deployment. Deploy e2e suites share one project per
matrix dimension, so concurrent suites could purge each other's cache
entries: `app-static` and `actions` both used the tags
`thankyounext`/`justputit`, and several suites revalidated `/`. The
deploy manifest recorded the fallout as known-failed tests.

- Prefix cache tags with their suite slug: `actions:*`, `app-static:*`,
`revalidatetag-rsc:*`, `use-cache-after-uncached-io:*`,
`use-cache-custom-handler:*`
- Move `parallel-routes-revalidation` under `/prr` and
`actions-discarded-navigation-revert` under `/adr` so no deploy-active
fixture revalidates `/`; retarget navigation's popstate-revalidate
action to its own subtree and prefetch-inlining's default revalidate
path to its own route
- Give the cache-components deploy job (`build_and_test.yml`) its own
Vercel project (`vtest314-e2e-tests-cache-components`) via a new
`VERCEL_TEST_PROJECT` override in `next-deploy.ts`, so its suites can't
interfere with the plain deploy job's suites; the weekly project-reset
cron keeps the new project fresh
- Remove the healed known-failed entries from the deploy manifest and
add the `increment to trigger deploy tests` marker so the PR deploy jobs
exercise the affected suites
- `app-static`: assert cache persistence on a suite-unique route in
deploy mode (the `/` check can still observe foreign root-layout purges
from `vary-params-base-dynamic`, whose project-wide purge is its test
subject and can't be renamed), and fix the persistence loop never
recording `prevData`

## Verification

CI

<!-- NEXT_JS_LLM -->

---------
Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
parent 55e64de0
...@@ -949,6 +949,9 @@ jobs: ...@@ -949,6 +949,9 @@ jobs:
export NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json,test/cache-components-tests-manifest.json" export NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json,test/cache-components-tests-manifest.json"
export NEXT_E2E_TEST_TIMEOUT=240000 export NEXT_E2E_TEST_TIMEOUT=240000
export IS_TURBOPACK_TEST=1 export IS_TURBOPACK_TEST=1
# revalidatePath/revalidateTag invalidate at project scope, so this
# job deploys into its own project, separate from the plain deploy job.
export VERCEL_TEST_PROJECT="vtest314-e2e-tests-cache-components"
node scripts/test-new-tests.mjs \ node scripts/test-new-tests.mjs \
--mode deploy \ --mode deploy \
--group ${{ matrix.group }} --group ${{ matrix.group }}
......
...@@ -238,6 +238,18 @@ tail -5 /tmp/test-output.log # Summary ...@@ -238,6 +238,18 @@ tail -5 /tmp/test-output.log # Summary
}) })
``` ```
- **Keep `revalidatePath`/`revalidateTag` arguments and fetch URLs
suite-unique.** In deploy mode the cache lives at Vercel project scope and
deploy e2e suites share one project per matrix dimension: revalidation
purges by tag/path across the whole project, and fetch cache entries are
keyed by URL across deployments. Prefix tags with the suite slug (e.g.
`cacheTag('app-static:thankyounext')`), never revalidate `/` from a
deploy-active fixture (every app has a `/` route — move the page to a
suite-unique route and revalidate that instead), and when a test depends on
a cached value, give the data-endpoint URL suite-unique query params (e.g.
`api/random?app-static-page`) so another fixture's fetches and
revalidations cannot share or purge the entry. See `test/AGENTS.md`.
## Linting and Types ## Linting and Types
```bash ```bash
......
...@@ -21,18 +21,24 @@ const TEST_TEAMS = [ ...@@ -21,18 +21,24 @@ const TEST_TEAMS = [
teamId: TEST_TEAM_NAME, teamId: TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_TEST_TOKEN', tokenEnvVar: 'VERCEL_TEST_TOKEN',
token: TEST_TOKEN, token: TEST_TOKEN,
extraProjects: [],
}, },
{ {
teamEnvVar: 'VERCEL_ADAPTER_TEST_TEAM', teamEnvVar: 'VERCEL_ADAPTER_TEST_TEAM',
teamId: ADAPTER_TEST_TEAM_NAME, teamId: ADAPTER_TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_ADAPTER_TEST_TOKEN', tokenEnvVar: 'VERCEL_ADAPTER_TEST_TOKEN',
token: ADAPTER_TEST_TOKEN, token: ADAPTER_TEST_TOKEN,
// The cache-components deploy job in build_and_test.yml deploys into its
// own project so its revalidations cannot interfere with the plain
// deploy job's suites.
extraProjects: ['vtest314-e2e-tests-cache-components'],
}, },
{ {
teamEnvVar: 'VERCEL_TURBOPACK_TEST_TEAM', teamEnvVar: 'VERCEL_TURBOPACK_TEST_TEAM',
teamId: TURBOPACK_TEST_TEAM_NAME, teamId: TURBOPACK_TEST_TEAM_NAME,
tokenEnvVar: 'VERCEL_TURBOPACK_TEST_TOKEN', tokenEnvVar: 'VERCEL_TURBOPACK_TEST_TOKEN',
token: TURBOPACK_TEST_TOKEN, token: TURBOPACK_TEST_TOKEN,
extraProjects: [],
}, },
] ]
...@@ -42,22 +48,30 @@ async function main() { ...@@ -42,22 +48,30 @@ async function main() {
// Keep going after a failure so that one misconfigured or unreachable team // Keep going after a failure so that one misconfigured or unreachable team
// does not stop the others from being reset. `resetProject` rejects an absent // does not stop the others from being reset. `resetProject` rejects an absent
// teamId or token itself, so this only has to say which variables to check. // teamId or token itself, so this only has to say which variables to check.
for (const { teamEnvVar, teamId, tokenEnvVar, token } of TEST_TEAMS) { for (const {
try { teamEnvVar,
await resetProject({ teamId,
projectName: TEST_PROJECT_NAME, tokenEnvVar,
teamId, token,
token, extraProjects,
disableDeploymentProtection: true, } of TEST_TEAMS) {
}) for (const projectName of [TEST_PROJECT_NAME, ...extraProjects]) {
} catch (err) { try {
console.error( await resetProject({
new Error( projectName,
`Failed to reset the ${TEST_PROJECT_NAME} project for ${teamEnvVar}. Verify that ${teamEnvVar} and ${tokenEnvVar} are set correctly.`, teamId,
{ cause: err } token,
disableDeploymentProtection: true,
})
} catch (err) {
console.error(
new Error(
`Failed to reset the ${projectName} project for ${teamEnvVar}. Verify that ${teamEnvVar} and ${tokenEnvVar} are set correctly.`,
{ cause: err }
)
) )
) hadFailure = true
hadFailure = true }
} }
} }
......
# Test review instructions # Test review instructions
- During code review, flag any change that newly disables, skips, or omits deploy-mode tests or assertions, including `skipDeployment: true` and `isNextDeploy` conditionals. Only allow this when the assertion is inherently specific to self-hosted behavior; even then, prefer an explicit deploy-mode assertion that documents the different deployed semantics. - During code review, flag any change that newly disables, skips, or omits deploy-mode tests or assertions, including `skipDeployment: true` and `isNextDeploy` conditionals. Only allow this when the assertion is inherently specific to self-hosted behavior; even then, prefer an explicit deploy-mode assertion that documents the different deployed semantics.
- During code review, flag any new hardcoded cache tag or any `revalidatePath('/')` (including `('/', 'layout')`) in a deploy-active fixture. Revalidation invalidates at Vercel project scope and every deploy suite shares one project per matrix dimension, so suites using the same tag or path purge each other's cache. Tags (`cacheTag`/`revalidateTag`/`updateTag`/`next.tags`) get a suite-slug prefix, e.g. `app-static:thankyounext`. Paths must name a real route, so a fixture that needs to revalidate `/` moves its page to a suite-unique route first (see `parallel-routes-revalidation`'s `/prr`). A revalidation route handler that takes the tag/path from a request parameter is fine as long as the values the tests pass are suite-unique.
- During code review, flag any fetch URL a fixture shares with another fixture when a test depends on the cached value. Fetch cache entries are keyed by URL across deployments, so two fixtures fetching the same URL share one entry, and either fixture's writes or revalidations change the value the other sees. Give the data endpoint suite-unique query params, e.g. `api/random?app-static-page` instead of `api/random?page`.
...@@ -69,8 +69,7 @@ ...@@ -69,8 +69,7 @@
}, },
"test/e2e/app-dir/app-static/app-static.test.ts": { "test/e2e/app-dir/app-static/app-static.test.ts": {
"failed": [ "failed": [
"app-dir static/dynamic handling new tags have been specified on subsequent fetch should not fetch from memory cache", "app-dir static/dynamic handling new tags have been specified on subsequent fetch should not fetch from memory cache"
"app-dir static/dynamic handling new tags have been specified on subsequent fetch should not fetch from memory cache after revalidateTag is used"
] ]
}, },
"test/e2e/app-dir/metadata/metadata.test.ts": { "test/e2e/app-dir/metadata/metadata.test.ts": {
......
...@@ -16,7 +16,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -16,7 +16,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
options?: { allowErrorStatusCodes: number[] } options?: { allowErrorStatusCodes: number[] }
) { ) {
let page: Playwright.Page let page: Playwright.Page
const browser = await next.browser('/', { const browser = await next.browser('/adr', {
beforePageLoad(p: Playwright.Page) { beforePageLoad(p: Playwright.Page) {
page = p page = p
}, },
...@@ -67,8 +67,8 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -67,8 +67,8 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
// If B ran too early, it saw the pre-navigation page — but that is not // If B ran too early, it saw the pre-navigation page — but that is not
// necessarily visible yet. Running one more action makes it visible: // necessarily visible yet. Running one more action makes it visible:
// with the bug, the URL flips back to "/" here instead of staying // with the bug, the URL flips back to "/adr" here instead of staying
// on /dest. // on /adr/dest.
await act( await act(
async () => { async () => {
await browser.elementById('dispatch-c').click() await browser.elementById('dispatch-c').click()
...@@ -77,7 +77,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -77,7 +77,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
) )
await browser.waitForElementByCss('#status-c[data-status="c-result"]') await browser.waitForElementByCss('#status-c[data-status="c-result"]')
expect(new URL(await browser.url()).pathname).toBe('/dest') expect(new URL(await browser.url()).pathname).toBe('/adr/dest')
expect(await browser.elementById('dest').text()).toBe('Destination page') expect(await browser.elementById('dest').text()).toBe('Destination page')
return { browser, initialRender } return { browser, initialRender }
...@@ -113,7 +113,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -113,7 +113,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
// entirely — the URL never even changed to the navigation target.) // entirely — the URL never even changed to the navigation target.)
it('runs an action dispatched during the navigation once it finishes', async () => { it('runs an action dispatched during the navigation once it finishes', async () => {
let page: Playwright.Page let page: Playwright.Page
const browser = await next.browser('/', { const browser = await next.browser('/adr', {
beforePageLoad(p: Playwright.Page) { beforePageLoad(p: Playwright.Page) {
page = p page = p
}, },
...@@ -149,7 +149,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -149,7 +149,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
) )
await browser.waitForElementByCss('#status-b[data-status="b-result"]') await browser.waitForElementByCss('#status-b[data-status="b-result"]')
expect(new URL(await browser.url()).pathname).toBe('/dest') expect(new URL(await browser.url()).pathname).toBe('/adr/dest')
expect(await browser.elementById('dest').text()).toBe('Destination page') expect(await browser.elementById('dest').text()).toBe('Destination page')
}) })
...@@ -159,7 +159,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -159,7 +159,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
// further interaction. // further interaction.
it('renders the state produced by an action that settles after the navigation', async () => { it('renders the state produced by an action that settles after the navigation', async () => {
let page: Playwright.Page let page: Playwright.Page
const browser = await next.browser('/', { const browser = await next.browser('/adr', {
beforePageLoad(p: Playwright.Page) { beforePageLoad(p: Playwright.Page) {
page = p page = p
}, },
...@@ -202,7 +202,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -202,7 +202,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
await browser.waitForElementByCss( await browser.waitForElementByCss(
`#stamp:not([data-render="${initialRender}"])` `#stamp:not([data-render="${initialRender}"])`
) )
expect(new URL(await browser.url()).pathname).toBe('/dest') expect(new URL(await browser.url()).pathname).toBe('/adr/dest')
expect(await browser.elementById('dest').text()).toBe('Destination page') expect(await browser.elementById('dest').text()).toBe('Destination page')
}) })
...@@ -214,7 +214,7 @@ describe('discarded action settling while a navigation is pending (#86151)', () ...@@ -214,7 +214,7 @@ describe('discarded action settling while a navigation is pending (#86151)', ()
await browser.waitForElementByCss( await browser.waitForElementByCss(
`#stamp:not([data-render="${initialRender}"])` `#stamp:not([data-render="${initialRender}"])`
) )
expect(new URL(await browser.url()).pathname).toBe('/dest') expect(new URL(await browser.url()).pathname).toBe('/adr/dest')
expect(await browser.elementById('dest').text()).toBe('Destination page') expect(await browser.elementById('dest').text()).toBe('Destination page')
}) })
}) })
...@@ -11,6 +11,6 @@ export async function reject() { ...@@ -11,6 +11,6 @@ export async function reject() {
} }
export async function revalidate() { export async function revalidate() {
revalidatePath('/', 'layout') revalidatePath('/adr', 'layout')
return 'revalidated' return 'revalidated'
} }
...@@ -83,7 +83,7 @@ export function Controls() { ...@@ -83,7 +83,7 @@ export function Controls() {
<button id="dispatch-b-revalidate" onClick={dispatchBRevalidate}> <button id="dispatch-b-revalidate" onClick={dispatchBRevalidate}>
dispatch revalidating queued action dispatch revalidating queued action
</button> </button>
<button id="go-dest" onClick={() => router.push('/dest')}> <button id="go-dest" onClick={() => router.push('/adr/dest')}>
go to destination go to destination
</button> </button>
<button id="dispatch-c" onClick={dispatchC}> <button id="dispatch-c" onClick={dispatchC}>
......
// increment to trigger deploy tests: v1
process.env.TEST_NODE_MIDDLEWARE = 'true' process.env.TEST_NODE_MIDDLEWARE = 'true'
require('./app-action.test') require('./app-action.test')
...@@ -13,6 +13,7 @@ import { join } from 'node:path' ...@@ -13,6 +13,7 @@ import { join } from 'node:path'
const GENERIC_RSC_ERROR = const GENERIC_RSC_ERROR =
'Error: Minified React error #441; visit https://react.dev/errors/441 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.' 'Error: Minified React error #441; visit https://react.dev/errors/441 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.'
// increment to trigger deploy tests: v1
describe('app-dir action handling', () => { describe('app-dir action handling', () => {
const { next, isNextDev, isNextStart, isNextDeploy, isTurbopack } = const { next, isNextDev, isNextStart, isNextDeploy, isTurbopack } =
nextTestSetup({ nextTestSetup({
......
...@@ -5,9 +5,9 @@ import Link from 'next/link' ...@@ -5,9 +5,9 @@ import Link from 'next/link'
export default async function Page() { export default async function Page() {
const randomCookie = (await cookies()).get('random') const randomCookie = (await cookies()).get('random')
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page', 'https://next-data-api-endpoint.vercel.app/api/random?actions-page',
{ {
next: { revalidate: 3600, tags: ['thankyounext'] }, next: { revalidate: 3600, tags: ['actions:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -19,14 +19,15 @@ export default async function Page() { ...@@ -19,14 +19,15 @@ export default async function Page() {
</Link> </Link>
<p> <p>
{' '} {' '}
revalidate (tags: thankyounext): <span id="thankyounext">{data}</span> revalidate (tags: actions:thankyounext):{' '}
<span id="thankyounext">{data}</span>
</p> </p>
<form> <form>
<button <button
id="revalidate-tag" id="revalidate-tag"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('thankyounext') updateTag('actions:thankyounext')
}} }}
> >
revalidate thankyounext revalidate thankyounext
......
...@@ -2,16 +2,16 @@ import { updateTag } from 'next/cache' ...@@ -2,16 +2,16 @@ import { updateTag } from 'next/cache'
export default async function Page() { export default async function Page() {
const data1 = await fetch( const data1 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?a', 'https://next-data-api-endpoint.vercel.app/api/random?actions-a',
{ {
next: { tags: ['thankyounext'] }, next: { tags: ['actions:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
const data2 = await fetch( const data2 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b', 'https://next-data-api-endpoint.vercel.app/api/random?actions-b',
{ {
next: { tags: ['justputit'] }, next: { tags: ['actions:justputit'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -19,18 +19,20 @@ export default async function Page() { ...@@ -19,18 +19,20 @@ export default async function Page() {
<> <>
<h1 id="title">another route</h1> <h1 id="title">another route</h1>
<p> <p>
revalidate (tags: thankyounext): <span id="thankyounext">{data1}</span> revalidate (tags: actions:thankyounext):{' '}
<span id="thankyounext">{data1}</span>
</p> </p>
<p> <p>
revalidate (tags: justputit): <span id="justputit">{data2}</span> revalidate (tags: actions:justputit):{' '}
<span id="justputit">{data2}</span>
</p> </p>
<form> <form>
<button <button
id="revalidate" id="revalidate"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('thankyounext') updateTag('actions:thankyounext')
updateTag('justputit') updateTag('actions:justputit')
}} }}
> >
revalidate thankyounext revalidate thankyounext
......
...@@ -8,16 +8,19 @@ import RedirectClientComponent from './client' ...@@ -8,16 +8,19 @@ import RedirectClientComponent from './client'
export default async function Page() { export default async function Page() {
const cookie = (await cookies()).get('random') const cookie = (await cookies()).get('random')
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page', 'https://next-data-api-endpoint.vercel.app/api/random?actions-page',
{ {
next: { revalidate: 3600, tags: ['thankyounext'] }, next: { revalidate: 3600, tags: ['actions:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
const data2 = await fetch( const data2 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?a=b', 'https://next-data-api-endpoint.vercel.app/api/random?actions-a=b',
{ {
next: { revalidate: 3600, tags: ['thankyounext', 'justputit'] }, next: {
revalidate: 3600,
tags: ['actions:thankyounext', 'actions:justputit'],
},
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -26,9 +29,8 @@ export default async function Page() { ...@@ -26,9 +29,8 @@ export default async function Page() {
<h1 id="title">revalidate</h1> <h1 id="title">revalidate</h1>
<p> <p>
{' '} {' '}
revalidate (tags: thankyounext): <span id="thankyounext"> revalidate (tags: actions:thankyounext):{' '}
{data} <span id="thankyounext">{data}</span>{' '}
</span>{' '}
<span> <span>
<Link href="/revalidate-2" id="another"> <Link href="/revalidate-2" id="another">
/revalidate-2 /revalidate-2
...@@ -36,7 +38,7 @@ export default async function Page() { ...@@ -36,7 +38,7 @@ export default async function Page() {
</span> </span>
</p> </p>
<p> <p>
revalidate (tags: thankyounext, justputit):{' '} revalidate (tags: actions:thankyounext, actions:justputit):{' '}
<span id="justputit">{data2}</span> <span id="justputit">{data2}</span>
</p> </p>
<p> <p>
...@@ -59,7 +61,7 @@ export default async function Page() { ...@@ -59,7 +61,7 @@ export default async function Page() {
id="revalidate-thankyounext" id="revalidate-thankyounext"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('thankyounext') updateTag('actions:thankyounext')
}} }}
> >
revalidate thankyounext revalidate thankyounext
...@@ -70,7 +72,7 @@ export default async function Page() { ...@@ -70,7 +72,7 @@ export default async function Page() {
id="revalidate-justputit" id="revalidate-justputit"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('justputit') updateTag('actions:justputit')
}} }}
> >
revalidate justputit revalidate justputit
...@@ -92,7 +94,7 @@ export default async function Page() { ...@@ -92,7 +94,7 @@ export default async function Page() {
id="revalidate-path-redirect" id="revalidate-path-redirect"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('justputit') updateTag('actions:justputit')
redirect('/revalidate') redirect('/revalidate')
}} }}
> >
...@@ -115,7 +117,7 @@ export default async function Page() { ...@@ -115,7 +117,7 @@ export default async function Page() {
id="redirect-revalidate" id="redirect-revalidate"
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('justputit') updateTag('actions:justputit')
redirect('/revalidate?foo=bar') redirect('/revalidate?foo=bar')
}} }}
> >
...@@ -125,7 +127,7 @@ export default async function Page() { ...@@ -125,7 +127,7 @@ export default async function Page() {
<RedirectClientComponent <RedirectClientComponent
action={async () => { action={async () => {
'use server' 'use server'
updateTag('justputit') updateTag('actions:justputit')
}} }}
/> />
</> </>
......
...@@ -15,6 +15,7 @@ import stripAnsi from 'strip-ansi' ...@@ -15,6 +15,7 @@ import stripAnsi from 'strip-ansi'
const glob = promisify(globOrig) const glob = promisify(globOrig)
// increment to trigger deploy tests: v1
describe('app-dir static/dynamic handling', () => { describe('app-dir static/dynamic handling', () => {
const { next, isNextDev, isNextStart, isNextDeploy, isTurbopack } = const { next, isNextDev, isNextStart, isNextDeploy, isTurbopack } =
nextTestSetup({ nextTestSetup({
...@@ -172,7 +173,7 @@ describe('app-dir static/dynamic handling', () => { ...@@ -172,7 +173,7 @@ describe('app-dir static/dynamic handling', () => {
expect(res1.status).toBe(200) expect(res1.status).toBe(200)
const revalidateRes = await next.fetch( const revalidateRes = await next.fetch(
'/api/revalidate-tag-node?tag=thankyounext' '/api/revalidate-tag-node?tag=app-static:thankyounext'
) )
expect((await revalidateRes.json()).revalidated).toBe(true) expect((await revalidateRes.json()).revalidated).toBe(true)
...@@ -553,7 +554,7 @@ describe('app-dir static/dynamic handling', () => { ...@@ -553,7 +554,7 @@ describe('app-dir static/dynamic handling', () => {
await check(async () => { await check(async () => {
const revalidateRes = await next.fetch( const revalidateRes = await next.fetch(
`${revalidateApi}?tag=thankyounext` `${revalidateApi}?tag=app-static:thankyounext`
) )
expect((await revalidateRes.json()).revalidated).toBe(true) expect((await revalidateRes.json()).revalidated).toBe(true)
...@@ -610,8 +611,8 @@ describe('app-dir static/dynamic handling', () => { ...@@ -610,8 +611,8 @@ describe('app-dir static/dynamic handling', () => {
if (prevData) { if (prevData) {
expect(prevData).toBe(data) expect(prevData).toBe(data)
prevData = data
} }
prevData = data
await waitFor(500) await waitFor(500)
} }
...@@ -622,6 +623,32 @@ describe('app-dir static/dynamic handling', () => { ...@@ -622,6 +623,32 @@ describe('app-dir static/dynamic handling', () => {
} }
}) })
if (isNextDeploy) {
// Deploy fixtures share one Vercel project, and revalidation is
// project-scoped: another suite revalidating `/` purges this
// deployment's `/` as well, so the test above can observe foreign
// purges. Assert persistence on a suite-unique route too, which no
// other suite's revalidation targets.
it('should not revalidate suite-unique routes when revalidate is not used', async () => {
let prevData
for (let i = 0; i < 5; i++) {
const res = await next.fetch('/variable-revalidate/revalidate-360')
const html = await res.text()
const $ = cheerio.load(html)
const data = $('#page-data').text()
expect(res.status).toBe(200)
if (prevData) {
expect(prevData).toBe(data)
}
prevData = data
await waitFor(500)
}
})
}
it.each([ it.each([
{ {
type: 'edge route handler', type: 'edge route handler',
...@@ -2577,7 +2604,7 @@ describe('app-dir static/dynamic handling', () => { ...@@ -2577,7 +2604,7 @@ describe('app-dir static/dynamic handling', () => {
"initialExpireSeconds": 31536000, "initialExpireSeconds": 31536000,
"initialHeaders": { "initialHeaders": {
"content-type": "application/json", "content-type": "application/json",
"x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/revalidate-360-isr/layout,_N_T_/route-handler/revalidate-360-isr/route,_N_T_/route-handler/revalidate-360-isr,thankyounext", "x-next-cache-tags": "_N_T_/layout,_N_T_/route-handler/layout,_N_T_/route-handler/revalidate-360-isr/layout,_N_T_/route-handler/revalidate-360-isr/route,_N_T_/route-handler/revalidate-360-isr,app-static:thankyounext",
}, },
"initialRevalidateSeconds": 10, "initialRevalidateSeconds": 10,
"response": "complete", "response": "complete",
...@@ -3476,7 +3503,7 @@ describe('app-dir static/dynamic handling', () => { ...@@ -3476,7 +3503,7 @@ describe('app-dir static/dynamic handling', () => {
expect(indexFetchMetrics).toHaveLength(1) expect(indexFetchMetrics).toHaveLength(1)
expect(indexFetchMetrics[0]).toMatchObject({ expect(indexFetchMetrics[0]).toMatchObject({
url: 'https://next-data-api-endpoint.vercel.app/api/random?page', url: 'https://next-data-api-endpoint.vercel.app/api/random?app-static-page',
status: 200, status: 200,
cacheStatus: expect.any(String), cacheStatus: expect.any(String),
start: expect.any(Number), start: expect.any(Number),
...@@ -5036,14 +5063,24 @@ describe('app-dir static/dynamic handling', () => { ...@@ -5036,14 +5063,24 @@ describe('app-dir static/dynamic handling', () => {
describe('unstable_cache', () => { describe('unstable_cache', () => {
it('should retrieve the same value on second request', async () => { it('should retrieve the same value on second request', async () => {
const res = await next.fetch('/unstable-cache/dynamic') async function fetchCachedData() {
const html = await res.text() const res = await next.fetch('/unstable-cache/dynamic')
const data = cheerio.load(html)('#cached-data').text() return cheerio
const res2 = await next.fetch('/unstable-cache/dynamic') .load(await res.text())('#cached-data')
const html2 = await res2.text() .text()
const data2 = cheerio.load(html2)('#cached-data').text() }
expect(data).toEqual(data2) if (isNextDeploy) {
// The shared Data Cache is eventually consistent across lambda
// instances: a request can land before another instance's write is
// visible and recompute. Poll until two consecutive reads agree,
// which is the consistency the deployed cache provides.
await retry(async () => {
expect(await fetchCachedData()).toEqual(await fetchCachedData())
})
} else {
expect(await fetchCachedData()).toEqual(await fetchCachedData())
}
}) })
it('should bypass cache in draft mode', async () => { it('should bypass cache in draft mode', async () => {
......
...@@ -4,7 +4,7 @@ export default async function Page() { ...@@ -4,7 +4,7 @@ export default async function Page() {
console.log('rendering index') console.log('rendering index')
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page' 'https://next-data-api-endpoint.vercel.app/api/random?app-static-page'
).then((res) => res.text()) ).then((res) => res.text())
return ( return (
......
...@@ -9,7 +9,7 @@ export async function GET() { ...@@ -9,7 +9,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 360, revalidate: 360,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -19,7 +19,7 @@ export async function GET() { ...@@ -19,7 +19,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 10, revalidate: 10,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
......
...@@ -8,7 +8,7 @@ export async function GET() { ...@@ -8,7 +8,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 360, revalidate: 360,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -18,7 +18,7 @@ export async function GET() { ...@@ -18,7 +18,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 10, revalidate: 10,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
......
...@@ -8,7 +8,7 @@ export async function GET() { ...@@ -8,7 +8,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 360, revalidate: 360,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -18,7 +18,7 @@ export async function GET() { ...@@ -18,7 +18,7 @@ export async function GET() {
{ {
next: { next: {
revalidate: 10, revalidate: 10,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
}, },
} }
).then((res) => res.text()) ).then((res) => res.text())
......
...@@ -5,7 +5,7 @@ export default async function Page() { ...@@ -5,7 +5,7 @@ export default async function Page() {
'https://next-data-api-endpoint.vercel.app/api/random?sam=iam', 'https://next-data-api-endpoint.vercel.app/api/random?sam=iam',
{ {
cache: 'force-cache', cache: 'force-cache',
next: { tags: ['thankyounext'] }, next: { tags: ['app-static:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
......
...@@ -5,7 +5,7 @@ export default async function Page() { ...@@ -5,7 +5,7 @@ export default async function Page() {
'https://next-data-api-endpoint.vercel.app/api/random?sam=iam', 'https://next-data-api-endpoint.vercel.app/api/random?sam=iam',
{ {
cache: 'force-cache', cache: 'force-cache',
next: { tags: ['thankyounext', 'justputit'] }, next: { tags: ['app-static:thankyounext', 'app-static:justputit'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
......
...@@ -3,7 +3,7 @@ import { cache, use } from 'react' ...@@ -3,7 +3,7 @@ import { cache, use } from 'react'
export default function Layout({ children }) { export default function Layout({ children }) {
const getData = cache(() => const getData = cache(() =>
fetch('https://next-data-api-endpoint.vercel.app/api/random?layout', { fetch('https://next-data-api-endpoint.vercel.app/api/random?layout', {
next: { revalidate: 10, tags: ['thankyounext'] }, next: { revalidate: 10, tags: ['app-static:thankyounext'] },
}).then((res) => res.text()) }).then((res) => res.text())
) )
const dataPromise = getData() const dataPromise = getData()
......
...@@ -2,16 +2,19 @@ import { unstable_cache } from 'next/cache' ...@@ -2,16 +2,19 @@ import { unstable_cache } from 'next/cache'
export default async function Page() { export default async function Page() {
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page', 'https://next-data-api-endpoint.vercel.app/api/random?app-static-page',
{ {
next: { revalidate: 360, tags: ['thankyounext'] }, next: { revalidate: 360, tags: ['app-static:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
const data2 = await fetch( const data2 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?a=b', 'https://next-data-api-endpoint.vercel.app/api/random?app-static-a=b',
{ {
next: { revalidate: 360, tags: ['thankyounext', 'justputit'] }, next: {
revalidate: 360,
tags: ['app-static:thankyounext', 'app-static:justputit'],
},
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -28,7 +31,7 @@ export default async function Page() { ...@@ -28,7 +31,7 @@ export default async function Page() {
}, },
['random'], ['random'],
{ {
tags: ['thankyounext', 'unstable_cache_tag1'], tags: ['app-static:thankyounext', 'unstable_cache_tag1'],
revalidate: 10, revalidate: 10,
} }
)() )()
...@@ -36,12 +39,16 @@ export default async function Page() { ...@@ -36,12 +39,16 @@ export default async function Page() {
return ( return (
<> <>
<p id="page">/variable-revalidate/revalidate-360</p> <p id="page">/variable-revalidate/revalidate-360</p>
<p id="page-data">revalidate 360 (tags: thankyounext): {data}</p> <p id="page-data">
revalidate 360 (tags: app-static:thankyounext): {data}
</p>
<p id="page-data2"> <p id="page-data2">
revalidate 360 (tags: thankyounext, justputit): {data2} revalidate 360 (tags: app-static:thankyounext, app-static:justputit):{' '}
{data2}
</p> </p>
<p id="page-data3"> <p id="page-data3">
revalidate 10 (tags: thankyounext): {JSON.stringify(cachedData)} revalidate 10 (tags: app-static:thankyounext):{' '}
{JSON.stringify(cachedData)}
</p> </p>
<p id="now">{Date.now()}</p> <p id="now">{Date.now()}</p>
</> </>
......
...@@ -4,16 +4,19 @@ export const revalidate = 0 ...@@ -4,16 +4,19 @@ export const revalidate = 0
export default async function Page() { export default async function Page() {
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?page', 'https://next-data-api-endpoint.vercel.app/api/random?app-static-page',
{ {
next: { revalidate: 360, tags: ['thankyounext'] }, next: { revalidate: 360, tags: ['app-static:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
const data2 = await fetch( const data2 = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?a=b', 'https://next-data-api-endpoint.vercel.app/api/random?app-static-a=b',
{ {
next: { revalidate: 360, tags: ['thankyounext', 'justputit'] }, next: {
revalidate: 360,
tags: ['app-static:thankyounext', 'app-static:justputit'],
},
} }
).then((res) => res.text()) ).then((res) => res.text())
...@@ -49,7 +52,7 @@ export default async function Page() { ...@@ -49,7 +52,7 @@ export default async function Page() {
}, },
['random'], ['random'],
{ {
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
revalidate: 10, revalidate: 10,
} }
)() )()
...@@ -60,7 +63,7 @@ export default async function Page() { ...@@ -60,7 +63,7 @@ export default async function Page() {
const data = await fetch( const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?something', 'https://next-data-api-endpoint.vercel.app/api/random?something',
{ {
next: { revalidate: 15, tags: ['thankyounext'] }, next: { revalidate: 15, tags: ['app-static:thankyounext'] },
} }
).then((res) => res.text()) ).then((res) => res.text())
return data return data
...@@ -77,19 +80,23 @@ export default async function Page() { ...@@ -77,19 +80,23 @@ export default async function Page() {
[], [],
{ {
revalidate: 1000, revalidate: 1000,
tags: ['thankyounext'], tags: ['app-static:thankyounext'],
} }
)() )()
return ( return (
<> <>
<p id="page">/variable-revalidate/revalidate-360</p> <p id="page">/variable-revalidate/revalidate-360</p>
<p id="page-data">revalidate 360 (tags: thankyounext): {data}</p> <p id="page-data">
revalidate 360 (tags: app-static:thankyounext): {data}
</p>
<p id="page-data2"> <p id="page-data2">
revalidate 360 (tags: thankyounext, justputit): {data2} revalidate 360 (tags: app-static:thankyounext, app-static:justputit):{' '}
{data2}
</p> </p>
<p id="page-data3"> <p id="page-data3">
revalidate 10 (tags: thankyounext): {JSON.stringify(cachedData)} revalidate 10 (tags: app-static:thankyounext):{' '}
{JSON.stringify(cachedData)}
</p> </p>
<p id="now">{Date.now()}</p> <p id="now">{Date.now()}</p>
<p id="nested-cache">nested cache: {cacheOuter}</p> <p id="nested-cache">nested cache: {cacheOuter}</p>
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
import { revalidatePath } from 'next/cache' import { revalidatePath } from 'next/cache'
export async function action() { export async function action() {
revalidatePath('/', 'layout') revalidatePath('/popstate-revalidate', 'layout')
return true return true
} }
import React from 'react' import React from 'react'
export default function Root({ export default function Root({ children }: { children: React.ReactNode }) {
children,
dialog,
interception,
}: {
children: React.ReactNode
dialog: React.ReactNode
interception: React.ReactNode
}) {
return ( return (
<html> <html>
<head> <head>
<script src="https://cdn.tailwindcss.com?plugins=typography"></script> <script src="https://cdn.tailwindcss.com?plugins=typography"></script>
</head> </head>
<body> <body>{children}</body>
{children}
{dialog}
{interception}
</body>
</html> </html>
) )
} }
...@@ -15,7 +15,7 @@ export default function Page() { ...@@ -15,7 +15,7 @@ export default function Page() {
<button onClick={() => router.refresh()} id="refresh-router"> <button onClick={() => router.refresh()} id="refresh-router">
Refresh Router Refresh Router
</button> </button>
<Link href="/">Close</Link> <Link href="/prr">Close</Link>
</dialog> </dialog>
) )
} }
...@@ -9,7 +9,7 @@ export default function Page() { ...@@ -9,7 +9,7 @@ export default function Page() {
await addData(new Date().toISOString()) await addData(new Date().toISOString())
revalidatePath('/', 'layout') revalidatePath('/prr', 'layout')
} }
return ( return (
...@@ -24,7 +24,7 @@ export default function Page() { ...@@ -24,7 +24,7 @@ export default function Page() {
</button> </button>
</form> </form>
<Link href="/">Close</Link> <Link href="/prr">Close</Link>
</dialog> </dialog>
) )
} }
...@@ -20,10 +20,10 @@ export async function redirectAction() { ...@@ -20,10 +20,10 @@ export async function redirectAction() {
'use server' 'use server'
console.log('redirecting...') console.log('redirecting...')
await new Promise((res) => setTimeout(res, 1000)) await new Promise((res) => setTimeout(res, 1000))
redirect('/') redirect('/prr')
} }
export async function clearData() { export async function clearData() {
data = [] data = []
revalidatePath('/') revalidatePath('/prr')
} }
...@@ -3,7 +3,7 @@ import Link from 'next/link' ...@@ -3,7 +3,7 @@ import Link from 'next/link'
export default function Page() { export default function Page() {
return ( return (
<div> <div>
<Link href="/catchall/foobar">Dynamic Catchall Interception</Link> <Link href="/prr/catchall/foobar">Dynamic Catchall Interception</Link>
</div> </div>
) )
} }
...@@ -13,7 +13,7 @@ export default function Layout({ ...@@ -13,7 +13,7 @@ export default function Layout({
<div> <div>
<div>{children}</div> <div>{children}</div>
<div>{modal}</div> <div>{modal}</div>
<Link href="/dynamic-refresh/foo/other">Go to Other Page</Link> <Link href="/prr/dynamic-refresh/foo/other">Go to Other Page</Link>
</div> </div>
) )
} }
...@@ -5,7 +5,7 @@ export default async function Home(props) { ...@@ -5,7 +5,7 @@ export default async function Home(props) {
const searchParams = await props.searchParams const searchParams = await props.searchParams
return ( return (
<main> <main>
<Link href="/dynamic-refresh/foo/login"> <Link href="/prr/dynamic-refresh/foo/login">
<button>Login button</button> <button>Login button</button>
</Link> </Link>
<div> <div>
......
...@@ -3,7 +3,7 @@ import Link from 'next/link' ...@@ -3,7 +3,7 @@ import Link from 'next/link'
export default function Page() { export default function Page() {
return ( return (
<div> <div>
<Link href="/dynamic/foobar">Dynamic Interception</Link> <Link href="/prr/dynamic/foobar">Dynamic Interception</Link>
</div> </div>
) )
} }
import React from 'react'
export default function PRRLayout({
children,
dialog,
interception,
}: {
children: React.ReactNode
dialog: React.ReactNode
interception: React.ReactNode
}) {
return (
<>
{children}
{dialog}
{interception}
</>
)
}
...@@ -34,7 +34,7 @@ export default function Page() { ...@@ -34,7 +34,7 @@ export default function Page() {
<p className="mt-4">Drawer</p> <p className="mt-4">Drawer</p>
<div className="mt-4 flex flex-col gap-2"> <div className="mt-4 flex flex-col gap-2">
<Link <Link
href="/nested-revalidate/modal" href="/prr/nested-revalidate/modal"
className="bg-sky-600 text-white p-2 rounded" className="bg-sky-600 text-white p-2 rounded"
> >
Open modal Open modal
......
...@@ -4,7 +4,7 @@ import { revalidatePath } from 'next/cache' ...@@ -4,7 +4,7 @@ import { revalidatePath } from 'next/cache'
export async function revalidateAction() { export async function revalidateAction() {
console.log('revalidate action') console.log('revalidate action')
revalidatePath('/') revalidatePath('/prr/nested-revalidate')
return { return {
success: true, success: true,
} }
......
...@@ -7,13 +7,13 @@ export default function Home() { ...@@ -7,13 +7,13 @@ export default function Home() {
<p id="page-now">Date.now {Date.now()}</p> <p id="page-now">Date.now {Date.now()}</p>
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<Link <Link
href="/nested-revalidate/drawer" href="/prr/nested-revalidate/drawer"
className="bg-sky-600 text-white p-2 rounded" className="bg-sky-600 text-white p-2 rounded"
> >
Open Drawer Open Drawer
</Link> </Link>
<Link <Link
href="/nested-revalidate/modal" href="/prr/nested-revalidate/modal"
className="bg-sky-600 text-white p-2 rounded" className="bg-sky-600 text-white p-2 rounded"
> >
Open Modal Open Modal
......
...@@ -9,10 +9,10 @@ export default async function Home() { ...@@ -9,10 +9,10 @@ export default async function Home() {
return ( return (
<div id="root-page"> <div id="root-page">
<Link href="/revalidate-modal">Open Revalidate Modal</Link> <Link href="/prr/revalidate-modal">Open Revalidate Modal</Link>
<Link href="/refresh-modal">Open Refresh Modal</Link> <Link href="/prr/refresh-modal">Open Refresh Modal</Link>
<Link href="/redirect-modal">Open Redirect Modal</Link> <Link href="/prr/redirect-modal">Open Redirect Modal</Link>
<Link href="/detail-page">Intercepted Detail Page</Link> <Link href="/prr/detail-page">Intercepted Detail Page</Link>
<div id="random-number">{randomNumber}</div> <div id="random-number">{randomNumber}</div>
<form action={clearData}> <form action={clearData}>
<button id="clear-entries">Clear Entries</button> <button id="clear-entries">Clear Entries</button>
......
...@@ -5,7 +5,7 @@ export default function Page() { ...@@ -5,7 +5,7 @@ export default function Page() {
<form <form
action={async () => { action={async () => {
'use server' 'use server'
redirect('/') redirect('/prr')
}} }}
> >
<button type="submit" id="redirect-page"> <button type="submit" id="redirect-page">
......
...@@ -13,7 +13,7 @@ export default function Layout({ ...@@ -13,7 +13,7 @@ export default function Layout({
<div> <div>
<div>{children}</div> <div>{children}</div>
<div>{modal}</div> <div>{modal}</div>
<Link href="/refreshing/other">Go to Other Page</Link> <Link href="/prr/refreshing/other">Go to Other Page</Link>
</div> </div>
) )
} }
...@@ -5,7 +5,7 @@ export default async function Home(props) { ...@@ -5,7 +5,7 @@ export default async function Home(props) {
const searchParams = await props.searchParams const searchParams = await props.searchParams
return ( return (
<main> <main>
<Link href="/refreshing/login"> <Link href="/prr/refreshing/login">
<button>Login button</button> <button>Login button</button>
</Link> </Link>
<div> <div>
......
...@@ -11,10 +11,10 @@ export default function Layout({ ...@@ -11,10 +11,10 @@ export default function Layout({
}) { }) {
return ( return (
<> <>
<Link prefetch={false} href="/retained-search/two?value=second"> <Link prefetch={false} href="/prr/retained-search/two?value=second">
Two Two
</Link> </Link>
<Link prefetch={false} href="/retained-search/three?value=third"> <Link prefetch={false} href="/prr/retained-search/three?value=third">
Three Three
</Link> </Link>
<RefreshButton /> <RefreshButton />
......
...@@ -13,13 +13,13 @@ describe('parallel-routes-revalidation', () => { ...@@ -13,13 +13,13 @@ describe('parallel-routes-revalidation', () => {
// this could hit a separate lambda instance that won't share the same reference // this could hit a separate lambda instance that won't share the same reference
if (!isNextDeploy) { if (!isNextDeploy) {
it('should submit the action and revalidate the page data', async () => { it('should submit the action and revalidate the page data', async () => {
const browser = await next.browser('/') const browser = await next.browser('/prr')
await check(() => browser.hasElementByCssSelector('#create-entry'), false) await check(() => browser.hasElementByCssSelector('#create-entry'), false)
// there shouldn't be any data yet // there shouldn't be any data yet
expect((await browser.elementsByCss('#entries li')).length).toBe(0) expect((await browser.elementsByCss('#entries li')).length).toBe(0)
await browser.elementByCss("[href='/revalidate-modal']").click() await browser.elementByCss("[href='/prr/revalidate-modal']").click()
await check(() => browser.hasElementByCssSelector('#create-entry'), true) await check(() => browser.hasElementByCssSelector('#create-entry'), true)
...@@ -37,7 +37,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -37,7 +37,7 @@ describe('parallel-routes-revalidation', () => {
expect((await browser.elementsByCss('#entries li')).length).toBe(2) expect((await browser.elementsByCss('#entries li')).length).toBe(2)
}) })
await browser.elementByCss("[href='/']").click() await browser.elementByCss("[href='/prr']").click()
// following a link back to `/` should close the modal // following a link back to `/` should close the modal
await check(() => browser.hasElementByCssSelector('#create-entry'), false) await check(() => browser.hasElementByCssSelector('#create-entry'), false)
...@@ -47,7 +47,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -47,7 +47,7 @@ describe('parallel-routes-revalidation', () => {
it('refreshes a retained slot using its original URL after multiple navigations', async () => { it('refreshes a retained slot using its original URL after multiple navigations', async () => {
let act: ReturnType<typeof createRouterAct> let act: ReturnType<typeof createRouterAct>
const browser = await next.browser('/retained-search/one?value=first', { const browser = await next.browser('/prr/retained-search/one?value=first', {
beforePageLoad(p: Playwright.Page) { beforePageLoad(p: Playwright.Page) {
act = createRouterAct(p) act = createRouterAct(p)
}, },
...@@ -61,7 +61,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -61,7 +61,7 @@ describe('parallel-routes-revalidation', () => {
]) { ]) {
await act(async () => { await act(async () => {
await browser await browser
.elementByCss(`a[href="/retained-search/${page}?value=${value}"]`) .elementByCss(`a[href="/prr/retained-search/${page}?value=${value}"]`)
.click() .click()
}) })
expect(await browser.elementById('active-page').text()).toBe(page) expect(await browser.elementById('active-page').text()).toBe(page)
...@@ -83,12 +83,12 @@ describe('parallel-routes-revalidation', () => { ...@@ -83,12 +83,12 @@ describe('parallel-routes-revalidation', () => {
}) })
it('should handle router.refresh() when called in a slot', async () => { it('should handle router.refresh() when called in a slot', async () => {
const browser = await next.browser('/') const browser = await next.browser('/prr')
await check(() => browser.hasElementByCssSelector('#refresh-router'), false) await check(() => browser.hasElementByCssSelector('#refresh-router'), false)
const currentRandomNumber = ( const currentRandomNumber = (
await browser.elementById('random-number') await browser.elementById('random-number')
).text() ).text()
await browser.elementByCss("[href='/refresh-modal']").click() await browser.elementByCss("[href='/prr/refresh-modal']").click()
await check(() => browser.hasElementByCssSelector('#refresh-router'), true) await check(() => browser.hasElementByCssSelector('#refresh-router'), true)
await browser.elementById('refresh-router').click() await browser.elementById('refresh-router').click()
...@@ -97,7 +97,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -97,7 +97,7 @@ describe('parallel-routes-revalidation', () => {
return randomNumber !== currentRandomNumber return randomNumber !== currentRandomNumber
}, true) }, true)
await browser.elementByCss("[href='/']").click() await browser.elementByCss("[href='/prr']").click()
// following a link back to `/` should close the modal // following a link back to `/` should close the modal
await check(() => browser.hasElementByCssSelector('#create-entry'), false) await check(() => browser.hasElementByCssSelector('#create-entry'), false)
...@@ -105,9 +105,9 @@ describe('parallel-routes-revalidation', () => { ...@@ -105,9 +105,9 @@ describe('parallel-routes-revalidation', () => {
}) })
it('should handle a redirect action when called in a slot', async () => { it('should handle a redirect action when called in a slot', async () => {
const browser = await next.browser('/') const browser = await next.browser('/prr')
await check(() => browser.hasElementByCssSelector('#redirect'), false) await check(() => browser.hasElementByCssSelector('#redirect'), false)
await browser.elementByCss("[href='/redirect-modal']").click() await browser.elementByCss("[href='/prr/redirect-modal']").click()
await check(() => browser.hasElementByCssSelector('#redirect'), true) await check(() => browser.hasElementByCssSelector('#redirect'), true)
await browser.elementById('redirect').click() await browser.elementById('redirect').click()
...@@ -116,9 +116,9 @@ describe('parallel-routes-revalidation', () => { ...@@ -116,9 +116,9 @@ describe('parallel-routes-revalidation', () => {
}) })
it.each([ it.each([
{ path: '/detail-page' }, { path: '/prr/detail-page' },
{ path: '/dynamic/foobar', param: 'foobar' }, { path: '/prr/dynamic/foobar', param: 'foobar' },
{ path: '/catchall/foobar', param: 'foobar' }, { path: '/prr/catchall/foobar', param: 'foobar' },
])( ])(
'should not trigger interception when calling router.refresh() on an intercepted route ($path)', 'should not trigger interception when calling router.refresh() on an intercepted route ($path)',
async (route) => { async (route) => {
...@@ -160,7 +160,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -160,7 +160,7 @@ describe('parallel-routes-revalidation', () => {
) )
it('should not trigger full page when calling router.refresh() on an intercepted route', async () => { it('should not trigger full page when calling router.refresh() on an intercepted route', async () => {
const browser = await next.browser('/dynamic') const browser = await next.browser('/prr/dynamic')
await browser.elementByCss('a').click() await browser.elementByCss('a').click()
// we soft-navigated to the route, so it should be intercepted // we soft-navigated to the route, so it should be intercepted
...@@ -192,10 +192,10 @@ describe('parallel-routes-revalidation', () => { ...@@ -192,10 +192,10 @@ describe('parallel-routes-revalidation', () => {
}) })
it('should not trigger the intercepted route when lazy-fetching missing data', async () => { it('should not trigger the intercepted route when lazy-fetching missing data', async () => {
const browser = await next.browser('/') const browser = await next.browser('/prr')
// trigger the interception page // trigger the interception page
await browser.elementByCss("[href='/detail-page']").click() await browser.elementByCss("[href='/prr/detail-page']").click()
// we should see the intercepted page // we should see the intercepted page
expect(await browser.elementById('detail-title').text()).toBe( expect(await browser.elementById('detail-title').text()).toBe(
...@@ -230,10 +230,10 @@ describe('parallel-routes-revalidation', () => { ...@@ -230,10 +230,10 @@ describe('parallel-routes-revalidation', () => {
// this could hit a separate lambda instance that won't share the same reference // this could hit a separate lambda instance that won't share the same reference
if (!isNextDeploy) { if (!isNextDeploy) {
it('should refresh the correct page when a server action triggers a redirect', async () => { it('should refresh the correct page when a server action triggers a redirect', async () => {
const browser = await next.browser('/redirect') const browser = await next.browser('/prr/redirect')
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
await browser.elementByCss("[href='/revalidate-modal']").click() await browser.elementByCss("[href='/prr/revalidate-modal']").click()
await check(() => browser.hasElementByCssSelector('#create-entry'), true) await check(() => browser.hasElementByCssSelector('#create-entry'), true)
...@@ -254,15 +254,15 @@ describe('parallel-routes-revalidation', () => { ...@@ -254,15 +254,15 @@ describe('parallel-routes-revalidation', () => {
} }
describe.each([ describe.each([
{ basePath: '/refreshing', label: 'regular', withSearchParams: false }, { basePath: '/prr/refreshing', label: 'regular', withSearchParams: false },
{ basePath: '/refreshing', label: 'regular', withSearchParams: true }, { basePath: '/prr/refreshing', label: 'regular', withSearchParams: true },
{ {
basePath: '/dynamic-refresh/foo', basePath: '/prr/dynamic-refresh/foo',
label: 'dynamic', label: 'dynamic',
withSearchParams: false, withSearchParams: false,
}, },
{ {
basePath: '/dynamic-refresh/foo', basePath: '/prr/dynamic-refresh/foo',
label: 'dynamic', label: 'dynamic',
withSearchParams: true, withSearchParams: true,
}, },
...@@ -420,7 +420,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -420,7 +420,7 @@ describe('parallel-routes-revalidation', () => {
describe('server action revalidation', () => { describe('server action revalidation', () => {
it('handles refreshing when multiple parallel slots are active', async () => { it('handles refreshing when multiple parallel slots are active', async () => {
const browser = await next.browser('/nested-revalidate') const browser = await next.browser('/prr/nested-revalidate')
const currentPageTime = await browser.elementById('page-now').text() const currentPageTime = await browser.elementById('page-now').text()
...@@ -428,11 +428,15 @@ describe('parallel-routes-revalidation', () => { ...@@ -428,11 +428,15 @@ describe('parallel-routes-revalidation', () => {
expect(await browser.hasElementByCssSelector('#drawer')).toBe(false) expect(await browser.hasElementByCssSelector('#drawer')).toBe(false)
// renders the drawer parallel slot // renders the drawer parallel slot
await browser.elementByCss("[href='/nested-revalidate/drawer']").click() await browser
.elementByCss("[href='/prr/nested-revalidate/drawer']")
.click()
await browser.waitForElementByCss('#drawer') await browser.waitForElementByCss('#drawer')
// renders the modal slot // renders the modal slot
await browser.elementByCss("[href='/nested-revalidate/modal']").click() await browser
.elementByCss("[href='/prr/nested-revalidate/modal']")
.click()
await browser.waitForElementByCss('#modal') await browser.waitForElementByCss('#modal')
// Both should be visible, despite only one "matching" // Both should be visible, despite only one "matching"
...@@ -468,7 +472,7 @@ describe('parallel-routes-revalidation', () => { ...@@ -468,7 +472,7 @@ describe('parallel-routes-revalidation', () => {
it.skip('should not trigger a refresh for the page that is being redirected to', async () => { it.skip('should not trigger a refresh for the page that is being redirected to', async () => {
const rscRequests = [] const rscRequests = []
const prefetchRequests = [] const prefetchRequests = []
const browser = await next.browser('/redirect', { const browser = await next.browser('/prr/redirect', {
beforePageLoad(page) { beforePageLoad(page) {
page.on('request', async (req) => { page.on('request', async (req) => {
const headers = await req.allHeaders() const headers = await req.allHeaders()
......
...@@ -6,7 +6,7 @@ export default async function Page() { ...@@ -6,7 +6,7 @@ export default async function Page() {
'https://next-data-api-endpoint.vercel.app/api/random', 'https://next-data-api-endpoint.vercel.app/api/random',
{ {
next: { next: {
tags: ['data'], tags: ['revalidatetag-rsc:data'],
revalidate: false, revalidate: false,
}, },
} }
...@@ -15,8 +15,11 @@ export default async function Page() { ...@@ -15,8 +15,11 @@ export default async function Page() {
return ( return (
<div> <div>
<span id="data">{data}</span> <span id="data">{data}</span>
<RevalidateViaForm tag="data" /> <RevalidateViaForm tag="revalidatetag-rsc:data" />
<Link href="/revalidate_via_page?tag=data" id="revalidate-via-page"> <Link
href="/revalidate_via_page?tag=revalidatetag-rsc:data"
id="revalidate-via-page"
>
Revalidate via page Revalidate via page
</Link> </Link>
<Link href="/revalidate_via_cache" id="revalidate-via-cache"> <Link href="/revalidate_via_cache" id="revalidate-via-cache">
......
...@@ -3,7 +3,7 @@ import { revalidateTag, unstable_cache } from 'next/cache' ...@@ -3,7 +3,7 @@ import { revalidateTag, unstable_cache } from 'next/cache'
export const dynamic = 'force-dynamic' export const dynamic = 'force-dynamic'
const revalidateInCache = unstable_cache(async () => { const revalidateInCache = unstable_cache(async () => {
revalidateTag('data', 'max') revalidateTag('revalidatetag-rsc:data', 'max')
}) })
export default async function Page() { export default async function Page() {
......
...@@ -30,7 +30,7 @@ describe('revalidateTag-rsc', () => { ...@@ -30,7 +30,7 @@ describe('revalidateTag-rsc', () => {
if (isNextDev) { if (isNextDev) {
await waitForRedbox(browser) await waitForRedbox(browser)
await expect(getRedboxHeader(browser)).resolves.toContain( await expect(getRedboxHeader(browser)).resolves.toContain(
'Route "/revalidate_via_page": `revalidateTag("data")` can\'t be called during render.' 'Route "/revalidate_via_page": `revalidateTag("revalidatetag-rsc:data")` can\'t be called during render.'
) )
} else { } else {
await retry(async () => { await retry(async () => {
...@@ -41,7 +41,7 @@ describe('revalidateTag-rsc', () => { ...@@ -41,7 +41,7 @@ describe('revalidateTag-rsc', () => {
} }
expect(next.cliOutput).toContain( expect(next.cliOutput).toContain(
'Route "/revalidate_via_page": `revalidateTag("data")` can\'t be called during render. Call it from a Server Action or Route Handler instead.\nLearn more: https://nextjs.org/docs/messages/revalidate-in-use-cache' 'Route "/revalidate_via_page": `revalidateTag("revalidatetag-rsc:data")` can\'t be called during render. Call it from a Server Action or Route Handler instead.\nLearn more: https://nextjs.org/docs/messages/revalidate-in-use-cache'
) )
}) })
...@@ -52,7 +52,7 @@ describe('revalidateTag-rsc', () => { ...@@ -52,7 +52,7 @@ describe('revalidateTag-rsc', () => {
if (isNextDev) { if (isNextDev) {
await waitForRedbox(browser) await waitForRedbox(browser)
await expect(getRedboxHeader(browser)).resolves.toContain( await expect(getRedboxHeader(browser)).resolves.toContain(
'Route "/revalidate_via_cache": `revalidateTag("data")` can\'t be called inside a cached function.' 'Route "/revalidate_via_cache": `revalidateTag("revalidatetag-rsc:data")` can\'t be called inside a cached function.'
) )
} else { } else {
await retry(async () => { await retry(async () => {
...@@ -63,7 +63,7 @@ describe('revalidateTag-rsc', () => { ...@@ -63,7 +63,7 @@ describe('revalidateTag-rsc', () => {
} }
expect(next.cliOutput).toContain( expect(next.cliOutput).toContain(
'Route "/revalidate_via_cache": `revalidateTag("data")` can\'t be called inside a cached function. Call it from a Server Action or Route Handler instead.\nLearn more: https://nextjs.org/docs/messages/revalidate-in-use-cache' 'Route "/revalidate_via_cache": `revalidateTag("revalidatetag-rsc:data")` can\'t be called inside a cached function. Call it from a Server Action or Route Handler instead.\nLearn more: https://nextjs.org/docs/messages/revalidate-in-use-cache'
) )
}) })
} }
......
...@@ -2,7 +2,8 @@ import { revalidatePath } from 'next/cache' ...@@ -2,7 +2,8 @@ import { revalidatePath } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server' import { NextRequest, NextResponse } from 'next/server'
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
const path = req.nextUrl.searchParams.get('path') || '/' const path =
req.nextUrl.searchParams.get('path') || '/test-on-demand-revalidate'
try { try {
revalidatePath(path) revalidatePath(path)
......
...@@ -9,6 +9,13 @@ type RevalidateMode = ...@@ -9,6 +9,13 @@ type RevalidateMode =
| 'path-team-layout' | 'path-team-layout'
| 'path-team-page' | 'path-team-page'
// The `_N_T_/layout` and `('/', 'layout')` modes exercise root-layout
// revalidation, which is this suite's test subject. When this fixture is
// deployed to a shared Vercel project, these calls purge the root layout of
// every other deployment in the project (revalidation is project-scoped), so
// suites that assert cache persistence on `/` can observe interference from
// this suite. This is a known, accepted blast radius.
function isRevalidateMode(value: string): value is RevalidateMode { function isRevalidateMode(value: string): value is RevalidateMode {
return ( return (
value === 'tag-layout-expireNow' || value === 'tag-layout-expireNow' ||
......
...@@ -2,7 +2,7 @@ import { revalidatePath, revalidateTag } from 'next/cache' ...@@ -2,7 +2,7 @@ import { revalidatePath, revalidateTag } from 'next/cache'
/** Evicts the entry so the prefetch's fill actually runs. */ /** Evicts the entry so the prefetch's fill actually runs. */
export async function POST() { export async function POST() {
revalidateTag('data', { expire: 0 }) revalidateTag('use-cache-after-uncached-io:data', { expire: 0 })
revalidatePath('/uses-cache') revalidatePath('/uses-cache')
return Response.json({ ok: true }) return Response.json({ ok: true })
......
...@@ -28,7 +28,7 @@ async function Late() { ...@@ -28,7 +28,7 @@ async function Late() {
async function getCachedData(): Promise<string> { async function getCachedData(): Promise<string> {
'use cache' 'use cache'
cacheLife('hours') cacheLife('hours')
cacheTag('data') cacheTag('use-cache-after-uncached-io:data')
console.log('running getCachedData') console.log('running getCachedData')
......
...@@ -14,7 +14,7 @@ async function getData() { ...@@ -14,7 +14,7 @@ async function getData() {
'use cache' 'use cache'
cacheLife({ revalidate: 6 }) cacheLife({ revalidate: 6 })
cacheTag('modern') cacheTag('use-cache-custom-handler:modern')
return new Date().toISOString() return new Date().toISOString()
} }
...@@ -39,7 +39,7 @@ export default async function Home() { ...@@ -39,7 +39,7 @@ export default async function Home() {
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('modern') updateTag('use-cache-custom-handler:modern')
}} }}
> >
Revalidate Tag Revalidate Tag
...@@ -59,7 +59,7 @@ export default async function Home() { ...@@ -59,7 +59,7 @@ export default async function Home() {
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('modern') updateTag('use-cache-custom-handler:modern')
redirect('/') redirect('/')
}} }}
> >
...@@ -70,8 +70,8 @@ export default async function Home() { ...@@ -70,8 +70,8 @@ export default async function Home() {
formAction={async () => { formAction={async () => {
'use server' 'use server'
updateTag('modern') updateTag('use-cache-custom-handler:modern')
revalidateTag('other', { expire: 0 }) revalidateTag('use-cache-custom-handler:other', { expire: 0 })
}} }}
> >
Revalidate Tags With Different Profiles Revalidate Tags With Different Profiles
......
...@@ -102,7 +102,7 @@ describe('use-cache-custom-handler', () => { ...@@ -102,7 +102,7 @@ describe('use-cache-custom-handler', () => {
await retry(async () => { await retry(async () => {
expect(next.cliOutput.slice(outputIndex)).toContain( expect(next.cliOutput.slice(outputIndex)).toContain(
'ModernCustomCacheHandler::updateTags ["modern"]' 'ModernCustomCacheHandler::updateTags ["use-cache-custom-handler:modern"]'
) )
const data = await browser.elementById('data').text() const data = await browser.elementById('data').text()
...@@ -148,10 +148,10 @@ describe('use-cache-custom-handler', () => { ...@@ -148,10 +148,10 @@ describe('use-cache-custom-handler', () => {
await retry(async () => { await retry(async () => {
const cliOutput = next.cliOutput.slice(outputIndex) const cliOutput = next.cliOutput.slice(outputIndex)
expect(cliOutput).toInclude( expect(cliOutput).toInclude(
'ModernCustomCacheHandler::updateTags ["modern"]' 'ModernCustomCacheHandler::updateTags ["use-cache-custom-handler:modern"]'
) )
expect(cliOutput).toInclude( expect(cliOutput).toInclude(
'ModernCustomCacheHandler::updateTags ["other"]' 'ModernCustomCacheHandler::updateTags ["use-cache-custom-handler:other"]'
) )
}) })
}) })
......
...@@ -569,6 +569,12 @@ export class NextDeployInstance extends NextInstance { ...@@ -569,6 +569,12 @@ export class NextDeployInstance extends NextInstance {
? projectEnv.TURBOPACK_TEST_TOKEN ? projectEnv.TURBOPACK_TEST_TOKEN
: projectEnv.TEST_TOKEN : projectEnv.TEST_TOKEN
// revalidatePath/revalidateTag invalidate at project scope, so CI jobs
// that must not share a revalidation scope set VERCEL_TEST_PROJECT to a
// dedicated project. Unset keeps the shared default.
const TEST_PROJECT_NAME =
process.env.VERCEL_TEST_PROJECT?.trim() || projectEnv.TEST_PROJECT_NAME
// If the team name is available in the environment, use it as the scope. // If the team name is available in the environment, use it as the scope.
if (TEST_TEAM_NAME) { if (TEST_TEAM_NAME) {
vercelFlags.push('--scope', TEST_TEAM_NAME) vercelFlags.push('--scope', TEST_TEAM_NAME)
...@@ -611,7 +617,7 @@ export class NextDeployInstance extends NextInstance { ...@@ -611,7 +617,7 @@ export class NextDeployInstance extends NextInstance {
// link the project // link the project
const linkRes = await execa( const linkRes = await execa(
'vercel', 'vercel',
['link', '-p', projectEnv.TEST_PROJECT_NAME, '--yes', ...vercelFlags], ['link', '-p', TEST_PROJECT_NAME, '--yes', ...vercelFlags],
{ {
cwd: this.testDir, cwd: this.testDir,
env: vercelEnv, env: vercelEnv,
......
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