test(tui): cover memoryMonitor level transitions - #22297
Closed
wesleysimplicio wants to merge 1 commit into
Closed
wesleysimplicio wants to merge 1 commit into
wesleysimplicio wants to merge 1 commit into
Conversation
Add 8 vitest cases for startMemoryMonitor: - no callbacks while heap stays in normal range - onHigh fires once on high threshold cross - onCritical fires with auto-critical trigger - evictInkCaches passes 'all' on critical - snapshot carries level/heapUsed/rss - dedup clears on normal, refires on next high - custom thresholds respected - stop() cancels interval
Contributor
There was a problem hiding this comment.
Pull request overview
Adds dedicated Vitest coverage for startMemoryMonitor in the TUI layer, validating that memory-level transitions (normal/high/critical) drive the expected callbacks and side effects (heap dumps + Ink cache eviction) and that monitoring can be cleanly stopped.
Changes:
- Adds 8 new unit tests covering level transitions, dedup behavior, snapshot contents, custom thresholds, and stop/interval cancellation.
- Mocks heap-dump and Ink cache eviction dependencies to assert triggers/arguments deterministically.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 memoryMonitor level transitions
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 memoryMonitor level transitions
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
startMemoryMonitorinui-tui/src/lib/memoryMonitor.ts.Coverage
onHighfires exactly once when heap crosses high threshold (dedup)onCriticalfires withauto-criticalheap dump triggerevictInkCachesreceives'all'on critical level{ level, heapUsed, rss }highBytes/criticalBytesthresholds respectedTest plan
npx vitest run src/__tests__/memoryMonitor.test.ts(8/8 passed)npx vitest run(662/662 across 63 files)Generated by Hermes Turbo
Generated by Hermes Turbo