@@ -1176,6 +1176,86 @@ void main() {
1176
1176
takeStartingRoutes (account: accountB);
1177
1177
matchesNavigation (check (pushedRoutes).single, accountB, message);
1178
1178
});
1179
+
1180
+ testWidgets ('notification switches account only when from different account' , (tester) async {
1181
+ addTearDown (testBinding.reset);
1182
+
1183
+ final accountA = eg.selfAccount;
1184
+ final accountB = eg.otherAccount;
1185
+ final message = eg.streamMessage ();
1186
+
1187
+ await testBinding.globalStore.add (accountA, eg.initialSnapshot ());
1188
+ await testBinding.globalStore.add (accountB, eg.initialSnapshot ());
1189
+
1190
+ await prepare (tester, early: true );
1191
+ await tester.pump ();
1192
+ takeStartingRoutes (account: accountA);
1193
+
1194
+ Route <dynamic >? topRoute;
1195
+ final navigator = await ZulipApp .navigator;
1196
+ navigator.popUntil ((r) {
1197
+ topRoute = r;
1198
+ return true ;
1199
+ });
1200
+ check (topRoute).isA <AccountRoute >().accountId.equals (accountA.id);
1201
+
1202
+ await openNotification (tester, accountA, message);
1203
+ navigator.popUntil ((r) {
1204
+ topRoute = r;
1205
+ return true ;
1206
+ });
1207
+ check (topRoute).isA <MaterialAccountWidgetRoute >()
1208
+ ..accountId.equals (accountA.id)
1209
+ ..page.isA <MessageListPage >();
1210
+
1211
+ await openNotification (tester, accountB, message);
1212
+ navigator.popUntil ((r) {
1213
+ topRoute = r;
1214
+ return true ;
1215
+ });
1216
+ check (topRoute).isA <MaterialAccountWidgetRoute >()
1217
+ ..accountId.equals (accountB.id)
1218
+ ..page.isA <MessageListPage >();
1219
+ });
1220
+
1221
+ testWidgets ('notification preserves navigation stack when in same account' , (tester) async {
1222
+ addTearDown (testBinding.reset);
1223
+
1224
+ final account = eg.selfAccount;
1225
+ final message = eg.streamMessage ();
1226
+
1227
+ await testBinding.globalStore.add (account, eg.initialSnapshot ());
1228
+
1229
+ await prepare (tester, early: true );
1230
+ await tester.pump ();
1231
+ takeStartingRoutes (account: account);
1232
+
1233
+ Route <dynamic >? topRoute;
1234
+ final navigator = await ZulipApp .navigator;
1235
+ navigator.popUntil ((r) {
1236
+ topRoute = r;
1237
+ return true ;
1238
+ });
1239
+ check (topRoute).isA <AccountRoute >().accountId.equals (account.id);
1240
+
1241
+ await openNotification (tester, account, message);
1242
+ navigator.popUntil ((r) {
1243
+ topRoute = r;
1244
+ return true ;
1245
+ });
1246
+ check (topRoute).isA <MaterialAccountWidgetRoute >()
1247
+ ..accountId.equals (account.id)
1248
+ ..page.isA <MessageListPage >();
1249
+
1250
+ navigator.pop ();
1251
+ await tester.pumpAndSettle ();
1252
+ navigator.popUntil ((r) {
1253
+ topRoute = r;
1254
+ return true ;
1255
+ });
1256
+ check (topRoute).isA <AccountRoute >()
1257
+ .accountId.equals (account.id);
1258
+ });
1179
1259
});
1180
1260
1181
1261
group ('NotificationOpenPayload' , () {
0 commit comments