test(ui): make AppUI resize/cache tests environment-independent#8
Merged
Conversation
The resize and cache-invalidation tests asserted byte-inequality of the rendered ANSI (ansi_80 != ansi_40). That conflates two things: whether AppUI re-rendered (what AppUI controls) and whether Rich produced different bytes for the two widths (terminal/Rich-version dependent). In an environment where Rich does not honor the explicit Console width, both widths render identical bytes and the value-inequality assertion fails spuriously — even though AppUI re-rendered correctly. Assert the contract AppUI actually owns instead: a width or content change is a cache miss that yields a fresh render object (identity, not value), mirroring test_cache_hit_at_same_width's 'is'. The resize test also pins the cache key to the new width. Verified red-first: a width-insensitive cache (no re-render) returns the same cached object and the identity assertion fails. The visible re-wrap stays a live-checklist item.
lavindeep
added a commit
that referenced
this pull request
Jul 2, 2026
test(ui): make AppUI resize/cache tests environment-independent
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.
A monitor's gate run flagged
test_resize_rerenders_ansifailing onui-rework(ansi_80 == ansi_40), though local + PR CI were green — a flaky, environment-dependent assertion.Cause
The resize and cache-invalidation tests asserted byte-inequality of the rendered ANSI. That conflates two things:
In an environment where Rich doesn't honor the explicit
Console(width=...), both widths render identical bytes → the value-inequality assertion fails spuriously, even though AppUI re-rendered correctly.Fix
Assert the contract AppUI actually owns: a width/content change is a cache miss that yields a fresh render object (object identity, not byte value), mirroring
test_cache_hit_at_same_width'sis. The resize test also pins the cache key to the new width. The visible re-wrap stays a live-checklist item.Verified red-first: a width-insensitive cache (no re-render) returns the same cached object and the identity assertion fails. Full gate green locally (1314 passed, mypy --strict clean).