Skip to content

test(ensemble): cover navigateViewGroup clamp and CDN stale refresh#2263

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

test(ensemble): cover navigateViewGroup clamp and CDN stale refresh#2263
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-4f9d

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Jun 7, 2026

Risky behavior now covered

  • navigateViewGroup index clamping (0ce6723a): resolveNavigateViewGroupTabIndex locks in the rule that out-of-range indices are clamped before PageController.jumpToPage when the menu has items, while preserving the raw index when menuLen == 0 (PageGroup not mounted).
  • CDN stale refresh race (19b50b2e): _applyStaleRefreshOutcome / shouldApplyCdnStaleRefreshImmediately cover the cold-start path where artifact refresh is enabled and the app is initialized—bundle sync happens immediately instead of deferring to resume, preventing screens from rebuilding with stale resources.

Test files added/updated

  • modules/ensemble/test/safe_view_group_payload_index_test.dartresolveNavigateViewGroupTabIndex clamp and zero-menu edge cases
  • modules/ensemble/test/cdn_provider_test.dart — stale refresh decision matrix and immediate vs deferred bundle sync

Why these tests materially reduce regression risk

  • Navigation: A regression that stops clamping viewIndex before jumpToPage would crash or land on the wrong tab when payloads shrink; the extracted helper makes that contract explicit and unit-testable without a full widget tree.
  • CDN updates: The race fix depends on applying bundle changes before firing refresh events. Tests assert immediate sync when artifact refresh + config are present, and that updates are deferred (pending flag set, bundle unchanged) when refresh is disabled—guarding against reintroducing the stale-resource rebuild race.

Validation

flutter test test/safe_view_group_payload_index_test.dart test/cdn_provider_test.dart

All 15 tests passed.

Open in Web View Automation 

- Extract resolveNavigateViewGroupTabIndex for navigateViewGroup index clamping
- Extract CDN stale refresh outcome logic with @VisibleForTesting hooks
- Add tests for cold-start immediate bundle sync vs deferred pending updates

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