Skip to content

test(e2e): tab selection survives a state-triggered rerun#48

Open
sudo-vaibhav wants to merge 1 commit into
mainfrom
test/tabs-rerun-state-stick
Open

test(e2e): tab selection survives a state-triggered rerun#48
sudo-vaibhav wants to merge 1 commit into
mainfrom
test/tabs-rerun-state-stick

Conversation

@sudo-vaibhav

@sudo-vaibhav sudo-vaibhav commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds an e2e test proving that tab selection sticks across a rerun when the rerun is ordered by a state change inside a tab.

  • examples/demo/src/pages/tabs.ts — new /tabs demo page. A 2-tab layout where tab 2 owns a text_input; committing it reruns the script. Each tab echoes its own state so the spec can confirm the rerun actually fired.
  • Registered the page: route + sidebar link in main.ts, export in pages/index.ts.
  • e2e/tabs.spec.ts — the spec: default on tab 1 → switch to tab 2 → fill input → Enter → assert the echo updates (rerun landed) and tab 2 is still data-state="active" while tab 1 is inactive. Since Radix unmounts inactive tab content, the input staying visible is an independent confirmation tab 2 held.

Why it sticks

The active tab is uncontrolled Radix state (Tabs defaultValue="0"). On rerun the client patches the tree into a new object ref, but Frame renders every node with a stable key={path} — the tabs path is unchanged, so React preserves the instance and Radix's selection survives. No remount → no snap-back to tab 1. The genuine corner case (the active tab disappears as a result of the state change) would legitimately remount and reset; that's out of scope and noted in the page comment.

Verification

  • tabs.spec.ts: 2 passed
  • sidebar.spec.ts + smoke.spec.ts (guard against the new nav link breaking counts): 11 passed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a Tabs demo page to the example application showcasing tab functionality.
  • Tests

    • Added end-to-end tests verifying that tab state persists correctly during server-side reruns.

Adds a /tabs demo page (2-tab layout, text_input in tab 2) and an e2e
spec pinning that a rerun ordered from inside tab 2 keeps tab 2 active.
The active tab is uncontrolled Radix state on a stable-keyed component,
so the tree patch from a rerun must not snap the user back to tab 1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 968c8635-432d-4694-8d51-830bba041e76

📥 Commits

Reviewing files that changed from the base of the PR and between 2131ef4 and a03bfb2.

📒 Files selected for processing (4)
  • e2e/tabs.spec.ts
  • examples/demo/src/main.ts
  • examples/demo/src/pages/index.ts
  • examples/demo/src/pages/tabs.ts

📝 Walkthrough

Walkthrough

A new backroadTabsExample demo page is added with a two-tab Backroad layout; the second tab has a text input that drives a greeting after rerun. The demo is registered in the pages map, sidebar navigation, and router. A Playwright e2e spec verifies that the active tab and input persist after the server-side rerun.

Changes

Tabs Demo Page and E2E Test

Layer / File(s) Summary
Tabs demo implementation and wiring
examples/demo/src/pages/tabs.ts, examples/demo/src/pages/index.ts, examples/demo/src/main.ts
backroadTabsExample defines a two-tab layout where the second tab's text input stores a name and renders a greeting; it is imported and registered in the pages map, and main.ts adds the /tabs sidebar link and route binding.
E2E test for tab state persistence
e2e/tabs.spec.ts
Playwright spec navigates to /tabs, verifies the initial active tab, switches to the second tab, fills the input with "Ada," presses Enter to trigger a rerun, then asserts the greeting updates and the second tab remains active with the input still visible.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 Two tabs sit side by side,
I click the second — what a ride!
I type my name, press Enter tight,
The server reruns, all feels right.
The tab stays put — hooray, hooray!
Ada gets her greeting today. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly describes the main change: an e2e test verifying tab selection persistence across reruns, which matches the primary purpose of the changeset.
Description check ✅ Passed The PR description is comprehensive and addresses all required template sections including Summary, Type of change (test), Test plan, and verification results.
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.

✏️ 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 test/tabs-rerun-state-stick

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

@github-actions

Copy link
Copy Markdown

Knip dead-code gate — no regressions

Category Baseline Current Δ
binaries 0 0 ±0
catalog 0 0 ±0
dependencies 28 28 ±0
devDependencies 8 8 ±0
duplicates 3 3 ±0
enumMembers 0 0 ±0
exports 5 5 ±0
files 6 6 ±0
namespaceMembers 0 0 ±0
optionalPeerDependencies 0 0 ±0
owners 18 18 ±0
types 2 2 ±0
unlisted 2 2 ±0
unresolved 1 1 ±0

All counts at or below baseline.

@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
backroad-frontend — main JS bundle 296.33 KB (0%)
backroad-frontend — main CSS bundle 14 KB (0%)
backroad-frontend — /signin chunk (lazy) 106.96 KB (0%)

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