Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Oct 29, 2025

Summary by CodeRabbit

  • New Features

    • Added URL parameter encoding support with active link highlighting. Routes now properly handle dynamic parameters and search queries with visual feedback for active states.
  • Tests

    • Added end-to-end test coverage for encoding scenarios, validating active link styling across various parameter combinations and search parameter configurations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Walkthrough

This PR adds a new feature for encoding-aware link active states with parameter validation. It introduces two route files under /encoding/link-active/ that render links with active styling based on URL parameters and search state, accompanied by E2E tests validating the active state behavior.

Changes

Cohort / File(s) Summary
Route Implementation
e2e/react-start/basic/src/routes/encoding/link-active/index.tsx, e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx
New parent and parameterized child routes. Parent renders links to child route with different target values ('ê' and 'hello'). Child route validates optional foo search parameter and renders a self-referential link with activeProps for bold styling and activeOptions to include search state in active detection.
E2E Tests
e2e/react-start/basic/tests/encoding.spec.ts
New test suite using Playwright with parameterized test matrix covering target and search parameter combinations. Verifies self-link visibility, bold styling, and active status attribute on navigation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Straightforward new route feature with consistent patterns across both route files
  • E2E test follows standard Playwright structure with parameterized test matrix
  • No complex business logic; primarily configuration, validation schema setup, and JSX rendering
  • Changes are largely homogeneous repetition of similar patterns

Suggested labels

package: react-router

Suggested reviewers

  • Sheraff
  • SeanCassiere

Poem

🐰 A new route hops into view,
With links that know when they're true—
Active and bold, parameters told,
Encoding adventures, a sight to behold! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "tests: e2e test for active links with special char encoding" accurately describes the primary objective of the changeset. The main addition is a new end-to-end test file (encoding.spec.ts) that validates active link styling with special character encoding (testing parameters like 'ê' and 'hello'). The two new route files added are supporting infrastructure specifically created to enable the test functionality. The title is clear, specific, and concise, avoiding vague terminology while accurately conveying the core intent to add e2e test coverage for active link behavior with special character encoding.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-active-link

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

@nx-cloud
Copy link

nx-cloud bot commented Oct 29, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 3efca4a

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 4m 40s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-29 01:28:10 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 29, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5681

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5681

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5681

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5681

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5681

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5681

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5681

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5681

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5681

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5681

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5681

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5681

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5681

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5681

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5681

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5681

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5681

commit: 3efca4a

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
e2e/react-start/basic/tests/encoding.spec.ts (1)

42-44: Use toHaveClass matcher for better test reliability.

The toHaveAttribute('class', 'font-bold') assertion expects the class attribute to be exactly 'font-bold', which will fail if additional classes are present. The toHaveClass matcher is more robust and checks for the presence of a specific class.

Apply this diff:

       const link = page.getByTestId('self-link')
       await expect(link).toBeInViewport()
-      await expect(link).toHaveAttribute('class', 'font-bold')
+      await expect(link).toHaveClass('font-bold')
       await expect(link).toHaveAttribute('data-status', 'active')
e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx (1)

10-24: Refactor to extract hook calls from JSX.

Route.useParams() and Route.useSearch() are called multiple times directly in the JSX (lines 17, 18, 20, 21). This is inefficient as hooks are called on every render, and it makes the code less readable. Extract these calls to the top of the component.

Apply this diff:

 function RouteComponent() {
+  const { target } = Route.useParams()
+  const search = Route.useSearch()
+
   return (
     <Link
       data-testid="self-link"
       activeProps={{ className: 'font-bold' }}
       activeOptions={{ includeSearch: true }}
       to="/encoding/link-active/$target"
-      params={{ target: Route.useParams().target }}
-      search={Route.useSearch()}
+      params={{ target }}
+      search={search}
     >
-      link to self with $target={Route.useParams().target}, search.foo=
-      {Route.useSearch().foo}
+      link to self with $target={target}, search.foo={search.foo}
     </Link>
   )
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f325d9a and 3efca4a.

📒 Files selected for processing (3)
  • e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx (1 hunks)
  • e2e/react-start/basic/src/routes/encoding/link-active/index.tsx (1 hunks)
  • e2e/react-start/basic/tests/encoding.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx
  • e2e/react-start/basic/src/routes/encoding/link-active/index.tsx
  • e2e/react-start/basic/tests/encoding.spec.ts
**/src/routes/**

📄 CodeRabbit inference engine (AGENTS.md)

Place file-based routes under src/routes/ directories

Files:

  • e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx
  • e2e/react-start/basic/src/routes/encoding/link-active/index.tsx
e2e/**

📄 CodeRabbit inference engine (AGENTS.md)

Store end-to-end tests under the e2e/ directory

Files:

  • e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx
  • e2e/react-start/basic/src/routes/encoding/link-active/index.tsx
  • e2e/react-start/basic/tests/encoding.spec.ts
🧬 Code graph analysis (2)
e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx (1)
e2e/react-start/basic/src/routes/encoding/link-active/index.tsx (1)
  • Route (3-5)
e2e/react-start/basic/src/routes/encoding/link-active/index.tsx (1)
e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx (1)
  • Route (4-8)
🪛 ESLint
e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx

[error] 1-1: Member 'Link' of the import declaration should be sorted alphabetically.

(sort-imports)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (1)
e2e/react-start/basic/src/routes/encoding/link-active/index.tsx (1)

1-19: LGTM!

The route definition and links are correctly implemented, properly exercising special character encoding in route parameters.

Comment on lines +1 to +2
import { createFileRoute, Link } from '@tanstack/react-router'
import z from 'zod'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Fix import sorting and verify zod import.

The static analysis tool flagged that Link should be sorted before createFileRoute alphabetically. Additionally, the zod import uses a default import pattern, but zod typically exports z as a named export.

Apply this diff to fix the import sorting:

-import { createFileRoute, Link } from '@tanstack/react-router'
+import { Link, createFileRoute } from '@tanstack/react-router'
 import z from 'zod'

Verify the zod import pattern with a web search:

As per coding guidelines.


🌐 Web query:

Does zod export z as a default export or named export?

💡 Result:

Zod does not use a default export. Import it as a namespace (recommended):

import * as z from "zod". [1][2]

Sources: Zod docs and repository. [1] https://zod.dev/intro (recommendation) [2] https://github.com/colinhacks/zod (README).


Fix import sorting and correct zod import pattern.

The zod import is incorrect. Zod does not use a default export and should be imported as a namespace: import * as z from "zod". Additionally, apply the import sorting fix to align with static analysis conventions.

-import { createFileRoute, Link } from '@tanstack/react-router'
-import z from 'zod'
+import { Link, createFileRoute } from '@tanstack/react-router'
+import * as z from 'zod'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { createFileRoute, Link } from '@tanstack/react-router'
import z from 'zod'
import { Link, createFileRoute } from '@tanstack/react-router'
import * as z from 'zod'
🧰 Tools
🪛 ESLint

[error] 1-1: Member 'Link' of the import declaration should be sorted alphabetically.

(sort-imports)

🤖 Prompt for AI Agents
In e2e/react-start/basic/src/routes/encoding/link-active/$target.tsx lines 1-2,
the zod import is incorrect and imports should be sorted: change the zod import
to a namespace import (import * as z from "zod") and reorder the import
statements according to your project's import-sorting rules (typically
alphabetically by module specifier or as enforced by your linter) so imports
follow the static analysis conventions.

Comment on lines +19 to +20
combinate
test.describe('link active', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the stray combinate identifier.

Line 19 contains a standalone combinate identifier that has no effect. This appears to be an accidental leftover from development.

Apply this diff to remove it:

-combinate
 test.describe('link active', () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
combinate
test.describe('link active', () => {
test.describe('link active', () => {
🤖 Prompt for AI Agents
In e2e/react-start/basic/tests/encoding.spec.ts around lines 19 to 20, there is
a stray standalone identifier "combinate" on line 19 that should be removed;
delete that token so the file begins directly with the test.describe('link
active', () => { block, ensuring no other code or whitespace is accidentally
removed and the test file still compiles.

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.

2 participants