Skip to content

Stabilize Next navigation web test mocks - #8035

Merged
lawrencecchen merged 4 commits into
mainfrom
task-fix-web-navigation-test-mocks
Jul 14, 2026
Merged

lawrencecchen merged 4 commits into
mainfrom
task-fix-web-navigation-test-mocks

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • centralize the process-wide next/navigation mock used by web page tests
  • include the client navigation hooks imported by unrelated suites
  • add a regression that imports the affected client navigation component after the mock is installed

Testing

  • bun test tests/app-pro-welcome-page.test.tsx tests/app-pricing-page.test.tsx tests/billing-success-page.test.tsx
  • bun run typecheck
  • bun test $(ls tests/*.test.ts tests/*.test.tsx | sort) (661 passed, 91 skipped)

CI failure


Summary by cubic

Centralizes a complete next/navigation mock for web tests to eliminate order-dependent CI failures and keep client hooks importable across suites. Also completes the pricing test setup by adding a next-intl client mock and rendering the real Pro welcome banner.

  • Bug Fixes
    • Added web/tests/helpers/next-navigation-mock.ts and switched affected tests to use it.
    • Mock includes all needed exports: redirect, permanentRedirect, notFound, usePathname, useRouter, useSearchParams, useServerInsertedHTML.
    • Updated app-pro-welcome-page, app-pricing-page, billing-success-page, and pricing-page tests to use the shared, process-wide mock; pricing-page now renders the real Pro welcome banner and uses a next-intl client mock.
    • Added a regression test to ensure client navigation components still import after installing the mock.

Written for commit 1c6cf55. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Standardized how next/navigation is mocked across pricing, billing-success, and app-pro welcome page tests using a shared helper.
    • Added coverage ensuring welcome-page client-side navigation hooks/components remain importable after the shared mock is installed.
    • Enhanced pricing page tests with a next-intl client-side mock and updated snapshots by removing the ProWelcomeBanner stub.

@vercel

vercel Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jul 14, 2026 2:01pm
cmux-staging Building Building Preview, Comment Jul 14, 2026 2:01pm

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a shared next/navigation test mock with redirect helpers, router methods, and navigation hooks. Four page test suites use it, with additional Pro welcome importability coverage and localized client hook mocks.

Changes

Navigation mock standardization

Layer / File(s) Summary
Create shared navigation mock
web/tests/helpers/next-navigation-mock.ts
Defines reusable redirect helpers, navigation hooks, a stub router, and not-found behavior.
Migrate page tests to shared mock
web/tests/app-pricing-page.test.tsx, web/tests/app-pro-welcome-page.test.tsx, web/tests/billing-success-page.test.tsx, web/tests/pricing-page.test.tsx
Replaces inline navigation mocks with the shared helper, verifies Pro welcome navigation imports, adds localized next-intl hooks, and removes the Pro welcome banner stub.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 25
✅ Passed checks (25 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed The PR only changes a web test file; no Swift production code or actor-isolation-sensitive declarations were touched.
Cmux Swift Blocking Runtime ✅ Passed The diff only changes a web test file; no Swift files or runtime blocking primitives are introduced.
Cmux Browser Automation Off-Main ✅ Passed Only web test intl-mock changes are present; no browser automation sources, worker routing, or policy tests were touched.
Cmux Expensive Synchronous Load ✅ Passed The PR only changes a web test file; no Swift files or expensive synchronous load paths are touched.
Cmux Cache Substitution Correctness ✅ Passed Diff is test-only; shared next/navigation mock and banner regression add no persistence/history/snapshot cache substitution risk.
Cmux No Hacky Sleeps ✅ Passed The diff only adds a test helper and updates tests; no sleeps, timers, polling, or wall-clock waits were introduced.
Cmux Algorithmic Complexity ✅ Passed PASS: The PR only changes test scaffolding under web/tests; no production code or scalable-collection algorithm was introduced or worsened.
Cmux Swift Concurrency ✅ Passed The diff only changes web/tests/pricing-page.test.tsx; no Swift files or Swift concurrency patterns were introduced.
Cmux Swift @Concurrent ✅ Passed No Swift files are changed in this PR diff, so the Swift @concurrent rule is not applicable.
Cmux Swift File And Package Boundaries ✅ Passed The commit only changes a web test file; no Swift sources or package-boundary-relevant production code were touched.
Cmux Swiftpm Lockfiles ✅ Passed Diff only changes web test TS files; no Package.swift, Package.resolved, .gitignore, Xcode, or workflow files are touched, so the lockfile rule isn't implicated.
Cmux Swift Logging ✅ Passed The PR only changes a TypeScript test file; no Swift files or logging APIs were added or modified, so the Swift logging rule is not violated.
Cmux User-Facing Error Privacy ✅ Passed Changes are limited to web tests and a test helper; the policy explicitly allows tests/docs and no production user-facing error text was added.
Cmux Full Internationalization ✅ Passed Only a test file changed; no production UI, message-catalog, or locale-routing text was added or altered.
Cmux Swiftui State Layout ✅ Passed The PR only changes a TypeScript test file; no SwiftUI files or state/layout patterns from the rule appear in the diff.
Cmux Architecture Rethink ✅ Passed No Swift architecture changes are present; the diff is a small test-only TypeScript mock fix with clear ownership and no lifecycle/state anti-patterns.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PR changes only web test TS files; no Swift/AppKit/SwiftUI window code changed, so the auxiliary-window shortcut rule is not applicable.
Cmux Source Artifacts ✅ Passed All changed paths are intentional test/source files under web/tests; no logs, caches, build output, temp, or other source-control artifacts were added.
Cmux No Test Or Debug Seam In Production Source ✅ Passed The diff only changes web/tests/pricing-page.test.tsx; no Swift files under Sources/ or Tests/ were touched, so the production-source seam rule doesn't apply.
Cmux No Ambient Global State ✅ Passed The PR only changes a web test file; no Swift production code or new ambient globals are introduced, so the rule is not applicable.
Title check ✅ Passed The title is concise and accurately describes the main change: stabilizing Next navigation test mocks.
Description check ✅ Passed The description includes Summary and Testing details, and clearly explains the CI failure and fix.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task-fix-web-navigation-test-mocks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR stabilizes the shared Next.js navigation mocks used by web page tests. The main changes are:

  • Centralized the process-wide next/navigation mock.
  • Added the client navigation hooks needed across test suites.
  • Rendered the real Pro welcome banner in pricing tests.
  • Added coverage for importing the client component after mock installation.

Confidence Score: 5/5

This looks safe to merge.

  • The real Pro welcome banner is no longer replaced by a process-wide component stub.
  • The shared navigation mock includes the hooks used by the affected client component.
  • No blocking issue remains in the updated fix.

Important Files Changed

Filename Overview
web/tests/helpers/next-navigation-mock.ts Adds the shared navigation mock factory and the client hooks required by affected suites.
web/tests/pricing-page.test.tsx Removes the banner stub and renders the real component with explicit navigation and internationalization mocks.
web/tests/app-pro-welcome-page.test.tsx Uses the shared mock and verifies that the real client navigation component remains importable.
web/tests/app-pricing-page.test.tsx Replaces the local partial navigation mock with the shared mock.
web/tests/billing-success-page.test.tsx Switches the billing success tests to the shared navigation mock.

Reviews (3): Last reviewed commit: "Complete pricing test intl mock" | Re-trigger Greptile

describe("app pro welcome page", () => {
test("keeps client navigation components importable after installing the navigation mock", async () => {
const navigation = await import("next/navigation");
const banner = await import("../app/[locale]/components/pro-welcome-banner");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cached Component Stub Hides Failure

Another pricing-page suite installs a process-wide mock for pro-welcome-banner that exports a stub function. When that suite loads first, this import resolves to the stub, so the type assertion passes without loading the real component or checking its useSearchParams import against the shared navigation mock.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c5913f1. The localized pricing suite now imports and renders the real ProWelcomeBanner with the shared next/navigation mock, instead of installing a process-wide component stub. This keeps the importability regression test tied to the real client component. The focused pair and the full sorted web suite pass.

— Claude Code

@lawrencecchen
lawrencecchen merged commit 66fe8fb into main Jul 14, 2026
24 of 26 checks passed
@lawrencecchen
lawrencecchen deleted the task-fix-web-navigation-test-mocks branch July 14, 2026 05:46
@lawrencecchen
lawrencecchen restored the task-fix-web-navigation-test-mocks branch July 18, 2026 10:25

This branch was successfully deployed

1 active deployment
Preview – cmux — 1c6cf554 Deployed Jul 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant