Skip to content

Commit 4ff9842

Browse files
committed
action_sheet test: Make some show-from-inbox setup optional in a prepare
To test showing the topic action sheet from the message list (app bar or recipient header), we don't need `store.addMessage`; in those cases, the message data comes via MessageListView's message fetch. To test showing the action sheet from the Inbox, we do need a message ID to be in the Unreads data. So, arrange that, but only in the tests (one test) that use the Inbox. While we're at it, also make this setup represent the common case where we don't have the full Message object because a message list containing the message hasn't been opened yet. When we write tests for the upcoming resolve/unresolve button in the topic action sheet, that's a case we'll want to exercise, in addition to the case where we do have the message details.
1 parent c7c60e8 commit 4ff9842

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:flutter_checks/flutter_checks.dart';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:http/http.dart' as http;
99
import 'package:zulip/api/model/events.dart';
10+
import 'package:zulip/api/model/initial_snapshot.dart';
1011
import 'package:zulip/api/model/model.dart';
1112
import 'package:zulip/api/route/channels.dart';
1213
import 'package:zulip/api/route/messages.dart';
@@ -113,17 +114,18 @@ void main() {
113114
final message = eg.streamMessage(
114115
stream: channel, topic: topic, sender: eg.otherUser);
115116

116-
Future<void> prepare() async {
117+
Future<void> prepare({
118+
UnreadMessagesSnapshot? unreadMsgs,
119+
}) async {
117120
addTearDown(testBinding.reset);
118121

119122
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot(
120123
realmUsers: [eg.selfUser, eg.otherUser],
121124
streams: [channel],
122-
subscriptions: [eg.subscription(channel)]));
125+
subscriptions: [eg.subscription(channel)],
126+
unreadMsgs: unreadMsgs));
123127
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
124128
connection = store.connection as FakeApiConnection;
125-
126-
await store.addMessage(message);
127129
}
128130

129131
void checkButtons() {
@@ -140,7 +142,12 @@ void main() {
140142
}
141143

142144
testWidgets('show from inbox', (tester) async {
143-
await prepare();
145+
await prepare(unreadMsgs: eg.unreadMsgs(count: 1,
146+
channels: [eg.unreadChannelMsgs(
147+
streamId: channel.streamId,
148+
topic: topic,
149+
unreadMessageIds: [message.id],
150+
)]));
144151
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
145152
child: const HomePage()));
146153
await tester.pump();

0 commit comments

Comments
 (0)