@@ -191,6 +191,14 @@ void main() {
191191 group ('NotificationDisplayManager open' , () {
192192 late List <Route <dynamic >> pushedRoutes;
193193
194+ void takeStartingRoutes () {
195+ final expected = [
196+ (Subject it) => it.isA <WidgetRoute >().page.isA <ChooseAccountPage >(),
197+ ];
198+ check (pushedRoutes.take (expected.length)).deepEquals (expected);
199+ pushedRoutes.removeRange (0 , expected.length);
200+ }
201+
194202 Future <void > prepare (WidgetTester tester, {bool early = false }) async {
195203 await init ();
196204 pushedRoutes = [];
@@ -202,8 +210,8 @@ void main() {
202210 return ;
203211 }
204212 await tester.pump ();
205- check (pushedRoutes).length. equals ( 1 );
206- pushedRoutes. clear ();
213+ takeStartingRoutes ( );
214+ check ( pushedRoutes). isEmpty ();
207215 }
208216
209217 Future <void > openNotification (Account account, Message message) async {
@@ -289,11 +297,10 @@ void main() {
289297
290298 // Now let the GlobalStore get loaded and the app's main UI get mounted.
291299 await tester.pump ();
292- // The navigator first pushes the starting route…
293- check (pushedRoutes).length.equals (2 );
294- check (pushedRoutes[0 ]).isA <WidgetRoute >().page.isA <ChooseAccountPage >();
300+ // The navigator first pushes the starting routes…
301+ takeStartingRoutes ();
295302 // … and then the one the notification leads to.
296- matchesNavigation (check (pushedRoutes[ 1 ]) , eg.selfAccount, message);
303+ matchesNavigation (check (pushedRoutes).single , eg.selfAccount, message);
297304 });
298305
299306 testWidgets ('at app launch' , (tester) async {
@@ -313,9 +320,8 @@ void main() {
313320
314321 // Once the app is ready, we navigate to the conversation.
315322 await tester.pump ();
316- check (pushedRoutes).length.equals (2 );
317- check (pushedRoutes[0 ]).isA <WidgetRoute >().page.isA <ChooseAccountPage >();
318- matchesNavigation (check (pushedRoutes[1 ]), account, message);
323+ takeStartingRoutes ();
324+ matchesNavigation (check (pushedRoutes).single, account, message);
319325 });
320326 });
321327}
0 commit comments