1
- import 'dart:async' ;
2
1
import 'dart:convert' ;
3
2
4
3
import 'package:checks/checks.dart' ;
5
4
import 'package:flutter/foundation.dart' ;
6
5
import 'package:flutter/material.dart' ;
7
- import 'package:flutter_checks/flutter_checks.dart' ;
8
6
import 'package:flutter_test/flutter_test.dart' ;
9
7
import 'package:http/http.dart' as http;
10
8
import 'package:zulip/api/exception.dart' ;
@@ -17,9 +15,6 @@ import 'package:zulip/model/narrow.dart';
17
15
import 'package:zulip/model/store.dart' ;
18
16
import 'package:zulip/notifications/receive.dart' ;
19
17
import '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' ;
23
18
24
19
import '../api/fake_api.dart' ;
25
20
import '../example_data.dart' as eg;
@@ -28,7 +23,6 @@ import '../model/store_checks.dart';
28
23
import '../model/test_store.dart' ;
29
24
import '../model/unreads_checks.dart' ;
30
25
import '../stdlib_checks.dart' ;
31
- import '../test_navigation.dart' ;
32
26
import 'dialog_checks.dart' ;
33
27
import 'test_app.dart' ;
34
28
@@ -157,71 +151,6 @@ void main() {
157
151
await tester.pump (unregisterDelay - TestGlobalStore .removeAccountDuration);
158
152
check (newConnection.isOpen).isFalse ();
159
153
});
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
- });
225
154
});
226
155
227
156
group ('unregisterToken' , () {
0 commit comments