Skip to content

test(tui): cover fpsStore trackFrame state - #22299

Closed
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:tests/tui-fps-store
Closed

test(tui): cover fpsStore trackFrame state#22299
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:tests/tui-fps-store

Conversation

@wesleysimplicio

@wesleysimplicio wesleysimplicio commented May 9, 2026

Copy link
Copy Markdown
Contributor

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

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Related PRs / issues

  • Original body preserved below for full context.
Original body

Summary

test(tui): cover fpsStore trackFrame state

What Changed

  • Standardized this PR body to the current Hermes Turbo template.
  • Preserved the original detailed description below for reference.

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

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Summary

Add 8 vitest cases for the previously untested trackFrame / \$fpsState in ui-tui/src/lib/fpsStore.ts.

Coverage

  • trackFrame is a function when SHOW_FPS=true
  • single frame does not update fps state (needs >=2 samples)
  • two frames compute fps
  • lastDurationMs rounded to two decimal places
  • fps rounded to one decimal place
  • 30-frame sliding window cap
  • totalFrames keeps incrementing past the cap
  • trackFrame is undefined when SHOW_FPS=false

Test 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

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
Copilot AI review requested due to automatic review settings May 9, 2026 05:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts suite that mocks SHOW_FPS on/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)
@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 9, 2026
@wesleysimplicio

Copy link
Copy Markdown
Contributor Author

Closing non-fix PR as requested — mantendo apenas PRs de fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants