@@ -124,7 +124,7 @@ void main() {
124124 check (find.byType (CircularProgressIndicator )).findsNothing ();
125125 });
126126
127- testWidgets (' fetch again when navigating away and back' , (tester) async {
127+ testWidgets ("don't fetch again when navigating away and back" , (tester) async {
128128 addTearDown (testBinding.reset);
129129 await testBinding.globalStore.add (eg.selfAccount, eg.initialSnapshot ());
130130 final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
@@ -145,20 +145,25 @@ void main() {
145145 await tester.tap (find.byIcon (ZulipIcons .topics));
146146 await tester.pump ();
147147 await tester.pump (Duration .zero);
148+ check (connection.takeRequests ())
149+ ..length.equals (2 ) // one for the messages request, another for the topics
150+ ..last.which ((last) => last
151+ .isA< http.Request > ()
152+ ..method.equals ('GET' )
153+ ..url.path.equals ('/api/v1/users/me/${channel .streamId }/topics' ));
148154 check (find.text ('topic A' )).findsOne ();
149155
150156 // … go back to the message list page…
151157 await tester.pageBack ();
152158 await tester.pump ();
153159
154- // … then back to the topic-list page, expecting to fetch again.
155- connection.prepare (json: GetChannelTopicsResult (
156- topics: [eg.getChannelTopicsEntry (name: 'topic B' )]).toJson ());
160+ // … then back to the topic-list page, expecting not to fetch again but
161+ // use existing data which is kept up-to-date anyway.
157162 await tester.tap (find.byIcon (ZulipIcons .topics));
158163 await tester.pump ();
159164 await tester.pump (Duration .zero);
160- check (find. text ( 'topic A' )).findsNothing ();
161- check (find.text ('topic B ' )).findsOne ();
165+ check (connection. takeRequests ( )).isEmpty ();
166+ check (find.text ('topic A ' )).findsOne ();
162167 });
163168
164169 Finder topicItemFinder = find.descendant (
@@ -221,9 +226,7 @@ void main() {
221226 origMessages: [message],
222227 newTopicStr: 'bar' ));
223228 await tester.pump ();
224- // There's still one topic item ("foo") even though the new message is in
225- // topic "bar", but the topic list doesn't get updated.
226- check (topicItemFinder).findsOne ();
229+ check (topicItemFinder).findsExactly (2 );
227230
228231 // After the move, the message with maxId moved away from "foo". The topic
229232 // actions that require `someMessageIdInTopic` are no longer available.
@@ -232,6 +235,40 @@ void main() {
232235 check (find.text ('Mark as resolved' )).findsNothing ();
233236 await tester.tap (find.text ('Cancel' ));
234237 await tester.pump ();
238+
239+ // Topic actions that require `someMessageIdInTopic` are available
240+ // for "bar", the new topic that the message moved to.
241+ await tester.longPress (find.text ('bar' ));
242+ await tester.pump (Duration (milliseconds: 150 )); // bottom-sheet animation
243+ check (find.text ('Mark as resolved' )).findsOne ();
244+ });
245+
246+ // event handling is more thoroughly tested in test/model/channel_test.dart
247+ testWidgets ('smoke resolve topic from topic action sheet' , (tester) async {
248+ final channel = eg.stream ();
249+ final messages = List .generate (10 , (i) =>
250+ eg.streamMessage (id: 100 + i, stream: channel, topic: 'foo' ));
251+
252+ await prepare (tester, channel: channel,
253+ topics: [eg.getChannelTopicsEntry (maxId: 109 , name: 'foo' )],
254+ messages: messages);
255+ await tester.longPress (topicItemFinder);
256+ await tester.pump (Duration (milliseconds: 150 )); // bottom-sheet animation
257+ check (findInTopicItemAt (0 , find.byIcon (ZulipIcons .check))).findsNothing ();
258+ check (findInTopicItemAt (0 , find.text ('foo' ))).findsOne ();
259+
260+ connection.prepare (json: {});
261+ await tester.tap (find.text ('Mark as resolved' ));
262+ await tester.pump ();
263+ await tester.pump (Duration .zero);
264+
265+ await store.handleEvent (eg.updateMessageEventMoveFrom (
266+ origMessages: messages,
267+ newTopic: eg.t ('foo' ).resolve (),
268+ propagateMode: .changeAll));
269+ await tester.pump ();
270+ check (findInTopicItemAt (0 , find.byIcon (ZulipIcons .check))).findsOne ();
271+ check (findInTopicItemAt (0 , find.text ('foo' ))).findsOne ();
235272 });
236273
237274 testWidgets ('resolved and unresolved topics' , (tester) async {
0 commit comments