|
1 | 1 | import 'package:checks/checks.dart';
|
2 | 2 | import 'package:flutter/material.dart';
|
3 | 3 | import 'package:flutter_test/flutter_test.dart';
|
| 4 | +import 'package:zulip/log.dart'; |
4 | 5 | import 'package:zulip/model/database.dart';
|
5 | 6 | import 'package:zulip/widgets/app.dart';
|
6 | 7 | import 'package:zulip/widgets/inbox.dart';
|
@@ -164,5 +165,37 @@ void main() {
|
164 | 165 | check(ZulipApp.scaffoldMessenger).isNotNull();
|
165 | 166 | check(ZulipApp.ready).value.isTrue();
|
166 | 167 | });
|
| 168 | + |
| 169 | + testWidgets('reportErrorToUserBriefly shows snack bar', (tester) async { |
| 170 | + await tester.pumpWidget(const ZulipApp()); |
| 171 | + |
| 172 | + // Prior to app startup, reportErrorToUserBriefly only logs. |
| 173 | + reportErrorToUserBriefly('test error message'); |
| 174 | + check(ZulipApp.ready).value.isFalse(); |
| 175 | + await tester.pump(); |
| 176 | + check(find.text('test error message').evaluate()).isEmpty(); |
| 177 | + check(ZulipApp.ready).value.isTrue(); |
| 178 | + |
| 179 | + // After app startup, reportErrorToUserBriefly displays a snack bar. |
| 180 | + reportErrorToUserBriefly('test error message'); |
| 181 | + await tester.pump(); |
| 182 | + check(find.text('test error message').evaluate()).single; |
| 183 | + }); |
| 184 | + |
| 185 | + testWidgets('reportErrorToUserInDialog shows dialog', (tester) async { |
| 186 | + await tester.pumpWidget(const ZulipApp()); |
| 187 | + |
| 188 | + // Prior to app startup, reportErrorToUserInDialog only logs. |
| 189 | + reportErrorToUserInDialog('test error message'); |
| 190 | + check(ZulipApp.ready).value.isFalse(); |
| 191 | + await tester.pump(); |
| 192 | + check(find.text('test error message').evaluate()).isEmpty(); |
| 193 | + check(ZulipApp.ready).value.isTrue(); |
| 194 | + |
| 195 | + // After app startup, reportErrorToUserInDialog displays a dialog. |
| 196 | + reportErrorToUserInDialog('test error message'); |
| 197 | + await tester.pump(); |
| 198 | + check(find.text('test error message').evaluate()).single; |
| 199 | + }); |
167 | 200 | });
|
168 | 201 | }
|
0 commit comments