Files
minstrel/flutter_client/test
bvandeusen 83a7099db3 test(flutter): stub the transitive provider deps the drift cohort needs
Last 2 of the 6 surfaced drift-cohort failures. Diagnoses below.

quarantine_provider_test 'flag keeps drift optimistic + queues
mutation on server failure':
  MyQuarantineController.build() schedules unawaited _refreshFromServer()
  which reads connectivityProvider (a StreamProvider<bool>). In tests
  without an override, that stream never emits — its real impl listens
  to connectivity_plus's platform channel which has no fixture in
  flutter test. The success-path quarantine tests resolve their main
  flow before _refreshFromServer's chain reaches the connectivity read,
  so they don't trip the "disposed during loading" guard at tearDown.
  The throwing-API variant's `await ref.read(mutationQueueProvider)
  .enqueue(...)` advances enough async work that the connectivity read
  IS reached, then container.dispose() trips Riverpod's invariant.

  Fix: override connectivityProvider in the shared _container helper
  with `Stream.value(true)` so it resolves immediately. The previous
  `await Future.delayed(Duration.zero)` workaround is removed — the
  cleaner fix makes that band-aid unnecessary.

like_button_test 'tap toggles icon optimistically; rollback on error':
  LikesController.toggle:
    final user = _ref.read(authControllerProvider).value;
    if (user == null) return;
  The test only overrode `likesApiProvider`; authControllerProvider was
  in AsyncLoading state at toggle() time → user was null → early return
  → no drift write → likedIdsProvider never emits "liked" → heart never
  fills → assertion fails. The test would never have passed against the
  current controller; it was a stale survivor of an older API.

  Fix: stub authControllerProvider with _FakeAuthController that yields
  User(id: 'u1', …) immediately. Also add overrides for appDbProvider
  (NativeDatabase.memory, bypasses drift_flutter's Timer) and
  connectivityProvider (Stream.value(true), unblocks cacheFirst's
  isOnline check) — both are transitive dependencies of
  likedIdsProvider's cacheFirst.

After this push, the full drift cohort should be all-green. Fable #399
/ local #62 closes when CI lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 19:12:23 -04:00
..