Skip to content

test(ensemble): Page header storage timer dispose regression tests#2237

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

test(ensemble): Page header storage timer dispose regression tests#2237
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-fa9b

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 26, 2026

Description

Adds widget regression tests for Page lifecycle when the header uses storage-driven titleBarHeight (with listenTitleBarHeightStorage) or a storage-driven collapsibleHeader.visible expression. These code paths start periodic Timers and StreamSubscriptions; the recent fix(page) change ensures they are cancelled in dispose. The tests mount a minimal Page, tear it down, advance the fake clock past multiple poll intervals, and assert no post-dispose exceptions (for example setState() called after dispose).

Related Issue

N/A (coverage automation for recently merged fix(page): cancel header timers and dedupe storage event listeners).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • Tests only (not listed in template — improves regression coverage)

What Has Changed

  • Added modules/ensemble/test/widget/page_storage_timer_dispose_test.dart with two testWidgets cases covering title-bar height polling and collapsible-header visibility polling after widget removal.

Risky behavior now covered

  • Uncancelled periodic timers on PageState when listenTitleBarHeightStorage is enabled with titleBarHeight referencing ensemble.storage.* (100 ms poll fallback).
  • Uncancelled collapsible-header visibility poll timer when collapsibleHeader.enabled is true and visible references storage (150 ms poll).

Test files added/updated

  • Added: modules/ensemble/test/widget/page_storage_timer_dispose_test.dart

Why these tests materially reduce regression risk

They fail loudly if dispose ever stops cancelling those timers: the periodic callbacks would still run after unmount and can trigger setState on a defunct element, causing flaky production crashes and hard-to-debug CI noise. The assertions use deterministic pump/pumpWidget only (no network, no wall-clock).

How to Test

From modules/ensemble:

flutter test test/widget/page_storage_timer_dispose_test.dart

Validation note

The automation environment did not have the Flutter SDK on PATH, so flutter test was not executed here. Please run the command above locally or in CI to confirm.

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass (not run in this environment — see above)
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Screenshots / Videos

N/A

Open in Web View Automation 

Widget tests mount Page with storage-bound titleBarHeight and collapsible
visibility, remove the widget, then advance fake clock past multiple poll
intervals. Ensures dispose cancels periodic timers so no setState runs after
dispose (regression guard for page header lifecycle fix).

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