All six tests had been silently skipped under @Tags(['drift']) for
6+ months, so they accumulated test-vs-implementation drift. Now
running against the libsqlite3-bearing ci-flutter:3.44 image, each
failed for a distinct reason. Diagnoses below.
audio_cache_manager_test 'usageBytes sums sizeBytes across rows':
usageBytes() is a directory walk (authoritative on-disk total,
catches orphan partials the index misses). The test inserted drift
rows but never wrote files, so the walk returned 0. The actual API
for summing drift sizeBytes is bucketUsage(). Rename to
'bucketUsage sums drift sizeBytes across rows', use that API,
assert liked+rolling == 350. Also give the two rows unique paths
per row-shape sanity.
sync_controller_test (3 200-path tests, all returning null result):
Map literals in Dart 3 with mixed value types infer as
Map<String, Object>, not Map<String, dynamic>. The sync controller
casts `resp.data as Map<String, dynamic>` (and several nested
casts), which is invariant on generics and throws TypeError. The
silent try/catch in sync() swallowed the throw and returned null.
Real JSON parsing produces Map<String, dynamic>, so this never
surfaced in production. Fix: route the test stub body through
jsonDecode(jsonEncode(body)) in _stubDio — mimics real Dio's
parsed-response shape. Affects '200 with artist upsert', '200 with
track delete', and 'like_track upsert + delete round-trip'.
quarantine_provider_test 'flag keeps drift optimistic + queues
mutation on server failure':
When the API stub throws, the controller catches + queues to
CachedMutations. The drift watch() stream in MyQuarantineController
was still in loading state when addTearDown disposed the
container, tripping Riverpod's "StreamProvider disposed during
loading" assertion. The success-path tests resolved before
tearDown so they didn't see it. Fix: await one microtask before
the test ends so the stream emits.
like_button_test 'tap toggles icon optimistically; rollback on error':
After the LikeButton was migrated to LucideHeart in the Lucide
sweep, the prior fix replaced the find.byIcon assertion with a
heartFilled() helper reading LucideHeart.filled. But likesController
.toggle() goes through an async chain (optimistic state flip + await
api.like + state notification), which one frame of tester.pump()
doesn't flush. Use pumpAndSettle after both tap and rollback toggle
so the widget rebuilds with the new state before the assertion.
After this push, the drift cohort should be all-green on the
libsqlite3-bearing image. Fable #399 / local #62.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the libsqlite3-missing skip cohort now that the ci-flutter
runner image installs libsqlite3-0 (CI-runner commit on its main).
Per-file removals (no behavior change in tests themselves — they
just stop being skipped):
- `@Tags(['drift'])` + `library;` directive from 5 files.
- `const _skipDrift = ...;` declaration + its rationale comment
from 6 files (the 5 above + like_button_test.dart, which had its
own _skipDrift for the rollback-via-drift case).
- `skip: _skipDrift` annotations from 17 test invocations across
those 6 files (16 single-line + 1 multi-line in like_button).
- Stale `@Tags(['drift']) tier covers it` reference in
home_screen_test.dart's drift-coverage comment.
Net -79 +18 lines across 7 files; 17 previously-silent tests are
now part of the CI signal. Fable #399.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI's flutter-ci runner doesn't ship libsqlite3.so. drift's NativeDatabase
fails at first use ("Failed to load dynamic library 'libsqlite3.so'").
Affected files:
- test/cache/sync_controller_test.dart (4 tests)
- test/cache/audio_cache_manager_test.dart (5 tests)
- test/settings/storage_section_test.dart (2 tests, was silently
succeeding because the drift call was best-effort but emitted
multiple-AppDb warnings)
All 11 marked with skip: '...' + a top-level @Tags(['drift']) library
declaration so they can be re-enabled by tag once the runner image has
libsqlite3-dev installed (or once we move VM tests to sqlite3/wasm).
On-device verification covers the actual cache + sync logic.
Plus two collateral fixes:
- test/cache/connectivity_provider_test.dart: connectivity_plus needs
a platform channel that doesn't exist in unit tests; reduced to a
non-null import smoke check.
- test/library/widgets_smoke_test.dart: TrackRow now contains
CachedIndicator (ConsumerWidget); wrapped TrackRow test in
ProviderScope.
Filing follow-up for the runner image fix in next commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drives /api/library/sync against drift:
- reads cursor from SyncMetadata (default 0 = full snapshot)
- 204 → just bump lastSyncAt, return zeroes
- 410 → wipe all cached entities + retry from cursor=0
- 200 → apply upserts + deletes per entity type, advance cursor
Handles all 8 entity types (artist/album/track + like_track/like_album/
like_artist + playlist/playlist_track) for both upsert and delete paths.
Composite-key entities use the "<a>:<b>" string format the server emits.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>