forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup_failure_app_test.dart
More file actions
42 lines (35 loc) · 1.82 KB
/
Copy pathstartup_failure_app_test.dart
File metadata and controls
42 lines (35 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:omi/startup_failure_app.dart';
void main() {
group('StartupFailureApp', () {
testWidgets('renders the actual error text instead of a blank screen', (tester) async {
// The regression this guards: a StateError thrown by
// validateApplicationStartupRouting() used to leave the launch storyboard
// up forever, because runApp() was never reached and the zone handler only
// called debugPrint — invisible in profile and release builds.
final error = StateError(
'Profile local_dev requires a loopback or private-network API endpoint; '
'use mobile_beta for https://api.omiapi.com/.',
);
await tester.pumpWidget(StartupFailureApp(error: error, stack: StackTrace.current));
expect(find.text('Omi could not start'), findsOneWidget);
expect(
find.textContaining('requires a loopback or private-network API endpoint', findRichText: true),
findsOneWidget,
);
});
testWidgets('renders without any provider, service or localisation scope', (tester) async {
// It must survive being shown when startup itself failed, so it cannot
// depend on anything _init() sets up. Pumping it bare is the assertion.
await tester.pumpWidget(StartupFailureApp(error: Exception('boom'), stack: null));
expect(tester.takeException(), isNull);
expect(find.byType(MaterialApp), findsOneWidget);
});
testWidgets('error text is selectable so it can be copied off-device', (tester) async {
// There is no debugger attached in the situation this screen exists for.
await tester.pumpWidget(StartupFailureApp(error: Exception('copy me'), stack: null));
expect(find.byType(SelectableText), findsOneWidget);
});
});
}