Skip to content

test(ensemble): regression cover Page header timer dispose#2230

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

test(ensemble): regression cover Page header timer dispose#2230
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-e53c

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 22, 2026

Description

Adds a focused widget test for Page when the header uses storage-backed titleBarHeight (with listenTitleBarHeightStorage) and a storage-backed collapsible header visible expression. This exercises the production paths from fix(page): cancel header timers and dedupe storage event listeners (commit 2c45e427), which previously had no automated coverage.

Related Issue

Regression coverage automation (no filed issue).

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 cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Tests only

What Has Changed

  • Added modules/ensemble/test/widget/page_header_timer_dispose_test.dart, which mounts a minimal Page from YAML with both periodic header checks enabled, removes it from the tree, pumps past the poll intervals, and asserts no exception (undisposed Timer.periodic callbacks would typically call setState on disposed PageState and surface as FlutterError).

How to Test

  1. From repo root: melos bootstrap (if dependencies are not linked).
  2. cd modules/ensemble && flutter test test/widget/page_header_timer_dispose_test.dart

CI note: The automation sandbox 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.

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • 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

Risky behavior now covered

  • Disposed Page must not leave Timer.periodic instances running for title-bar height fallback polling (100 ms) or collapsible-header visibility polling (150 ms). If those timers are not cancelled in dispose, they continue to tick and can invoke setState after unmount.

Test files added/updated

  • modules/ensemble/test/widget/page_header_timer_dispose_test.dart (new)

Why this reduces regression risk

The fix addressed real lifecycle bugs (leaks and redundant listeners). This test is a minimal, deterministic guard: it drives the exact code paths that start the periodic timers and proves that tearing down the widget does not leave async work that throws during subsequent frame/timer pumps—catching regressions if dispose stops cancelling timers again.

Open in Web View Automation 

Adds a widget regression test for the fix that cancels periodic
titleBarHeight and collapsibleHeader visibility timers and avoids
duplicate storage listeners. Verifies unmounting the Page does not
leave periodic timers firing setState on disposed state.

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