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