1- import 'dart:async' ;
21import 'dart:convert' ;
32
43import 'package:checks/checks.dart' ;
54import 'package:flutter/foundation.dart' ;
65import 'package:flutter/material.dart' ;
7- import 'package:flutter_checks/flutter_checks.dart' ;
86import 'package:flutter_test/flutter_test.dart' ;
97import 'package:http/http.dart' as http;
108import 'package:zulip/api/exception.dart' ;
@@ -17,9 +15,6 @@ import 'package:zulip/model/narrow.dart';
1715import 'package:zulip/model/store.dart' ;
1816import 'package:zulip/notifications/receive.dart' ;
1917import 'package:zulip/widgets/actions.dart' ;
20- import 'package:zulip/widgets/app.dart' ;
21- import 'package:zulip/widgets/inbox.dart' ;
22- import 'package:zulip/widgets/page.dart' ;
2318
2419import '../api/fake_api.dart' ;
2520import '../example_data.dart' as eg;
@@ -28,7 +23,6 @@ import '../model/store_checks.dart';
2823import '../model/test_store.dart' ;
2924import '../model/unreads_checks.dart' ;
3025import '../stdlib_checks.dart' ;
31- import '../test_navigation.dart' ;
3226import 'dialog_checks.dart' ;
3327import 'test_app.dart' ;
3428
@@ -157,71 +151,6 @@ void main() {
157151 await tester.pump (unregisterDelay - TestGlobalStore .removeAccountDuration);
158152 check (newConnection.isOpen).isFalse ();
159153 });
160-
161- testWidgets ("logged-out account's routes removed from nav; other accounts' remain" , (tester) async {
162- Future <void > makeUnreadTopicInInbox (int accountId, String topic) async {
163- final stream = eg.stream ();
164- final message = eg.streamMessage (stream: stream, topic: topic);
165- final store = await testBinding.globalStore.perAccount (accountId);
166- await store.addStream (stream);
167- await store.addSubscription (eg.subscription (stream));
168- await store.addMessage (message);
169- await tester.pump ();
170- }
171-
172- addTearDown (testBinding.reset);
173-
174- final account1 = eg.account (id: 1 , user: eg.user ());
175- final account2 = eg.account (id: 2 , user: eg.user ());
176- await testBinding.globalStore.add (account1, eg.initialSnapshot ());
177- await testBinding.globalStore.add (account2, eg.initialSnapshot ());
178-
179- final testNavObserver = TestNavigatorObserver ();
180- await tester.pumpWidget (ZulipApp (navigatorObservers: [testNavObserver]));
181- await tester.pump ();
182- final navigator = await ZulipApp .navigator;
183- navigator.popUntil ((_) => false ); // clear starting routes
184- await tester.pumpAndSettle ();
185-
186- final pushedRoutes = < Route <dynamic >> [];
187- testNavObserver.onPushed = (route, prevRoute) => pushedRoutes.add (route);
188- // TODO(#737): switch to a realistic setup:
189- // https://github.com/zulip/zulip-flutter/pull/1076#discussion_r1874124363
190- final account1Route = MaterialAccountWidgetRoute (
191- accountId: account1.id, page: const InboxPageBody ());
192- final account2Route = MaterialAccountWidgetRoute (
193- accountId: account2.id, page: const InboxPageBody ());
194- unawaited (navigator.push (account1Route));
195- unawaited (navigator.push (account2Route));
196- await tester.pumpAndSettle ();
197- check (pushedRoutes).deepEquals ([account1Route, account2Route]);
198-
199- await makeUnreadTopicInInbox (account1.id, 'topic in account1' );
200- final findAccount1PageContent = find.text ('topic in account1' , skipOffstage: false );
201-
202- await makeUnreadTopicInInbox (account2.id, 'topic in account2' );
203- final findAccount2PageContent = find.text ('topic in account2' , skipOffstage: false );
204-
205- final findLoadingPage = find.byType (LoadingPlaceholderPage , skipOffstage: false );
206-
207- check (findAccount1PageContent).findsOne ();
208- check (findLoadingPage).findsNothing ();
209-
210- final removedRoutes = < Route <dynamic >> [];
211- testNavObserver.onRemoved = (route, prevRoute) => removedRoutes.add (route);
212-
213- final future = logOutAccount (testBinding.globalStore, account1.id);
214- await tester.pump (TestGlobalStore .removeAccountDuration);
215- await future;
216- check (removedRoutes).single.identicalTo (account1Route);
217- check (findAccount1PageContent).findsNothing ();
218- check (findLoadingPage).findsOne ();
219-
220- await tester.pump ();
221- check (findAccount1PageContent).findsNothing ();
222- check (findLoadingPage).findsNothing ();
223- check (findAccount2PageContent).findsOne ();
224- });
225154 });
226155
227156 group ('unregisterToken' , () {
0 commit comments