Skip to content

test(embed): make the session-canonicalize IT actually exercise the beforeLoad guard - #533

Merged
omridevk merged 1 commit into
mainfrom
test/canonicalize-real-coverage
Aug 16, 2026
Merged

test(embed): make the session-canonicalize IT actually exercise the beforeLoad guard#533
omridevk merged 1 commit into
mainfrom
test/canonicalize-real-coverage

Conversation

@omridevk

@omridevk omridevk commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

session-canonicalize.it.test.ts was fake coverage: it passed with the beforeLoad guard in panel.$sessionId.tsx deleted. So the guard it names had no coverage, and the test duplicated what warm-session-resolve.it.test.ts already proves. Found by revert-checking it while closing out #339.

Why it was vacuous

It seeded exactly ONE external harness session, which made it also the newest. __root.tsx:177 sorts sessions.list by updatedAt descending and warm-resolves the top row at boot — and sessions.resolve on an unadopted native id adopts it. By the time the picker opened, the list returned the canonical conciv_* id and the raw harness id was gone from the UI entirely. The guard never ran.

Why the guard is genuinely reachable

nativeOnlyMeta (session-rows.ts:189) lists a never-adopted harness session under its raw native id, and the picker's activate navigates with whatever id the option carries. So selecting an unadopted session drives /panel/$sessionId with a raw harness id and the guard fires — a real user action through the UI, no seeding.

The fix is to stop the session under test from being the newest, so warm-resolve adopts a different one and leaves it unadopted.

Mechanism confirmed directly

Probe against a guard-removed build, at click time:

PROBE href after switch: /panel/43548fd1-0000-4220-acf0-014b10b5815f?open=true
PROBE list: [["conciv_dd3893a6-…","the newest session outside conciv"],
             ["43548fd1-0000-4220-acf0-014b10b5815f","a session started outside conciv"]]

The newer session is adopted into a conciv_* row by boot warm-resolve; the older one is still listed under its raw id; selecting it drives the route with that raw id. With the guard, the panel ends on /panel/conciv_*; without it, it sits on the raw id.

The test now asserts that precondition explicitly (read-only via sessions.list) rather than assuming it.

One assertion had to change

The old until(href.startsWith('/panel/conciv_')) is trivially true with two sessions — the warm session's own route already satisfies it — so keeping it would have re-introduced the exact vacuity being fixed. It now waits for the href to contain the canonical id of the external session under test, found by reading sessions.list for a conciv_* row with that title — a row that only exists because the guard resolved the raw id.

Revert-check

  • Guard removed → embed rebuilt → bundle verified guard-free (sourcesContent shows no beforeLoad; grep -c "beforeLoad: async" dist/… → 0) → 1 failed.
  • Guard restored → rebuilt → --repeat-each=55 passed.

Test-only change; no changeset. Full embed suite: 105 passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded end-to-end coverage for session handling.
    • Verified that newer sessions are removed after resolution while raw external sessions remain available.
    • Confirmed raw external sessions can be selected and adopt their canonical session ID in the URL.

…eforeLoad guard

The fixture seeded a single external harness session, which made it the
newest, so the boot warm-resolve adopted it before the picker ever opened.
Seed a newer external session so the one under test stays unadopted and
selecting it sends a raw harness id into /panel/$sessionId.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 16, 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: CHILL

Plan: Pro Plus

Run ID: 4f96e558-7b64-4f0e-b270-a27ef0767b7a

📥 Commits

Reviewing files that changed from the base of the PR and between 7a95ab8 and fa86ca8.

📒 Files selected for processing (1)
  • packages/embed/tests/e2e/session-canonicalize.it.test.ts

Included review availability: Your plan includes up to 3 reviews per rolling hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The E2E test seeds newer and raw external sessions. It verifies initial listing, selective removal after warm resolution, and navigation to the raw external session’s adopted canonical route.

Changes

Session canonicalization

Layer / File(s) Summary
Session resolution and navigation
packages/embed/tests/e2e/session-canonicalize.it.test.ts
The test seeds two sessions, verifies both raw IDs are listed, confirms warm resolution removes only the newer session, and checks navigation to the external session’s adopted canonical ID.

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

Merge Risk: ⚪ Minimal · up to fa86c

This is a localized test-only change that improves coverage of the session canonicalization guard without changing product behavior, so no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: no-changeset

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: updating the embed integration test to exercise the beforeLoad guard.
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.
✨ 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/canonicalize-real-coverage

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

@omridevk
omridevk merged commit 35f6c26 into main Aug 16, 2026
41 of 43 checks passed
@omridevk
omridevk deleted the test/canonicalize-real-coverage branch August 16, 2026 11:53
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