Skip to content

Commit f4c5ff3

Browse files
committed
test [nfc]: Factor out checkNoErrorDialog helper
With zulip#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 fa09289 commit f4c5ff3

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
@@ -427,8 +427,7 @@ void main() {
427427
await setupAndTapSend(tester, prepareResponse: (int messageId) {
428428
connection.prepare(json: SendMessageResult(id: messageId).toJson());
429429
});
430-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
431-
check(errorDialogs).isEmpty();
430+
checkNoErrorDialog(tester);
432431
});
433432

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

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

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

560-
final errorDialogs = tester.widgetList(find.byType(AlertDialog));
561-
check(errorDialogs).isEmpty();
558+
checkNoErrorDialog(tester);
562559

563560
check(controller!.content.text)
564561
.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)