Skip to content

Commit 811ab86

Browse files
committed
login test [nfc]: Move takeStartingRoutes out of prepare
This allows us to use `prepare` for testing the login page when the user is logged in. Signed-off-by: Zixuan James Li <[email protected]>
1 parent f83c795 commit 811ab86

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/widgets/login_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ void main() {
9696
final navigator = await ZulipApp.navigator;
9797
unawaited(navigator.push(LoginPage.buildRoute(serverSettings: serverSettings)));
9898
await tester.pumpAndSettle();
99-
takeStartingRoutes();
100-
check(pushedRoutes).isEmpty();
10199
}
102100

103101
final findUsernameInput = find.byWidgetPredicate((widget) =>
@@ -136,6 +134,8 @@ void main() {
136134
testWidgets('basic happy case', (tester) async {
137135
final serverSettings = eg.serverSettings();
138136
await prepare(tester, serverSettings);
137+
takeStartingRoutes();
138+
check(pushedRoutes).isEmpty();
139139
check(testBinding.globalStore.accounts).isEmpty();
140140

141141
await login(tester, eg.selfAccount);
@@ -147,6 +147,8 @@ void main() {
147147
testWidgets('trims whitespace on username', (tester) async {
148148
final serverSettings = eg.serverSettings();
149149
await prepare(tester, serverSettings);
150+
takeStartingRoutes();
151+
check(pushedRoutes).isEmpty();
150152
check(testBinding.globalStore.accounts).isEmpty();
151153

152154
await tester.enterText(findUsernameInput, ' ${eg.selfAccount.email} ');
@@ -168,6 +170,8 @@ void main() {
168170
testWidgets('account already exists', (tester) async {
169171
final serverSettings = eg.serverSettings();
170172
await prepare(tester, serverSettings);
173+
takeStartingRoutes();
174+
check(pushedRoutes).isEmpty();
171175
check(testBinding.globalStore.accounts).isEmpty();
172176
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
173177

@@ -207,6 +211,8 @@ void main() {
207211
externalAuthenticationMethods: [method]);
208212
prepareBoringImageHttpClient(); // icon on social-auth button
209213
await prepare(tester, serverSettings);
214+
takeStartingRoutes();
215+
check(pushedRoutes).isEmpty();
210216
check(testBinding.globalStore.accounts).isEmpty();
211217

212218
const otp = '186f6d085a5621ebaf1ccfc05033e8acba57dae03f061705ac1e58c402c30a31';

0 commit comments

Comments
 (0)