@@ -1470,4 +1470,110 @@ void main() {
1470
1470
..status.equals (AnimationStatus .dismissed);
1471
1471
});
1472
1472
});
1473
+
1474
+ group ('recipient header navigation in multi-channel narrows' , () {
1475
+ late List <Route <void >> pushedRoutes;
1476
+ late TestNavigatorObserver navObserver;
1477
+ late ZulipStream channel;
1478
+ late StreamMessage message;
1479
+ late Finder recipientHeaderFinder;
1480
+ late Rect recipientHeaderRect;
1481
+ const testTopic = 'testTopic' ;
1482
+
1483
+ Future <void > prepare (WidgetTester tester) async {
1484
+ pushedRoutes = < Route <void >> [];
1485
+ navObserver = TestNavigatorObserver ()
1486
+ ..onPushed = (route, prevRoute) => pushedRoutes.add (route);
1487
+ channel = eg.stream ();
1488
+ message = eg.streamMessage (stream: channel, topic: testTopic);
1489
+
1490
+ await setupMessageListPage (tester,
1491
+ narrow: const CombinedFeedNarrow (),
1492
+ streams: [channel],
1493
+ subscriptions: [eg.subscription (channel)],
1494
+ messages: [message],
1495
+ navObservers: [navObserver]);
1496
+
1497
+ assert (pushedRoutes.length == 1 );
1498
+ pushedRoutes.clear ();
1499
+
1500
+ recipientHeaderFinder = find.byType (StreamMessageRecipientHeader );
1501
+ recipientHeaderRect = tester.getRect (recipientHeaderFinder);
1502
+ }
1503
+
1504
+ testWidgets ("navigates to ChannelNarrow when tapping above or below channel name in recipient header" ,
1505
+ (tester) async {
1506
+ await prepare (tester);
1507
+
1508
+ final channelNameFinder = find.descendant (
1509
+ of: recipientHeaderFinder,
1510
+ matching: find.text (channel.name));
1511
+ final channelNameRect = tester.getRect (channelNameFinder);
1512
+
1513
+ connection.prepare (json: eg.newestGetMessagesResult (
1514
+ foundOldest: true , messages: [message]).toJson ());
1515
+ // First tap: 1 px below the top of recepient header
1516
+ // at channelName x coordinate
1517
+ await tester.tapAt (Offset (
1518
+ channelNameRect.center.dx, recipientHeaderRect.top + 1 ));
1519
+
1520
+ await tester.pump ();
1521
+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1522
+ .initNarrow.equals (ChannelNarrow (channel.streamId));
1523
+ await tester.pumpAndSettle ();
1524
+
1525
+ // Navigate back to original page and clear routes
1526
+ await tester.pageBack ();
1527
+ await tester.pumpAndSettle ();
1528
+ pushedRoutes.clear ();
1529
+
1530
+ connection.prepare (json: eg.newestGetMessagesResult (
1531
+ foundOldest: true , messages: [message]).toJson ());
1532
+ // Second tap: 1 px above the bottom of the recipient header
1533
+ // at channelName x coordinate
1534
+ await tester.tapAt (Offset (
1535
+ channelNameRect.center.dx, channelNameRect.bottom - 1 ));
1536
+ await tester.pump ();
1537
+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1538
+ .initNarrow.equals (ChannelNarrow (channel.streamId));
1539
+ await tester.pumpAndSettle ();
1540
+ });
1541
+
1542
+ testWidgets ("navigates to TopicNarrow when tapping above or below topic name in recipient header" ,
1543
+ (tester) async {
1544
+ await prepare (tester);
1545
+
1546
+ final topicNameFinder = find.descendant (
1547
+ of: recipientHeaderFinder,
1548
+ matching: find.text (testTopic));
1549
+ final topicNameRect = tester.getRect (topicNameFinder);
1550
+
1551
+ connection.prepare (json: eg.newestGetMessagesResult (
1552
+ foundOldest: true , messages: [message]).toJson ());
1553
+ // First tap: 1 px below the top of recepient header
1554
+ // at topicName x coordinate
1555
+ await tester.tapAt (Offset (
1556
+ topicNameRect.center.dx, recipientHeaderRect.top + 1 ));
1557
+ await tester.pump ();
1558
+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1559
+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
1560
+ await tester.pumpAndSettle ();
1561
+
1562
+ // Navigate back to original page and clear routes
1563
+ await tester.pageBack ();
1564
+ await tester.pumpAndSettle ();
1565
+ pushedRoutes.clear ();
1566
+
1567
+ connection.prepare (json: eg.newestGetMessagesResult (
1568
+ foundOldest: true , messages: [message]).toJson ());
1569
+ // Second tap: 1 px above the bottom of the recipient header
1570
+ // at topicName x coordinate
1571
+ await tester.tapAt (Offset (
1572
+ topicNameRect.center.dx, recipientHeaderRect.bottom - 1 ));
1573
+ await tester.pump ();
1574
+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1575
+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
1576
+ await tester.pumpAndSettle ();
1577
+ });
1578
+ });
1473
1579
}
0 commit comments