Skip to content

test(ensemble): cover navigateViewGroup clamp, CDN stale refresh, storage clear#2266

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

test(ensemble): cover navigateViewGroup clamp, CDN stale refresh, storage clear#2266
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-c42c

Conversation

@cursor

@cursor cursor Bot commented Jun 8, 2026

Copy link
Copy Markdown

Risky behavior now covered

  • navigateViewGroup index clamping — Prevents PageController.jumpToPage assertions when script-provided viewIndex exceeds the tab range (regression from #0ce6723a).
  • CDN stale refresh race condition — Ensures cold-start manifest updates either sync the app bundle immediately or defer to resume, instead of firing refresh before resources are ready (regression from #19b50b2e).
  • CDN manifest freshness gating — Locks in timestamp comparison logic that decides whether to re-fetch the CDN manifest.
  • ensemble.storage.clear() dispatch ordering — Verifies binding notifications run only after async public storage removal completes, so listeners do not read stale values (regression from #8c2a52de).

Test files added/updated

File Change
modules/ensemble/test/safe_view_group_payload_index_test.dart Added resolveNavigateViewGroupTabIndex cases
modules/ensemble/test/cdn_provider_test.dart Added stale refresh immediate vs deferred paths
modules/ensemble/test/cdn_manifest_freshness_test.dart NewisCdnManifestIncomingNewer unit tests
modules/ensemble/test/ensemble_storage_clear_dispatch_test.dart NewrunEnsembleStorageClearDispatches ordering tests

Why these tests materially reduce regression risk

These areas are high blast-radius core flows (navigation, CDN updates, storage bindings) that were fixed recently with production-only changes. The extracted @visibleForTesting helpers let us assert the exact decision logic in isolation — no widgets, network, or Workmanager — so future refactors cannot silently reintroduce out-of-range tab jumps, CDN refresh races, or premature storage binding dispatches.

Validation

flutter test test/safe_view_group_payload_index_test.dart \
  test/cdn_manifest_freshness_test.dart \
  test/ensemble_storage_clear_dispatch_test.dart \
  test/cdn_provider_test.dart

All 20 tests passed.

Open in Web View Automation 

…rage clear

Extract @VisibleForTesting helpers for recent regression fixes:
- resolveNavigateViewGroupTabIndex (navigateViewGroup index clamping)
- applyStaleRefreshOutcome (CDN race condition on cold start vs resume)
- isCdnManifestIncomingNewer (CDN manifest freshness gating)
- runEnsembleStorageClearDispatches (storage.clear binding ordering)

Add focused unit tests that prove correctness without widget or network deps.

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