Skip to content

test(ensemble): cover Page header storage listener dispose cleanup#2240

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-b1a6
Draft

test(ensemble): cover Page header storage listener dispose cleanup#2240
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-b1a6

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 28, 2026

Summary

Adds widget tests for the PageState fix in 2c45e427 that deduped storage event listeners and cancelled periodic header poll timers on dispose.

Risky behavior now covered

  • Storage-bound titleBarHeight updates: Verifies AppBar height reacts when ensemble.storage.headerHeight changes while the page is mounted (poll fallback path).
  • Collapsible header visibility: Verifies AppBar collapses when ensemble.storage.headerVisible becomes false.
  • Timer cleanup on dispose: Verifies disposed pages do not throw when storage values keep changing after unmount — guarding against the regression where periodic timers were never cancelled.

Test files added/updated

  • modules/ensemble/test/widget/page_header_storage_listeners_test.dart (new, 4 tests)

Why these tests materially reduce regression risk

The original bug registered duplicate ModelChangeEvent listeners and leaked periodic timers, which could cause redundant rebuilds, memory leaks, and setState() after dispose. These tests exercise the header storage integration paths that previously had zero coverage and assert both live reactivity and clean teardown — the two failure modes that motivated the production fix.

Validation

flutter test test/widget/page_header_storage_listeners_test.dart

All 4 tests pass. Tests mock path_provider for GetStorage and are deterministic/independent.

Open in Web View Automation 

Add widget tests for the PageState fix that dedupes storage event
listeners and cancels periodic header poll timers on dispose.

Covers reactive titleBarHeight/collapsibleHeader updates while mounted
and verifies disposed pages do not throw when storage changes continue.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant