Files
vercel__next.js/test/e2e/app-dir/use-cache-default-handler-expire-zero/use-cache-default-handler-expire-zero.test.ts
Josh Story e0966df114 test: migrate caching deploy exclusions to force gates (#98154)
## Summary

- migrate Cache Components, PPR, prefetching, prerendering,
revalidation, and SSG deployment exclusions to `@force-gate`
- remove the corresponding `skipDeployment` options and `skipped`
control flow while preserving each suite's rationale

This keeps caching-related exclusions together so their deployed
semantics can be reviewed by the same owners.

## Verification

- verified on the combined top-of-stack tree with `pnpm typescript`
- compared ordinary-mode collection before and after: all 4,670 existing
test names matched
- collected all 510 affected files in deploy mode: 4,578 skipped tests,
zero failures

<!-- NEXT_JS_LLM -->
2026-09-09 08:25:36 -07:00

65 lines
2.6 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('use-cache-default-handler-expire-zero', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
// Enable the built-in default cache handler's debug logging so we can
// assert on its `set()` decisions in the CLI output. That output is not
// available on deploy, so skip the deploy variant.
env: { NEXT_PRIVATE_DEBUG_CACHE: '1' },
})
if (isNextStart) {
it('does not save an expire:0 cache to the built-in default handler, but saves a short-lived one', async () => {
const browser = await next.browser('/')
expect(
await browser.elementById('expire-zero-value').text()
).toBeDateString()
expect(
await browser.elementById('short-lived-value').text()
).toBeDateString()
// The default handler skips storing the `expire: 0` entry (it would never
// be served back in production)...
expect(next.cliOutput).toMatch(
/DefaultCacheHandler: set \["([0-9a-f]{2})+",\[{"id":"expire-zero"}\],\["[A-Za-z0-9_-]+"(,"[^"]+")*\]\] skipped dynamic entry/
)
// ...and never reports it as stored.
expect(next.cliOutput).not.toMatch(
/DefaultCacheHandler: set \["([0-9a-f]{2})+",\[{"id":"expire-zero"}\],\["[A-Za-z0-9_-]+"(,"[^"]+")*\]\] done/
)
// The short-lived (`expire: 60`) cache is still stored.
expect(next.cliOutput).toMatch(
/DefaultCacheHandler: set \["([0-9a-f]{2})+",\[{"id":"short-lived"}\],\["[A-Za-z0-9_-]+"(,"[^"]+")*\]\] done/
)
})
} else {
it('saves an expire:0 cache to the built-in default handler in dev', async () => {
const browser = await next.browser('/')
expect(
await browser.elementById('expire-zero-value').text()
).toBeDateString()
// In development the default handler keeps `expire: 0` entries (its
// minimum retention serves them warm across reloads), so it stores rather
// than skips. The implementation parts include the build ID and a
// trailing HMR refresh hash.
await retry(async () => {
expect(next.cliOutput).toMatch(
/DefaultCacheHandler: set \["([0-9a-f]{2})+",\[{"id":"expire-zero"}\],\["[A-Za-z0-9_-]+"(,"[^"]+")+\]\] done/
)
})
expect(next.cliOutput).not.toMatch(
/DefaultCacheHandler: set \["([0-9a-f]{2})+",\[{"id":"expire-zero"}\],\["[A-Za-z0-9_-]+"(,"[^"]+")+\]\] skipped/
)
})
}
})