test: mock the canary lookup in the agent upgrade reuse test (#102553)
### What?
The agent-upgrade "reuse the current CLI" unit test in
`test/unit/agentic-upgrade-prompts.test.ts` now passes when `next` is
built with a non-canary version, such as `16.5.0-rc.0` or a stable
release. It still tests the reuse path on those builds.
### Why?
The test mocked the npm `canary` dist-tag as `{ version: cliVersion }`,
where `cliVersion` is the version in `next/package.json`. #100256 added
validation to `resolveCanaryVersion`
(`packages/next/src/lib/upgrade/resolve-canary-version.ts`) that only
accepts `-canary.N` versions.
On a release build, that mocked answer is rejected, so `prepareUpgrade`
is never called. This made the unit jobs fail on release version bumps,
as on `releases/stable/16-5` after `v16.5.0-rc.0`.
Production behaviour is unaffected. On a real stable or RC CLI, the
registry returns a canary, which differs from the running version, so
the CLI delegates to `npx next@<canary> upgrade`.
### How?
- `resolveCanaryVersion` is now a module mock that calls the real
implementation by default (`jest.requireActual`). The registry fetch,
validation and release-age tests still exercise the real code.
- The reuse test makes the resolver return the running CLI's version. It
then asserts that the lookup ran, that there was no delegation, and that
`prepareUpgrade` was called. The registry is bypassed because
`process.env.__NEXT_VERSION` is inlined at build time and can't be faked
at runtime.
- The registry URL and request-options assertion that used to live in
the reuse test moved to the "delegates to the exact canary" test, which
still goes through the real fetch.
### Verification
- Ran `pnpm exec jest test/unit/agentic-upgrade-prompts.test.ts` on a
canary build (`16.5.0-canary.72`): 94/94 passed.
- Manually set `packages/next/package.json` `version` to `16.5.0-rc.0`
and ran `pnpm --filter=next build` (the built CLI inlines
`16.5.0-rc.0`).
- The previous test failed 2 cases.
- With the mocking change, 94/94 passed. This run was before the
registry URL assertion moved into the delegation test. That test mocks a
fixed canary version (`99.0.0-canary.35`), not the built version.
- I then reverted the version.
- `pnpm lint-typescript` passed, and prettier and eslint passed on the
test file.
<!-- NEXT_JS_LLM -->
<!-- fleet 3b68d51c-6447-41b3-8a1c-1613d8fb2791 -->
---------
Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>