Skip to content

Commit 82f41f5

Browse files
committed
actions: Omit 'Mark as unread' for messages in unsubscribed streams.
Previously, the 'Mark as unread' button was displayed for any read message.. This pr adds a change that adds a condition to only show the button for stream messages where a subscription exists in . a new test is added to verify this new behavior as requested.
1 parent 91246ee commit 82f41f5

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,39 @@ void main() {
13401340

13411341
check(find.byIcon(Icons.mark_chat_unread_outlined).evaluate()).single;
13421342
});
1343+
testWidgets('not visible if message is in unsubscribed stream', (tester) async {
1344+
addTearDown(testBinding.reset);
1345+
1346+
final stream = eg.stream();
1347+
final readMessage = eg.streamMessage(stream: stream, flags: [MessageFlag.read]);
1348+
final narrow = TopicNarrow.ofMessage(readMessage);
1349+
1350+
// Manually set up the store, but without subscribing to the stream.
1351+
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
1352+
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
1353+
connection = store.connection as FakeApiConnection;
1354+
await store.addUser(eg.selfUser);
1355+
await store.addUser(eg.user(userId: readMessage.senderId));
1356+
await store.addStream(stream);
1357+
// Do NOT add the subscription.
1358+
1359+
// Prepare the API response for the message list.
1360+
connection.prepare(json: eg.newestGetMessagesResult(
1361+
foundOldest: true, messages: [readMessage]).toJson());
1362+
1363+
// Build the message list page.
1364+
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
1365+
child: MessageListPage(initNarrow: narrow)));
1366+
await tester.pumpAndSettle();
1367+
1368+
// Open the action sheet for the message.
1369+
await tester.longPress(find.byType(MessageContent), warnIfMissed: false);
1370+
await tester.pump(const Duration(milliseconds: 250)); // animation
1371+
check(find.byType(BottomSheet)).findsOne();
13431372

1373+
// Now, verify the button is not present.
1374+
check(find.byIcon(Icons.mark_chat_unread_outlined).evaluate()).isEmpty();
1375+
});
13441376
group('onPressed', () {
13451377
testWidgets('smoke test', (tester) async {
13461378
final message = eg.streamMessage(flags: [MessageFlag.read]);
@@ -1547,7 +1579,6 @@ void main() {
15471579
of: find.byWidget(snackbar.content),
15481580
matching: find.text(zulipLocalizations.successMessageTextCopied)));
15491581
});
1550-
15511582
testWidgets('request has an error', (tester) async {
15521583
final message = eg.streamMessage();
15531584
await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message));

0 commit comments

Comments
 (0)