test(replay): comprehensive replay engine tests#74
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive test coverage for the replay engine (
packages/toolkit/src/replay/engine.ts), addressing GitHub Issue #61.What's Tested
55 tests across 9
describeblocks covering all public API surface:new ReplayEngine(events, failures, options), immutability of input arraystotalEventsgetter — correct count for normal, empty, and single-event casescurrentgetter — starts at 0, returns -1 for empty, advances afterstep(), reflectsstartIndexstep()— returns first/next event, returnsnullwhen complete, includes empty failures array, returns{event, failures, index}stepBack()— returnsnullat start and after single step, goes back one eventjumpTo(index)— jumps to valid index, returnsnullfor negative/out-of-range/emptygetState()— returns played/remaining/complete snapshot, includes failures in played events, handles emptyreset()— returns to index 0, allows re-stepping, handles emptyidreturned viastep()and ingetState().playedoptions.startIndex(at start, mid, last, default)Test Pattern
Uses the same
makeEventhelper pattern aspackages/toolkit/src/core/detection.test.ts, with a localmakeFailurehelper for buildingFailureobjects. Imports from./engine.jsas specified.Checklist
pnpm test— 280 tests pass (55 new)pnpm lint— cleanpnpm typecheck— cleanpnpm format— cleanCloses #61