test(tui): cover fpsStore trackFrame state - #22299
Closed
wesleysimplicio wants to merge 1 commit into
Closed
Conversation
Add 8 vitest cases for fpsStore: - trackFrame defined when SHOW_FPS=true - single frame does not update fps state - two frames compute fps - lastDurationMs rounded to 2 decimals - fps rounded to 1 decimal - 30-frame sliding window cap - totalFrames keeps incrementing past cap - trackFrame undefined when SHOW_FPS=false
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Vitest coverage for the FPS tracking store in the TUI (fpsStore), specifically exercising the trackFrame export and the $fpsState atom behavior behind the SHOW_FPS env gate.
Changes:
- Introduces a new
fpsStore.test.tssuite that mocksSHOW_FPSon/off and validates basic state updates. - Adds assertions around sample-count behavior (no update until 2+ frames), totals incrementing, and duration rounding.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+61
to
+64
| now += 333 | ||
| trackFrame!(0) | ||
|
|
||
| expect($fpsState.get().fps).toBe(3) |
Comment on lines
+72
to
+78
| now += 100 | ||
| } | ||
|
|
||
| const state = $fpsState.get() | ||
|
|
||
| expect(state.totalFrames).toBe(60) | ||
| expect(state.fps).toBe(10) |
Contributor
Author
|
Closing non-fix PR as requested — mantendo apenas PRs de fix. |
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.
What does this PR do?
test(tui): cover fpsStore trackFrame state
Root cause
The detailed rationale from the original PR body is preserved below. This template update keeps the review structure consistent with #29640.
Fix
Why this shape
This shape mirrors #29640 so reviewers can quickly compare scope, root cause, fix, tests, and related context without having to decode a custom PR description.
Tests
Original body
Related PRs / issues
Original body
Summary
test(tui): cover fpsStore trackFrame state
What Changed
Fluxo
A mudança continua seguindo o fluxo original descrito na seção preservada abaixo, sem ampliar o escopo funcional deste PR.
Visão
A padronização melhora a revisão, reduz ruído e evita deriva de formatação entre PRs abertos.
Test Plan
Original body
Summary
Add 8 vitest cases for the previously untested
trackFrame/\$fpsStateinui-tui/src/lib/fpsStore.ts.Coverage
trackFrameis a function whenSHOW_FPS=truelastDurationMsrounded to two decimal placesfpsrounded to one decimal placetotalFrameskeeps incrementing past the captrackFrameis undefined whenSHOW_FPS=falseTest plan
npx vitest run src/__tests__/fpsStore.test.ts(8/8 passed)npx vitest run(662/662 across 63 files)Generated by Hermes Turbo
Generated by Hermes Turbo