Skip to content

fix(test): stub history + removeAttribute after #313 + #366 collision#445

Merged
rohitg00 merged 1 commit into
mainfrom
fix/viewer-sandbox-history-removeattr
May 17, 2026
Merged

fix(test): stub history + removeAttribute after #313 + #366 collision#445
rohitg00 merged 1 commit into
mainfrom
fix/viewer-sandbox-history-removeattr

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 17, 2026

Cross-PR regression caught while re-reviewing merged work. #366's viewer sandbox passed on its own. #313's hash-routing added history.replaceState + removeAttribute calls in switchTab. Combined main fails:

TypeError: b.removeAttribute is not a function
ReferenceError: history is not defined

Two-line stub fix to the sandbox.

Test plan

  • npm test — 987/987 passing on this branch
  • reproduced the failure on plain main before the fix

Summary by CodeRabbit

  • Tests
    • Updated viewer session test harness to support new routing behavior.

Review Change Stack

The viewer-session-id sandbox (added in #366) ran fine until #313
landed hash-routing in `switchTab` — `updateTabRoute` now calls
`history.replaceState`, and the aria-selected toggle calls
`removeAttribute` on the non-active tab buttons. Neither was stubbed
in the vm sandbox, so the combined main produced 2 failures:

  TypeError: b.removeAttribute is not a function
  ReferenceError: history is not defined

Both PRs (#366, #313) passed CI in isolation. The combined failure
only surfaced after merge. Stub both globals.

987/987 tests now pass on main.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 17, 2026 10:24am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b893b32-90d6-4ff2-8a7f-0200e44ffe1a

📥 Commits

Reviewing files that changed from the base of the PR and between 63a0742 and de3c757.

📒 Files selected for processing (1)
  • test/viewer-session-id.test.ts

📝 Walkthrough

Walkthrough

This PR updates the Vitest viewer-session test harness to prevent runtime errors from new viewer routing behavior. The test sandbox DOM mock now supports attribute removal, and the vm environment includes stubbed history and location APIs used by tab-switching code paths introduced in PR #313.

Changes

Viewer Session Test Harness Updates

Layer / File(s) Summary
Viewer routing sandbox environment mocks
test/viewer-session-id.test.ts
Mock DOM element gains removeAttribute method for ARIA-toggling. Vm sandbox extended with history (replaceState, pushState) and location (hash, pathname, search) stubs to match viewer's new routing calls during tab switching. Existing test assertions remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • rohitg00/agentmemory#313: This PR introduces the new hash/history-driven updateTabRoute/switchTab behavior that the test harness mocks now support.
  • rohitg00/agentmemory#366: Related viewer session-id rendering and tab-switching regression tests that rely on the same sandbox mocking setup.

Poem

🐰 A hop through the sandbox, a route to refine,
Mock history whispers, location alignd,
Tab switches smoothly, attributes take flight,
The viewer now settles, the test burns so bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. 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 directly and specifically addresses the main change: stubbing history and removeAttribute in the test sandbox to fix a regression from the collision of two prior PRs (#313 and #366).
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 fix/viewer-sandbox-history-removeattr

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 skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@rohitg00 rohitg00 merged commit c93c715 into main May 17, 2026
5 checks passed
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