Skip to content

Commit 90d8cb5

Browse files
chrisbobbePIG208
authored andcommitted
test [nfc]: Factor out checkNoErrorDialog helper
With #996, these tests will have to start checking for separate per-platform flavors of alert dialog. Best if they all do so through this one codepath.
1 parent 64d5e9d commit 90d8cb5

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

test/widgets/app_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ void main() {
280280
check(ZulipApp.ready).value.isFalse();
281281
await tester.pump();
282282
check(findSnackBarByText(message).evaluate()).isEmpty();
283-
check(find.byType(AlertDialog).evaluate()).isEmpty();
283+
checkNoErrorDialog(tester);
284284

285285
check(ZulipApp.ready).value.isTrue();
286286
// After app startup, reportErrorToUserBriefly displays a SnackBar.
287287
reportErrorToUserBriefly(message, details: details);
288288
await tester.pumpAndSettle();
289289
check(findSnackBarByText(message).evaluate()).single;
290-
check(find.byType(AlertDialog).evaluate()).isEmpty();
290+
checkNoErrorDialog(tester);
291291

292292
// Open the error details dialog.
293293
await tester.tap(find.text('Details'));

test/widgets/compose_box_test.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ void main() {
426426
await setupAndTapSend(tester, prepareResponse: (int messageId) {
427427
connection.prepare(json: SendMessageResult(id: messageId).toJson());
428428
});
429-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
430-
check(errorDialogs).isEmpty();
429+
checkNoErrorDialog(tester);
431430
});
432431

433432
testWidgets('ZulipApiException', (tester) async {
@@ -496,8 +495,7 @@ void main() {
496495
check(call.allowMultiple).equals(true);
497496
check(call.type).equals(FileType.media);
498497

499-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
500-
check(errorDialogs).isEmpty();
498+
checkNoErrorDialog(tester);
501499

502500
check(controller!.content.text)
503501
.equals('see image: [Uploading image.jpg…]()\n\n');
@@ -556,8 +554,7 @@ void main() {
556554
check(call.source).equals(ImageSource.camera);
557555
check(call.requestFullMetadata).equals(false);
558556

559-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
560-
check(errorDialogs).isEmpty();
557+
checkNoErrorDialog(tester);
561558

562559
check(controller!.content.text)
563560
.equals('see image: [Uploading image.jpg…]()\n\n');

test/widgets/dialog_checks.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import 'package:checks/checks.dart';
12
import 'package:flutter/material.dart';
3+
import 'package:flutter_checks/flutter_checks.dart';
24
import 'package:flutter_test/flutter_test.dart';
35
import 'package:zulip/widgets/dialog.dart';
46

@@ -26,6 +28,11 @@ Widget checkErrorDialog(WidgetTester tester, {
2628
matching: find.widgetWithText(TextButton, 'OK')));
2729
}
2830

31+
// TODO(#996) update this to check for per-platform flavors of alert dialog
32+
void checkNoErrorDialog(WidgetTester tester) {
33+
check(find.byType(AlertDialog)).findsNothing();
34+
}
35+
2936
/// In a widget test, check that [showSuggestedActionDialog] was called
3037
/// with the right text.
3138
///

0 commit comments

Comments
 (0)