@@ -169,6 +169,18 @@ void main() {
169169 of: topicItemFinder.at (index),
170170 matching: finder);
171171
172+ testWidgets ('sort topics by maxId' , (tester) async {
173+ await prepare (tester, topics: [
174+ eg.getChannelTopicsEntry (name: 'A' , maxId: 3 ),
175+ eg.getChannelTopicsEntry (name: 'B' , maxId: 2 ),
176+ eg.getChannelTopicsEntry (name: 'C' , maxId: 4 ),
177+ ]);
178+
179+ check (findInTopicItemAt (0 , find.text ('C' ))).findsOne ();
180+ check (findInTopicItemAt (1 , find.text ('A' ))).findsOne ();
181+ check (findInTopicItemAt (2 , find.text ('B' ))).findsOne ();
182+ });
183+
172184 testWidgets ('show topic action sheet' , (tester) async {
173185 final channel = eg.stream ();
174186 await prepare (tester, channel: channel,
@@ -190,16 +202,36 @@ void main() {
190202 });
191203 });
192204
193- testWidgets ('sort topics by maxId' , (tester) async {
194- await prepare (tester, topics: [
195- eg.getChannelTopicsEntry (name: 'A' , maxId: 3 ),
196- eg.getChannelTopicsEntry (name: 'B' , maxId: 2 ),
197- eg.getChannelTopicsEntry (name: 'C' , maxId: 4 ),
198- ]);
205+ testWidgets ('topic action sheet before and after moves' , (tester) async {
206+ final channel = eg.stream ();
207+ final message = eg.streamMessage (id: 100 , stream: channel, topic: 'foo' );
208+ await prepare (tester, channel: channel,
209+ topics: [eg.getChannelTopicsEntry (name: 'foo' , maxId: 100 )],
210+ messages: [message]);
211+ check (topicItemFinder).findsOne ();
199212
200- check (findInTopicItemAt (0 , find.text ('C' ))).findsOne ();
201- check (findInTopicItemAt (1 , find.text ('A' ))).findsOne ();
202- check (findInTopicItemAt (2 , find.text ('B' ))).findsOne ();
213+ // Before the move, "foo"'s maxId is known to be accurate. This makes
214+ // topic actions that require `someMessageIdInTopic` available.
215+ await tester.longPress (find.text ('foo' ));
216+ await tester.pump (Duration (milliseconds: 150 )); // bottom-sheet animation
217+ check (find.text ('Mark as resolved' )).findsOne ();
218+ await tester.tap (find.text ('Cancel' ));
219+
220+ await store.handleEvent (eg.updateMessageEventMoveFrom (
221+ origMessages: [message],
222+ newTopicStr: 'bar' ));
223+ 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 ();
227+
228+ // After the move, the message with maxId moved away from "foo". The topic
229+ // actions that require `someMessageIdInTopic` are no longer available.
230+ await tester.longPress (find.text ('foo' ));
231+ await tester.pump (Duration (milliseconds: 150 )); // bottom-sheet animation
232+ check (find.text ('Mark as resolved' )).findsNothing ();
233+ await tester.tap (find.text ('Cancel' ));
234+ await tester.pump ();
203235 });
204236
205237 testWidgets ('resolved and unresolved topics' , (tester) async {
0 commit comments