Skip to content

test: add e2e fixtures for new experimental TanStack Start RSC#651

Merged
serhalp merged 3 commits into
mainfrom
claude/zen-meninsky
Apr 14, 2026
Merged

test: add e2e fixtures for new experimental TanStack Start RSC#651
serhalp merged 3 commits into
mainfrom
claude/zen-meninsky

Conversation

@serhalp

@serhalp serhalp commented Apr 13, 2026

Copy link
Copy Markdown
Member

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added React Server Components demo pages: /rsc-basic showcasing server-rendered greeting and user list, and /rsc-composite demonstrating server-rendered content with embedded client-side interactive components.
    • Added navigation links to new demo routes in the app header.
  • Tests

    • Added end-to-end tests for new RSC demo pages verifying server rendering and client interactivity.
  • Chores

    • Updated dependencies and enabled React Server Components support in build configuration.

Walkthrough

This PR adds React Server Components (RSC) support to a TanStack Start test fixture. It introduces two new routes (/rsc-basic and /rsc-composite) that demonstrate different RSC patterns, including async server-side data fetching and rendering, a client-side Counter component for interactive demonstrations, three server functions that fetch and render RSC content, updated TanStack dependency versions and configuration to enable RSC, navigation links in the root layout, and two new e2e tests to validate the RSC routes respond correctly and render expected server-rendered output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: adding e2e fixtures for experimental TanStack Start RSC functionality.
Description check ✅ Passed The description provides context and references to TanStack RSC documentation, directly relating to the changeset's purpose of testing new RSC features.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 claude/zen-meninsky

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 and usage tips.

@serhalp serhalp force-pushed the claude/zen-meninsky branch from 812f7ad to 4210df1 Compare April 13, 2026 21:42
@serhalp serhalp marked this pull request as ready for review April 13, 2026 21:57
@serhalp serhalp requested a review from a team as a code owner April 13, 2026 21:57
@serhalp serhalp requested review from a team and removed request for a team April 13, 2026 21:58

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/vite-plugin-tanstack-start/test/e2e/build.test.ts`:
- Around line 100-102: The test reads the counter value immediately after
page.click which can race with async state updates; replace the immediate
page.textContent call with a wait-based assertion (use page.waitForSelector or
page.waitForFunction, or create a locator via
page.locator('[data-testid="counter-value"]') and use
expect(locator).toHaveText('1')) so the test waits for the DOM to reflect the
increment before asserting; update the lines using page.click, page.textContent
and the '[data-testid="counter-value"]' selector accordingly.

In
`@packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/utils/rsc.tsx`:
- Around line 36-40: The RSC fixture currently fetches live data via fetch(...)
and throws on non-OK results, creating a brittle dependency; modify the code
around the fetch call so that you attempt the network request but gracefully
fallback to a deterministic local dataset when the fetch fails or returns a
non-OK response. Specifically, wrap the fetch in try/catch (or check res.ok) and
on any error or non-OK response set users to a hard-coded array of user objects
(same shape as Array<{id:number;name:string;email:string}>) instead of throwing;
update the logic in the module containing the const res / const users to use
this fallback so tests remain deterministic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 242a8f05-93b3-4c8f-9c44-f32ad470bdba

📥 Commits

Reviewing files that changed from the base of the PR and between bdb9264 and 4210df1.

📒 Files selected for processing (9)
  • packages/vite-plugin-tanstack-start/test/e2e/build.test.ts
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/package.json
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/components/Counter.tsx
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/routeTree.gen.ts
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/routes/__root.tsx
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/routes/rsc-basic.tsx
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/routes/rsc-composite.tsx
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/utils/rsc.tsx
  • packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/vite.config.ts

Comment on lines +100 to +102
await page.click('[data-testid="counter-button"]')
const updatedValue = await page.textContent('[data-testid="counter-value"]')
expect(updatedValue).toBe('1')

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.

⚠️ Potential issue | 🟡 Minor

Stabilize post-click counter assertion to avoid async flake.

At Line 100-Line 102, the value is read immediately after click. This can intermittently fail before state commit in slower environments.

Suggested fix
-    await page.click('[data-testid="counter-button"]')
-    const updatedValue = await page.textContent('[data-testid="counter-value"]')
-    expect(updatedValue).toBe('1')
+    await page.click('[data-testid="counter-button"]')
+    await page.waitForFunction(() => {
+      const el = document.querySelector('[data-testid="counter-value"]')
+      return el?.textContent === '1'
+    })
📝 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
await page.click('[data-testid="counter-button"]')
const updatedValue = await page.textContent('[data-testid="counter-value"]')
expect(updatedValue).toBe('1')
await page.click('[data-testid="counter-button"]')
await page.waitForFunction(() => {
const el = document.querySelector('[data-testid="counter-value"]')
return el?.textContent === '1'
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vite-plugin-tanstack-start/test/e2e/build.test.ts` around lines 100
- 102, The test reads the counter value immediately after page.click which can
race with async state updates; replace the immediate page.textContent call with
a wait-based assertion (use page.waitForSelector or page.waitForFunction, or
create a locator via page.locator('[data-testid="counter-value"]') and use
expect(locator).toHaveText('1')) so the test waits for the DOM to reflect the
increment before asserting; update the lines using page.click, page.textContent
and the '[data-testid="counter-value"]' selector accordingly.

Comment on lines +36 to +40
const res = await fetch('https://jsonplaceholder.typicode.com/users')
if (!res.ok) {
throw new Error('Failed to fetch users for RSC')
}
const users = (await res.json()) as Array<{ id: number; name: string; email: string }>

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.

⚠️ Potential issue | 🟠 Major

Avoid hard dependency on live third-party API in e2e fixture path.

At Line 36-Line 40, the fixture relies on a public API at request time. This makes RSC tests non-deterministic and vulnerable to external outages/rate limits.

Suggested deterministic fallback pattern
 export const fetchRscUserList = createServerFn().handler(async () => {
-  const res = await fetch('https://jsonplaceholder.typicode.com/users')
-  if (!res.ok) {
-    throw new Error('Failed to fetch users for RSC')
-  }
-  const users = (await res.json()) as Array<{ id: number; name: string; email: string }>
+  const fallbackUsers: Array<{ id: number; name: string; email: string }> = [
+    { id: 1, name: 'Leanne Graham', email: 'leanne@example.com' },
+    { id: 2, name: 'Ervin Howell', email: 'ervin@example.com' },
+    { id: 3, name: 'Clementine Bauch', email: 'clementine@example.com' },
+    { id: 4, name: 'Patricia Lebsack', email: 'patricia@example.com' },
+    { id: 5, name: 'Chelsey Dietrich', email: 'chelsey@example.com' },
+  ]
+
+  let users = fallbackUsers
+  try {
+    const res = await fetch('https://jsonplaceholder.typicode.com/users')
+    if (res.ok) {
+      users = (await res.json()) as Array<{ id: number; name: string; email: string }>
+    }
+  } catch {
+    // keep deterministic fallback for fixture stability
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/vite-plugin-tanstack-start/test/fixtures/start-basic-rc/src/utils/rsc.tsx`
around lines 36 - 40, The RSC fixture currently fetches live data via fetch(...)
and throws on non-OK results, creating a brittle dependency; modify the code
around the fetch call so that you attempt the network request but gracefully
fallback to a deterministic local dataset when the fetch fails or returns a
non-OK response. Specifically, wrap the fetch in try/catch (or check res.ok) and
on any error or non-OK response set users to a hard-coded array of user objects
(same shape as Array<{id:number;name:string;email:string}>) instead of throwing;
update the logic in the module containing the const res / const users to use
this fallback so tests remain deterministic.

@serhalp serhalp enabled auto-merge (squash) April 14, 2026 15:01
@serhalp serhalp merged commit 67f3334 into main Apr 14, 2026
18 checks passed
@serhalp serhalp deleted the claude/zen-meninsky branch April 14, 2026 15:24
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.

3 participants