fix(flutter): two test environment issues from CI
smoke_test was hanging in pumpAndSettle because real flutter_secure_storage MethodChannel calls don't resolve in widget tests (no platform channel registered). Override secureStorageProvider with a mocktail FlutterSecureStorage that returns null for every read, so the GoRouter redirect resolves and ServerUrlScreen renders. player_provider_test second case was crashing because constructing MinstrelAudioHandler() instantiates just_audio's AudioPlayer, which calls setMethodCallHandler during construction — that asserts unless the WidgetsFlutterBinding is initialized. Add TestWidgetsFlutterBinding.ensureInitialized() at the top of main(). Both are unit-test plumbing fixes; no production code change.
This commit is contained in:
@@ -5,6 +5,12 @@ import 'package:minstrel/player/audio_handler.dart';
|
||||
import 'package:minstrel/player/player_provider.dart';
|
||||
|
||||
void main() {
|
||||
// MinstrelAudioHandler() instantiates just_audio's AudioPlayer, which calls
|
||||
// setMethodCallHandler on a platform channel during construction. Without an
|
||||
// initialized binding the call asserts. We're not exercising real audio in
|
||||
// the test — this just gives us a working binary messenger.
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('audioHandlerProvider must be overridden — bare read throws', () {
|
||||
final container = ProviderContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
Reference in New Issue
Block a user