@@ -1470,4 +1470,108 @@ void main() {
14701470 ..status.equals (AnimationStatus .dismissed);
14711471 });
14721472 });
1473+
1474+ group ('recipient header navigation in multi-channel narrows' , () {
1475+ late List <Route <void >> pushedRoutes;
1476+ late TestNavigatorObserver navObserver;
1477+
1478+ final channel = eg.stream ();
1479+ const testTopic = 'testTopic' ;
1480+ final message = eg.streamMessage (stream: channel, topic: testTopic);
1481+
1482+ final recipientHeaderFinder = find.byType (StreamMessageRecipientHeader );
1483+ late Rect recipientHeaderRect;
1484+
1485+ Future <void > prepare (WidgetTester tester) async {
1486+ pushedRoutes = [];
1487+ navObserver = TestNavigatorObserver ()
1488+ ..onPushed = (route, prevRoute) => pushedRoutes.add (route);
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+ recipientHeaderRect = tester.getRect (recipientHeaderFinder);
1501+ }
1502+
1503+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/1179
1504+ testWidgets ("navigates to ChannelNarrow when tapping above or below channel name in recipient header" , (tester) async {
1505+ await prepare (tester);
1506+
1507+ final channelNameFinder = find.descendant (
1508+ of: recipientHeaderFinder,
1509+ matching: find.text (channel.name));
1510+ final channelNameRect = tester.getRect (channelNameFinder);
1511+
1512+ connection.prepare (json: eg.newestGetMessagesResult (
1513+ foundOldest: true , messages: [message]).toJson ());
1514+ // Tap just right below the top of recipient header, above and outside of
1515+ // its channel name component.
1516+ await tester.tapAt (Offset (
1517+ channelNameRect.center.dx, recipientHeaderRect.top + 1 ));
1518+ await tester.pump ();
1519+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1520+ .initNarrow.equals (ChannelNarrow (channel.streamId));
1521+ await tester.pumpAndSettle ();
1522+
1523+ // Navigate back to original page and clear routes.
1524+ await tester.pageBack ();
1525+ await tester.pumpAndSettle ();
1526+ pushedRoutes.clear ();
1527+
1528+ connection.prepare (json: eg.newestGetMessagesResult (
1529+ foundOldest: true , messages: [message]).toJson ());
1530+ // Tap just above the bottom of recipient header, below and outside of
1531+ // its channel name component.
1532+ await tester.tapAt (Offset (
1533+ channelNameRect.center.dx, recipientHeaderRect.bottom - 1 ));
1534+ await tester.pump ();
1535+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1536+ .initNarrow.equals (ChannelNarrow (channel.streamId));
1537+ await tester.pumpAndSettle ();
1538+ });
1539+
1540+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/1179
1541+ testWidgets ("navigates to TopicNarrow when tapping above or below topic name in recipient header" , (tester) async {
1542+ await prepare (tester);
1543+
1544+ final topicNameFinder = find.descendant (
1545+ of: recipientHeaderFinder,
1546+ matching: find.text (testTopic));
1547+ final topicNameRect = tester.getRect (topicNameFinder);
1548+
1549+ connection.prepare (json: eg.newestGetMessagesResult (
1550+ foundOldest: true , messages: [message]).toJson ());
1551+ // Tap just right below the top of recipient header, above and outside of
1552+ // its topic name component.
1553+ await tester.tapAt (Offset (
1554+ topicNameRect.center.dx, recipientHeaderRect.top + 1 ));
1555+ await tester.pump ();
1556+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1557+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
1558+ await tester.pumpAndSettle ();
1559+
1560+ // Navigate back to original page and clear routes.
1561+ await tester.pageBack ();
1562+ await tester.pumpAndSettle ();
1563+ pushedRoutes.clear ();
1564+
1565+ connection.prepare (json: eg.newestGetMessagesResult (
1566+ foundOldest: true , messages: [message]).toJson ());
1567+ // Tap just above the bottom of recipient header, below and outside of
1568+ // its topic name component.
1569+ await tester.tapAt (Offset (
1570+ topicNameRect.center.dx, recipientHeaderRect.bottom - 1 ));
1571+ await tester.pump ();
1572+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
1573+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
1574+ await tester.pumpAndSettle ();
1575+ });
1576+ });
14731577}
0 commit comments