Skip to content

test: add more regression coverage for existing router behavior - #7822

Merged
Sheraff merged 1 commit into
mainfrom
test/passing-router-issue-tests
Jul 15, 2026
Merged

test: add more regression coverage for existing router behavior#7822
Sheraff merged 1 commit into
mainfrom
test/passing-router-issue-tests

Conversation

@Sheraff

@Sheraff Sheraff commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Not included

Test plan

  • Router Core targeted unit tests: 8 passed
  • React Router targeted unit tests: 58 passed
  • @tanstack/router-core:test:types
  • @tanstack/react-router:test:types
  • test:eslint for Router Core and React Router
  • React Start basic Vite SSR Playwright test for direct nested not-found hydration: 1 passed

Summary by CodeRabbit

  • Bug Fixes

    • Improved hydration behavior for nested not-found pages, preserving parent route interactivity.
    • Ensured server-rendered error pages include the correct title and styles.
    • Improved loading states during delayed route initialization and rapid navigation.
    • Preserved updated context during link preloading.
    • Corrected not-found boundary handling, route lifecycle ordering, and hydration state restoration.
  • Tests

    • Added regression coverage for hydration, server rendering, loading, navigation, context, and error handling scenarios.

@nx-cloud

nx-cloud Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 0fd4483

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 14m 23s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-15 07:31:14 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: b4b3d0cee71d
  • Measured at: 2026-07-15T07:18:01.262Z
  • Baseline source: history:11a6a0d8ba4d
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.35 KiB 0 B (0.00%) 87.21 KiB 273.70 KiB 76.01 KiB ▁▁██████▄▄▄
react-router.full 91.06 KiB 0 B (0.00%) 90.92 KiB 285.59 KiB 79.19 KiB ▁▁██████▁▁▁
solid-router.minimal 35.53 KiB 0 B (0.00%) 35.40 KiB 105.90 KiB 31.94 KiB ▁▁██████▁▁▁
solid-router.full 40.58 KiB 0 B (0.00%) 40.46 KiB 121.11 KiB 36.51 KiB ▁▁██████▁▁▁
vue-router.minimal 53.00 KiB 0 B (0.00%) 52.87 KiB 149.94 KiB 47.63 KiB ▂▂██████▁▁▁
vue-router.full 58.94 KiB 0 B (0.00%) 58.81 KiB 168.70 KiB 52.76 KiB ▅▅██████▁▁▁
react-start.minimal 101.99 KiB 0 B (0.00%) 101.85 KiB 322.13 KiB 88.23 KiB ▁▄██████▄▄▄
react-start.deferred-hydration 102.72 KiB 0 B (0.00%) 101.87 KiB 323.50 KiB 88.88 KiB ▁▄██████▄▄▄
react-start.full 105.36 KiB 0 B (0.00%) 105.23 KiB 332.06 KiB 91.12 KiB ▁▄██████▁▁▁
react-start.rsbuild.minimal 99.68 KiB 0 B (0.00%) 99.51 KiB 316.57 KiB 85.74 KiB ▁▄██████▃▃▃
react-start.rsbuild.minimal-iife 100.08 KiB 0 B (0.00%) 99.91 KiB 317.51 KiB 86.11 KiB ▁▄██████▃▃▃
react-start.rsbuild.full 102.89 KiB 0 B (0.00%) 102.72 KiB 326.63 KiB 88.52 KiB ▁▄██████▂▂▂
solid-start.minimal 49.61 KiB 0 B (0.00%) 49.48 KiB 152.07 KiB 43.83 KiB ▃▅██████▁▁▁
solid-start.deferred-hydration 52.87 KiB 0 B (0.00%) 49.53 KiB 160.11 KiB 46.89 KiB ▃▅██████▁▁▁
solid-start.full 55.42 KiB 0 B (0.00%) 55.29 KiB 169.12 KiB 48.90 KiB ▃▆██████▁▁▁
vue-start.minimal 71.03 KiB 0 B (0.00%) 70.90 KiB 207.19 KiB 62.89 KiB ▄▇██████▁▁▁
vue-start.full 75.03 KiB 0 B (0.00%) 74.90 KiB 219.83 KiB 66.37 KiB ▃▅██████▁▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds regression tests covering SSR and hydration boundaries, router lifecycle ordering, context propagation, loading and preload states, and transition invalidation. The React e2e fixture adds a hydration counter used to verify direct nested not-found hydration.

Changes

Router regression coverage

Layer / File(s) Summary
SSR and hydrated not-found boundaries
e2e/react-start/basic/src/routes/posts.tsx, e2e/react-start/basic/tests/not-found.spec.ts, packages/react-router/tests/errorComponent.test.tsx, packages/router-core/tests/issue-5106-hydrated-notfound-boundary.test.ts
Tests parent-route hydration after nested not-found responses, SSR error head rendering, and hydrated child not-found boundary adoption.
Core lifecycle and context behavior
packages/router-core/tests/issue-3293-on-enter-after-loader.test.ts, packages/router-core/tests/issue-4078-loader-notfound-root-boundary.test.ts, packages/router-core/tests/issue-4696-parent-context-search-normalization.test.ts
Tests beforeLoadloaderonEnter ordering, root-boundary attribution, and parent context preservation through search normalization.
React loading and preload flows
packages/react-router/tests/issue-2905-root-beforeload-pending.test.tsx, packages/react-router/tests/issue-5778-router-provider-context-preload.test.tsx, packages/react-router/tests/loaders.test.tsx
Tests pending UI timing, updated context during intent preloading, and pending-state behavior during rapid parameterized navigation.
Transition invalidation error handling
packages/react-router/tests/issue-7638-invalidate-transition-error.test.tsx
Controls loader completion and invalidation promises to verify transition state, error rerendering, parent interactivity, hook stability, and cleanup.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • TanStack/router#7505: Related SSR errorComponent coverage for errors thrown during beforeLoad.
  • TanStack/router#7812: Overlapping regression coverage for transition invalidation and beforeLoad/head error behavior.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR as added regression test coverage for existing router behavior.
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.
✨ 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 test/passing-router-issue-tests

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7822

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7822

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7822

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7822

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7822

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7822

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7822

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7822

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7822

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7822

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7822

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7822

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7822

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7822

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7822

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7822

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7822

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7822

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7822

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7822

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7822

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7822

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7822

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7822

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7822

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7822

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7822

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7822

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7822

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7822

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7822

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7822

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7822

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7822

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7822

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7822

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7822

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7822

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7822

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7822

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7822

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7822

commit: 0fd4483

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
packages/router-core/tests/issue-5106-hydrated-notfound-boundary.test.ts (1)

19-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unsafe global cast.

Lines 19 and 23 bypass strict typing with (global as any). Install and clean up the test-only window property through globalThis APIs instead.

Proposed fix
 describe('hydrated child-owned notFound boundary coverage', () => {
   let mockWindow: { $_TSR?: TsrSsrGlobal }
+  let originalWindowDescriptor: PropertyDescriptor | undefined

   beforeEach(() => {
     mockWindow = {}
-    ;(global as any).window = mockWindow
+    originalWindowDescriptor = Object.getOwnPropertyDescriptor(
+      globalThis,
+      'window',
+    )
+    Object.defineProperty(globalThis, 'window', {
+      configurable: true,
+      value: mockWindow,
+    })
   })

   afterEach(() => {
-    delete (global as any).window
+    if (originalWindowDescriptor) {
+      Object.defineProperty(globalThis, 'window', originalWindowDescriptor)
+    } else {
+      Reflect.deleteProperty(globalThis, 'window')
+    }
     vi.restoreAllMocks()
   })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/router-core/tests/issue-5106-hydrated-notfound-boundary.test.ts`
around lines 19 - 23, Update the test setup and cleanup around mockWindow to use
globalThis APIs for installing and removing the temporary window property,
eliminating both `(global as any)` casts while preserving the existing
beforeEach/afterEach behavior.

Source: Coding guidelines

packages/react-router/tests/issue-5778-router-provider-context-preload.test.tsx (1)

67-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a valid initial router context value.

null! bypasses the declared { foo: string } contract while passing null at runtime. Initialize foo with a string so this test remains type-safe and cannot mask fallback-context behavior.

Proposed fix
-    context: { foo: null! },
+    context: { foo: 'foo' },

As per coding guidelines, **/*.{ts,tsx} must “Use TypeScript strict mode with extensive type safety.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/react-router/tests/issue-5778-router-provider-context-preload.test.tsx`
at line 67, Replace the null-forced value in the router provider test’s initial
context with a valid string for the declared `{ foo: string }` shape. Update the
`context` initializer while preserving the test’s intended preload and
fallback-context behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@packages/react-router/tests/issue-5778-router-provider-context-preload.test.tsx`:
- Line 67: Replace the null-forced value in the router provider test’s initial
context with a valid string for the declared `{ foo: string }` shape. Update the
`context` initializer while preserving the test’s intended preload and
fallback-context behavior.

In `@packages/router-core/tests/issue-5106-hydrated-notfound-boundary.test.ts`:
- Around line 19-23: Update the test setup and cleanup around mockWindow to use
globalThis APIs for installing and removing the temporary window property,
eliminating both `(global as any)` casts while preserving the existing
beforeEach/afterEach behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3739812-d970-43ac-bf77-b85d004feea8

📥 Commits

Reviewing files that changed from the base of the PR and between 11a6a0d and 0fd4483.

📒 Files selected for processing (11)
  • e2e/react-start/basic/src/routes/posts.tsx
  • e2e/react-start/basic/tests/not-found.spec.ts
  • packages/react-router/tests/errorComponent.test.tsx
  • packages/react-router/tests/issue-2905-root-beforeload-pending.test.tsx
  • packages/react-router/tests/issue-5778-router-provider-context-preload.test.tsx
  • packages/react-router/tests/issue-7638-invalidate-transition-error.test.tsx
  • packages/react-router/tests/loaders.test.tsx
  • packages/router-core/tests/issue-3293-on-enter-after-loader.test.ts
  • packages/router-core/tests/issue-4078-loader-notfound-root-boundary.test.ts
  • packages/router-core/tests/issue-4696-parent-context-search-normalization.test.ts
  • packages/router-core/tests/issue-5106-hydrated-notfound-boundary.test.ts

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 6.87%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
❌ 4 regressed benchmarks
✅ 172 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths not-found (solid) 423.3 KB 747.5 KB -43.37%
Memory mem server error-paths not-found (vue) 380.7 KB 612.7 KB -37.86%
Simulation client-preload interaction loop (react) 57.3 ms 60.6 ms -5.46%
Memory mem server server-fn-churn (react) 271.4 KB 281.9 KB -3.71%
Memory mem server peak-large-page (react) 2,080.9 KB 955.2 KB ×2.2
Memory mem server error-paths unmatched (react) 641.2 KB 416 KB +54.14%
Memory mem server serialization-payload (react) 5.3 MB 3.4 MB +53.24%
Memory mem server error-paths redirect (vue) 304.3 KB 294.8 KB +3.2%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing test/passing-router-issue-tests (0fd4483) with main (11a6a0d)

Open in CodSpeed

@Sheraff
Sheraff merged commit 0b178a7 into main Jul 15, 2026
25 of 26 checks passed
@Sheraff
Sheraff deleted the test/passing-router-issue-tests branch July 15, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant