test(flutter): delete stale like_button rollback test; harden quarantine connectivity override
like_button_test 'tap toggles icon optimistically; rollback on error': Stale survivor of the pre-MutationQueue era. The test name claims to verify rollback after error, but LikesController.toggle no longer rolls back — it adopted the same offline-first pattern as quarantine: optimistic drift write, on API failure enqueue a mutation for replay, drift state stays (user's intent persists offline). The test's `expect(heartFilled(), isTrue)` after the failed unlike happens to align with current "don't rollback" behavior by accident; the test's intent is stale. The genuine offline-first property is exercised by the quarantine test. Delete rather than rewrite — no unique coverage to preserve. quarantine connectivity override: Previous Stream.value(true) override emitted true and then closed the stream immediately. Riverpod's StreamProvider transitions loading → data → closed when the underlying stream completes, and that "closed" transition during the AsyncNotifier + mutation replayer's overlapping lifecycle was tripping "disposed during loading" on the throwing-API variant. Replace with an async* generator that yields true and then holds open via `Completer<void>().future` until tearDown disposes the container. Same .future semantics for consumers; the provider stays in AsyncData(true) throughout the test instead of transitioning to closed mid-flight. Closes the last 2 of the 6 drift-cohort surfaced failures. Fable #399. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:drift/native.dart' show NativeDatabase;
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -49,7 +51,14 @@ ProviderContainer _container({required AppDb db, required QuarantineApi api}) {
|
||||
// tearDown trips Riverpod's "disposed during loading" — visible on
|
||||
// the throwing-API variant where the catch path's await mutationQueue
|
||||
// .enqueue advances _refreshFromServer's chain enough to surface it.
|
||||
connectivityProvider.overrideWith((ref) => Stream.value(true)),
|
||||
// Use a never-closing async* generator instead of Stream.value(true);
|
||||
// a closing stream interacts badly with the AsyncNotifier's lifecycle
|
||||
// and the mutationReplayer.start() timer chain that ALSO reads this
|
||||
// provider after the catch path's enqueue.
|
||||
connectivityProvider.overrideWith((ref) async* {
|
||||
yield true;
|
||||
await Completer<void>().future; // hold open until tearDown
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user