@@ -165,11 +165,14 @@ void main() {
165165 // Regression test for: https://github.com/zulip/zulip-flutter/issues/1717
166166 final stream = eg.stream ();
167167 // Open the page on a topic with the literal name "general chat".
168- final topic = eg.defaultRealmEmptyTopicDisplayName;
169- final topicNarrow = eg.topicNarrow (stream.streamId, topic);
168+ final topicNarrow = eg.topicNarrow (
169+ stream.streamId,
170+ eg.defaultRealmEmptyTopicDisplayName);
171+ final message = eg.streamMessage (
172+ stream: stream, topic: '' , content: "<p>a message</p>" );
170173 await setupMessageListPage (tester, narrow: topicNarrow,
171174 subscriptions: [eg.subscription (stream)],
172- messages: [eg. streamMessage (stream : stream, topic : topic, content : "<p>a message</p>" ) ]);
175+ messages: [message]);
173176 final state = MessageListPage .ancestorOf (tester.element (find.text ("a message" )));
174177 // The page's narrow has been updated; the topic is "", not "general chat".
175178 check (state.narrow).equals (eg.topicNarrow (stream.streamId, '' ));
@@ -240,7 +243,7 @@ void main() {
240243 await setupMessageListPage (tester,
241244 narrow: eg.topicNarrow (channel.streamId, '' ),
242245 subscriptions: [eg.subscription (channel)],
243- messageCount : 1 );
246+ messages : [eg. streamMessage (stream : channel, topic : '' )] );
244247 checkAppBarChannelTopic (
245248 channel.name, eg.defaultRealmEmptyTopicDisplayName);
246249 });
@@ -282,7 +285,8 @@ void main() {
282285 final channel = eg.stream ();
283286 await setupMessageListPage (tester, narrow: eg.topicNarrow (channel.streamId, 'hi' ),
284287 navObservers: [navObserver],
285- subscriptions: [eg.subscription (channel)], messageCount: 1 );
288+ subscriptions: [eg.subscription (channel)],
289+ messages: [eg.streamMessage (stream: channel, topic: 'hi' )]);
286290
287291 // Clear out initial route.
288292 assert (pushedRoutes.length == 1 );
@@ -320,7 +324,7 @@ void main() {
320324 await setupMessageListPage (tester,
321325 narrow: eg.topicNarrow (channel.streamId, topic),
322326 streams: [channel], subscriptions: [eg.subscription (channel)],
323- messageCount : 1 );
327+ messages : [eg. streamMessage (stream : channel, topic : topic)] );
324328 await store.handleEvent (eg.userTopicEvent (
325329 channel.streamId, topic, UserTopicVisibilityPolicy .muted));
326330 await tester.pump ();
@@ -1400,9 +1404,9 @@ void main() {
14001404 final otherSubscription = eg.subscription (otherChannel);
14011405 final narrow = eg.topicNarrow (channel.streamId, topic);
14021406
1403- void prepareGetMessageResponse (List <Message > messages) {
1407+ void prepareGetMessageResponse (List <Message > messages, { bool foundOldest = false } ) {
14041408 connection.prepare (json: eg.newestGetMessagesResult (
1405- foundOldest: false , messages: messages).toJson ());
1409+ foundOldest: foundOldest , messages: messages).toJson ());
14061410 }
14071411
14081412 Future <void > handleMessageMoveEvent (List <StreamMessage > messages, String newTopic, {int ? newChannelId}) async {
@@ -1463,10 +1467,23 @@ void main() {
14631467 check (find.textContaining ('Existing message' ).evaluate ()).length.equals (0 );
14641468 check (find.textContaining ('Message to move' ).evaluate ()).length.equals (1 );
14651469
1470+ final newChannel = eg.stream ();
14661471 final existingMessage = eg.streamMessage (
1467- stream: eg.stream (), topic: 'new topic' , content: 'Existing message' );
1468- prepareGetMessageResponse ([existingMessage, message]);
1469- await handleMessageMoveEvent ([message], 'new topic' );
1472+ stream: newChannel, topic: 'new topic' , content: 'Existing message' );
1473+ prepareGetMessageResponse (
1474+ // `foundOldest: true` just to avoid having to prepare a fetch-older
1475+ // response when a scroll-metrics notification occurs. (I don't really
1476+ // understand what causes that scroll-metrics notification, but it's not
1477+ // the focus of this test.)
1478+ foundOldest: true ,
1479+ [
1480+ existingMessage,
1481+ Message .fromJson (deepToJson (message) as Map <String , dynamic >
1482+ ..['stream_id' ] = newChannel.streamId
1483+ ..['subject' ] = 'new topic' ),
1484+ ]);
1485+ await handleMessageMoveEvent ([message],
1486+ 'new topic' , newChannelId: newChannel.streamId);
14701487 await tester.pump (const Duration (seconds: 1 ));
14711488
14721489 check (find.textContaining ('Existing message' ).evaluate ()).length.equals (1 );
@@ -2274,7 +2291,7 @@ void main() {
22742291 doTest (expected: false , ChannelNarrow (subscription.streamId),
22752292 mkMessage: () => eg.streamMessage (stream: subscription));
22762293 doTest (expected: false , TopicNarrow (subscription.streamId, eg.t (topic)),
2277- mkMessage: () => eg.streamMessage (stream: subscription));
2294+ mkMessage: () => eg.streamMessage (stream: subscription, topic : topic ));
22782295 doTest (expected: false , DmNarrow .withUsers ([], selfUserId: eg.selfUser.userId),
22792296 mkMessage: () => eg.streamMessage (stream: subscription, topic: topic));
22802297 doTest (expected: true , StarredMessagesNarrow (),
0 commit comments