Files
minstrel/flutter_client/test/settings/storage_section_test.dart
T
bvandeusen 85183c455a test(flutter): re-enable drift tests after ci-flutter:1.26 ships libsqlite3-0
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>
2026-05-20 18:02:17 -04:00

74 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:minstrel/auth/auth_provider.dart';
import 'package:minstrel/settings/storage_section.dart';
import 'package:minstrel/theme/theme_data.dart';
class _MockStorage extends Mock implements FlutterSecureStorage {}
void main() {
setUpAll(() {
registerFallbackValue('');
});
testWidgets('renders Storage heading + all controls', (t) async {
final storage = _MockStorage();
when(() => storage.read(key: any(named: 'key')))
.thenAnswer((_) async => null);
when(() => storage.write(
key: any(named: 'key'), value: any(named: 'value')))
.thenAnswer((_) async {});
await t.pumpWidget(ProviderScope(
overrides: [secureStorageProvider.overrideWithValue(storage)],
child: MaterialApp(
theme: buildDarkTheme(),
home: const Scaffold(body: StorageSection()),
),
));
await t.pumpAndSettle();
expect(find.text('Storage'), findsOneWidget);
expect(find.text('Liked cache limit'), findsOneWidget);
expect(find.text('Recently-played cache limit'), findsOneWidget);
expect(find.text('Pre-fetch ahead'), findsOneWidget);
expect(find.byKey(const Key('clear_cache_button')), findsOneWidget);
expect(find.byKey(const Key('sync_now_button')), findsOneWidget);
expect(find.byKey(const Key('cache_liked_toggle')), findsOneWidget);
expect(find.byKey(const Key('liked_cap_selector')), findsOneWidget);
expect(find.byKey(const Key('rolling_cap_selector')), findsOneWidget);
expect(find.byKey(const Key('prefetch_selector')), findsOneWidget);
});
testWidgets('Clear cache button shows confirm dialog', (t) async {
final storage = _MockStorage();
when(() => storage.read(key: any(named: 'key')))
.thenAnswer((_) async => null);
when(() => storage.write(
key: any(named: 'key'), value: any(named: 'value')))
.thenAnswer((_) async {});
await t.pumpWidget(ProviderScope(
overrides: [secureStorageProvider.overrideWithValue(storage)],
child: MaterialApp(
theme: buildDarkTheme(),
home: const Scaffold(body: StorageSection()),
),
));
await t.pumpAndSettle();
await t.tap(find.byKey(const Key('clear_cache_button')));
await t.pumpAndSettle();
expect(find.text('Clear cache?'), findsOneWidget);
// Cancel returns to the original state.
await t.tap(find.text('Cancel'));
await t.pumpAndSettle();
expect(find.text('Clear cache?'), findsNothing);
});
}