Write integration tests for GoRouter route configuration
epic-navigation-and-gesture-accessibility-foundation-task-007 — Write integration tests verifying that: all five StatefulShellRoute branches are reachable by name, PopScope is active and swipe-back is suppressed on each branch, route metadata lookup returns correct labels and flags for each declared route, and navigation between branches does not lose the previously active sub-route.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
The most complex test is state preservation across tab switches. Use `StatefulShellRoute`'s `navigatorKey` per branch to access each branch's `Navigator` state independently. To test `PopScope`, find the `PopScope` widget via `tester.widget
Avoid testing internal GoRouter state; test only observable widget tree outcomes. Use `addTearDown(router.dispose)` in each test to prevent router state leaking between tests. Consider a shared `buildTestApp(GoRouter router)` helper that wraps `ProviderScope` + `MaterialApp.router` to reduce boilerplate across test cases.
Testing Requirements
Use `flutter_test` exclusively — no `integration_test` package required (avoids needing a connected device). Structure tests in a `group('NavigationRouteConfig', ...)` block with sub-groups per concern: `group('branch reachability', ...)`, `group('PopScope suppression', ...)`, `group('state preservation', ...)`, `group('route metadata', ...)`. Use `ProviderScope` with `overrides` to inject fake auth and repository providers. Use `GoRouter`'s `WidgetsApp` or `MaterialApp.router` in test pump.
For the state preservation test: push a detail route on branch 0, call `shellNavigator.goBranch(1)`, then `shellNavigator.goBranch(0)`, assert original sub-route widget is still in the tree. Minimum: 10 distinct test cases covering all stated acceptance criteria.
StatefulShellRoute branch navigator state can interact unexpectedly with GoRouter's imperative navigation (go, push, replace), causing state snapshots to desync from actual route stacks. This could manifest as a user returning to a tab and seeing a different screen than expected, breaking the core motor-fatigue promise.
Mitigation & Contingency
Mitigation: Write integration tests that simulate cross-tab navigation with nested pushes before any UI layer is built. Pin go_router to a tested minor version and review the StatefulShellRoute changelog before upgrading.
Contingency: If branch navigator state consistently desyncs, fall back to a manual stack snapshot strategy using a custom NavigatorObserver that records and replays navigation events independently of StatefulShellRoute internals.
Persisted navigation stacks in shared_preferences can become stale or corrupt if route paths are renamed during development, causing app crashes or infinite redirect loops on cold start for users who have an old snapshot.
Mitigation & Contingency
Mitigation: Version the persisted schema with a format key. On app start, validate that all stored route paths exist in the current route config before restoring; silently discard invalid entries rather than crashing.
Contingency: Implement a safe-mode cold start that skips state restoration after a detected crash (via a dirty-launch flag written at startup and cleared on successful first frame), falling back to the default root tab.