|
1 | 1 | import 'package:checks/checks.dart';
|
2 | 2 | import 'package:flutter/foundation.dart';
|
3 | 3 | import 'package:flutter/material.dart';
|
| 4 | +import 'package:flutter_checks/flutter_checks.dart'; |
4 | 5 | import 'package:flutter_test/flutter_test.dart';
|
5 | 6 | import 'package:url_launcher/url_launcher.dart';
|
| 7 | +import 'package:zulip/model/settings.dart'; |
| 8 | +import 'package:zulip/widgets/app.dart'; |
6 | 9 | import 'package:zulip/widgets/dialog.dart';
|
| 10 | +import 'package:zulip/widgets/store.dart'; |
7 | 11 |
|
8 | 12 | import '../model/binding.dart';
|
9 | 13 | import 'dialog_checks.dart';
|
@@ -64,6 +68,17 @@ void main() {
|
64 | 68 | check(testBinding.takeLaunchUrlCalls()).single
|
65 | 69 | .equals((url: learnMoreButtonUrl, mode: expectedMode));
|
66 | 70 | }, variant: const TargetPlatformVariant({TargetPlatform.android, TargetPlatform.iOS}));
|
| 71 | + |
| 72 | + testWidgets('only one SingleChildScrollView created', (tester) async { |
| 73 | + await prepare(tester); |
| 74 | + |
| 75 | + showErrorDialog(context: context, title: title, message: message); |
| 76 | + await tester.pump(); |
| 77 | + checkErrorDialog(tester, expectedTitle: title, expectedMessage: message); |
| 78 | + |
| 79 | + check(find.ancestor(of: find.text(message), |
| 80 | + matching: find.byType(SingleChildScrollView))).findsOne(); |
| 81 | + }, variant: TargetPlatformVariant.all()); |
67 | 82 | });
|
68 | 83 |
|
69 | 84 | group('showSuggestedActionDialog', () {
|
@@ -113,5 +128,43 @@ void main() {
|
113 | 128 | }, variant: const TargetPlatformVariant({TargetPlatform.android, TargetPlatform.iOS}));
|
114 | 129 | });
|
115 | 130 |
|
116 |
| - // TODO(#1594): test UpgradeWelcomeDialog |
| 131 | + testWidgets('only one SingleChildScrollView created', (tester) async { |
| 132 | + addTearDown(testBinding.reset); |
| 133 | + await tester.pumpWidget(TestZulipApp()); |
| 134 | + await tester.pump(); |
| 135 | + final element = tester.element(find.byType(Placeholder)); |
| 136 | + |
| 137 | + showSuggestedActionDialog(context: element, |
| 138 | + title: 'Continue?', |
| 139 | + message: 'Do the thing?', |
| 140 | + actionButtonText: 'Sure'); |
| 141 | + await tester.pump(); |
| 142 | + |
| 143 | + check(find.ancestor(of: find.text('Do the thing?'), |
| 144 | + matching: find.byType(SingleChildScrollView))).findsOne(); |
| 145 | + }, variant: TargetPlatformVariant.all()); |
| 146 | + |
| 147 | + group('UpgradeWelcomeDialog', () { |
| 148 | + // TODO(#1594): test LegacyUpgradeState and BoolGlobalSetting.upgradeWelcomeDialogShown |
| 149 | + |
| 150 | + testWidgets('only one SingleChildScrollView created', (tester) async { |
| 151 | + final transitionDurationObserver = TransitionDurationObserver(); |
| 152 | + addTearDown(testBinding.reset); |
| 153 | + |
| 154 | + // Real ZulipApp needed because the show-dialog function calls |
| 155 | + // `await ZulipApp.navigator`. |
| 156 | + await tester.pumpWidget(ZulipApp(navigatorObservers: [transitionDurationObserver])); |
| 157 | + await tester.pump(); |
| 158 | + |
| 159 | + await testBinding.globalStore.settings |
| 160 | + .debugSetLegacyUpgradeState(LegacyUpgradeState.found); |
| 161 | + |
| 162 | + UpgradeWelcomeDialog.maybeShow(); |
| 163 | + await transitionDurationObserver.pumpPastTransition(tester); |
| 164 | + |
| 165 | + final expectedMessage = 'You’ll find a familiar experience in a faster, sleeker package.'; |
| 166 | + check(find.ancestor(of: find.text(expectedMessage), |
| 167 | + matching: find.byType(SingleChildScrollView))).findsOne(); |
| 168 | + }, variant: TargetPlatformVariant.all()); |
| 169 | + }); |
117 | 170 | }
|
0 commit comments