Commit Graph

1 Commits

Author SHA1 Message Date
James Anderson 2354ca6e60 test(trailing-slash): pin core enforcement contract for App Router (#1332) (#1635)
* test(trailing-slash): pin core enforcement contract for App Router (#1332)

Adds focused integration tests against a dev-server fixture built from
app-basic with a minimal `next.config.ts` overriding `trailingSlash`.

The core enforcement contract documented in Next.js
test/e2e/trailing-slashes and test/e2e/app-dir/trailingslash was already
implemented across the dev server, prod-server, app-rsc-handler, and the
deploy worker entry by #1395 and #1413, but no end-to-end test asserted
the full contract end-to-end through the dev server. These regression
tests close that gap so future refactors of the trailing-slash redirect
or `<Link>` normalisation paths fail loudly.

Coverage:
- trailingSlash: true
  - GET /about → 308 Location: /about/
  - GET /about/ → 200
  - <Link href="/about"> renders href="/about/"
- trailingSlash: false (default)
  - GET /about/ → 308 Location: /about
  - GET /about → 200
  - <Link href="/about"> renders href="/about" (no trailing slash)

Refs #1332.

* test(trailing-slash): address bonk review nits

- Rename tests/trailing-slash-1332.test.ts → tests/trailing-slash.test.ts
  to match repo naming convention (the issue ref lives in the header
  comment and describe titles).
- Switch to the shared `startFixtureServer` helper from tests/helpers.ts;
  drop the local `startServer` and the now-unused `createServer` / `Server`
  imports.
- Tighten the second describe title to "trailingSlash: false" — the
  fixture explicitly sets `false`, not omits the field. The default-vs-
  explicit behaviour is identical today, so the merged-name was misleading.
- Document why we keep `fs.cpSync` rather than `createIsolatedFixture`:
  app-basic's node_modules carries fixture-local symlinks
  (fake-context-lib, fake-css-lib, …) that `createIsolatedFixture` would
  break by replacing node_modules with a workspace symlink, and the
  isolated copy also gets its own `.vite` optimizer cache (preventing
  races against the workspace cache used by other tests). Verified
  empirically: the bot-suggested `createIsolatedFixture` swap reproduces
  500s on every request, mirroring the rationale already captured in
  tests/favicon-short-circuit.test.ts.

Refs #1332.

* test(trailing-slash): bump 200-serve timeouts to 30s for dev-mode compile

CI showed both 200-serve cases hitting the 5s default while the dev server
was compiling the /about route on first hit. Match the headroom we already
use elsewhere (e.g. tests/app-router.test.ts).

* style: apply biome formatter to trailing-slash.test.ts
2026-05-28 21:07:58 +01:00