@@ -2673,4 +2673,107 @@ void main() {
26732673 ..status.equals (AnimationStatus .dismissed);
26742674 });
26752675 });
2676+
2677+ group ('recipient header navigation in multi-channel narrows' , () {
2678+ late List <Route <void >> pushedRoutes;
2679+
2680+ final channel = eg.stream ();
2681+ const testTopic = 'testTopic' ;
2682+ final message = eg.streamMessage (stream: channel, topic: testTopic);
2683+
2684+ final recipientHeaderFinder = find.byType (StreamMessageRecipientHeader );
2685+ late Rect recipientHeaderRect;
2686+
2687+ Future <void > prepare (WidgetTester tester) async {
2688+ pushedRoutes = [];
2689+ final navObserver = TestNavigatorObserver ()
2690+ ..onPushed = (route, prevRoute) => pushedRoutes.add (route);
2691+
2692+ await setupMessageListPage (tester,
2693+ narrow: const CombinedFeedNarrow (),
2694+ streams: [channel],
2695+ subscriptions: [eg.subscription (channel)],
2696+ messages: [message],
2697+ navObservers: [navObserver]);
2698+
2699+ assert (pushedRoutes.length == 1 );
2700+ pushedRoutes.clear ();
2701+
2702+ recipientHeaderRect = tester.getRect (recipientHeaderFinder);
2703+ }
2704+
2705+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/1179
2706+ testWidgets ("navigates to ChannelNarrow when tapping above or below channel name in recipient header" , (tester) async {
2707+ await prepare (tester);
2708+
2709+ final channelNameFinder = find.descendant (
2710+ of: recipientHeaderFinder,
2711+ matching: find.text (channel.name));
2712+ final channelNameRect = tester.getRect (channelNameFinder);
2713+
2714+ connection.prepare (json: eg.newestGetMessagesResult (
2715+ foundOldest: true , messages: [message]).toJson ());
2716+ // Tap just right below the top of recipient header, above and outside of
2717+ // its channel name component.
2718+ await tester.tapAt (Offset (
2719+ channelNameRect.center.dx, recipientHeaderRect.top + 1 ));
2720+ await tester.pump ();
2721+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
2722+ .initNarrow.equals (ChannelNarrow (channel.streamId));
2723+ await tester.pumpAndSettle ();
2724+
2725+ // Navigate back to original page and clear routes.
2726+ await tester.pageBack ();
2727+ await tester.pumpAndSettle ();
2728+ pushedRoutes.clear ();
2729+
2730+ connection.prepare (json: eg.newestGetMessagesResult (
2731+ foundOldest: true , messages: [message]).toJson ());
2732+ // Tap just above the bottom of recipient header, below and outside of
2733+ // its channel name component.
2734+ await tester.tapAt (Offset (
2735+ channelNameRect.center.dx, recipientHeaderRect.bottom - 1 ));
2736+ await tester.pump ();
2737+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
2738+ .initNarrow.equals (ChannelNarrow (channel.streamId));
2739+ await tester.pumpAndSettle ();
2740+ });
2741+
2742+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/1179
2743+ testWidgets ("navigates to TopicNarrow when tapping above or below topic name in recipient header" , (tester) async {
2744+ await prepare (tester);
2745+
2746+ final topicNameFinder = find.descendant (
2747+ of: recipientHeaderFinder,
2748+ matching: find.text (testTopic));
2749+ final topicNameRect = tester.getRect (topicNameFinder);
2750+
2751+ connection.prepare (json: eg.newestGetMessagesResult (
2752+ foundOldest: true , messages: [message]).toJson ());
2753+ // Tap just right below the top of recipient header, above and outside of
2754+ // its topic name component.
2755+ await tester.tapAt (Offset (
2756+ topicNameRect.center.dx, recipientHeaderRect.top + 1 ));
2757+ await tester.pump ();
2758+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
2759+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
2760+ await tester.pumpAndSettle ();
2761+
2762+ // Navigate back to original page and clear routes.
2763+ await tester.pageBack ();
2764+ await tester.pumpAndSettle ();
2765+ pushedRoutes.clear ();
2766+
2767+ connection.prepare (json: eg.newestGetMessagesResult (
2768+ foundOldest: true , messages: [message]).toJson ());
2769+ // Tap just above the bottom of recipient header, below and outside of
2770+ // its topic name component.
2771+ await tester.tapAt (Offset (
2772+ topicNameRect.center.dx, recipientHeaderRect.bottom - 1 ));
2773+ await tester.pump ();
2774+ check (pushedRoutes).single.isA <WidgetRoute >().page.isA <MessageListPage >()
2775+ .initNarrow.equals (TopicNarrow (channel.streamId, message.topic));
2776+ await tester.pumpAndSettle ();
2777+ });
2778+ });
26762779}
0 commit comments