Skip to content

Commit

Permalink
refactor: cleanup boostrap
Browse files Browse the repository at this point in the history
  • Loading branch information
dtscalac committed Jun 5, 2024
1 parent c0517d8 commit 7f46b26
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions catalyst_voices/integration_test/common.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:catalyst_voices/app/app.dart';
import 'package:catalyst_voices/app/view/app_page.dart';
import 'package:catalyst_voices/configs/main_qa_patrol.dart' as app;
import 'package:catalyst_voices/configs/bootstrap.dart' as app;
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';

Expand All @@ -12,7 +12,7 @@ const _nativeAutomatorConfig = NativeAutomatorConfig(
);

Future<void> createApp(PatrolIntegrationTester $) async {
await app.main();
await app.bootstrapForTests();
await $.pumpWidgetAndSettle(const App());
}

Expand Down
13 changes: 13 additions & 0 deletions catalyst_voices/lib/configs/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:url_strategy/url_strategy.dart';

/// Initializes and runs the application provided by the [builder].
Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
WidgetsFlutterBinding.ensureInitialized();

Expand All @@ -24,3 +25,15 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {

runApp(await builder());
}

/// Initializer for integration tests, similar to [bootstrap] but:
/// - Must not call [WidgetsFlutterBinding.ensureInitialized].
/// - Must not call [runApp].
/// - Must not override [FlutterError.onError].
/// - Must be synced with [bootstrap], to run exactly the same
/// initialization logic except for the above exclusions.
Future<void> bootstrapForTests() async {
GoRouter.optionURLReflectsImperativeAPIs = true;
setPathUrlStrategy();
Bloc.observer = AppBlocObserver();
}
10 changes: 0 additions & 10 deletions catalyst_voices/lib/configs/main_qa_patrol.dart

This file was deleted.

0 comments on commit 7f46b26

Please sign in to comment.