Skip to content

Commit 9dc69b2

Browse files
chrisbobbegithub-actions[bot]
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 4304706 commit 9dc69b2

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

test/widgets/app_test.dart

+2-2
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

+3-6
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,7 @@ void main() {
436436
await setupAndTapSend(tester, prepareResponse: (int messageId) {
437437
connection.prepare(json: SendMessageResult(id: messageId).toJson());
438438
});
439-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
440-
check(errorDialogs).isEmpty();
439+
checkNoErrorDialog(tester);
441440
});
442441

443442
testWidgets('ZulipApiException', (tester) async {
@@ -506,8 +505,7 @@ void main() {
506505
check(call.allowMultiple).equals(true);
507506
check(call.type).equals(FileType.media);
508507

509-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
510-
check(errorDialogs).isEmpty();
508+
checkNoErrorDialog(tester);
511509

512510
check(controller!.content.text)
513511
.equals('see image: [Uploading image.jpg…]()\n\n');
@@ -566,8 +564,7 @@ void main() {
566564
check(call.source).equals(ImageSource.camera);
567565
check(call.requestFullMetadata).equals(false);
568566

569-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
570-
check(errorDialogs).isEmpty();
567+
checkNoErrorDialog(tester);
571568

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

test/widgets/dialog_checks.dart

+7
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)