test: add unit tests for CommandHistory functionality#1750
Conversation
📝 WalkthroughWalkthroughAdds a new Vitest test file ChangesCommandHistory Test Suite
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/history/CommandHistory.test.ts`:
- Around line 120-124: The case-insensitive search test only validates the count
of results but not the actual content, allowing the test to pass even if an
incorrect command is returned. In the test case for "search() is
case-insensitive", after asserting that the search results have length 1, add an
additional assertion to verify that the matched result actually contains or
equals the expected command 'Git Status'. This ensures the search method returns
the correct command, not just any command.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e110ce0-9601-44e6-98ff-c63df3663a0a
📒 Files selected for processing (1)
packages/core/src/history/CommandHistory.test.ts
Description
Adds 23 unit tests for CommandHistory in @termuijs/core which had no
test coverage. Tests cover add, previous, next, search, getAll, clear,
export, and import including edge cases like empty input, clamping,
maxSize eviction, and navigation after import.
Related Issue
Closes #1748
Which package(s)?
Package: @termuijs/core
Type of Change
type:bug)type:feature)type:docs)type:testing)type:refactor)type:design)type:accessibility)type:performance)type:devops)type:security)Checklist
needs-starcheck blocks your merge otherwise.bun vitest runbun run buildbun run typecheckCONTRIBUTING.md.type: short description.markDirty()(if your change affects rendering).anytypes without an inline comment explaining why.GSSoC 2026 Participation
-https://gssoc.girlscript.org/profile/790b367a-48ea-45f6-af27-c353fb2d49cb
Notes for the Reviewer
CommandHistory.ts had zero test coverage. All 23 tests pass locally.
Full core test suite (43 files, 471 tests) passes with no regressions.
I reviewed each test case against the source code manually and verified all pass locally.
Summary by CodeRabbit