Skip to content

Commit cdbd967

Browse files
committed
action_sheet test [nfc]: Parameterize a prepare by channel and topic
This `prepare` function would also be useful for some tests outside the 'showTopicActionSheet' group. Give it these params to start getting it ready to move to the outer scope. We'll add more params in the next few commits.
1 parent 4ff9842 commit cdbd967

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,26 @@ void main() {
108108
}
109109

110110
group('topic action sheet', () {
111+
final someChannel = eg.stream();
112+
const someTopic = 'my topic';
113+
111114
group('showTopicActionSheet', () {
112-
final channel = eg.stream();
113-
const topic = 'my topic';
114115
final message = eg.streamMessage(
115-
stream: channel, topic: topic, sender: eg.otherUser);
116+
stream: someChannel, topic: someTopic, sender: eg.otherUser);
116117

117118
Future<void> prepare({
119+
ZulipStream? channel,
120+
String topic = someTopic,
118121
UnreadMessagesSnapshot? unreadMsgs,
119122
}) async {
123+
final effectiveChannel = channel ?? someChannel;
124+
120125
addTearDown(testBinding.reset);
121126

122127
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot(
123128
realmUsers: [eg.selfUser, eg.otherUser],
124-
streams: [channel],
125-
subscriptions: [eg.subscription(channel)],
129+
streams: [effectiveChannel],
130+
subscriptions: [eg.subscription(effectiveChannel)],
126131
unreadMsgs: unreadMsgs));
127132
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
128133
connection = store.connection as FakeApiConnection;
@@ -144,16 +149,16 @@ void main() {
144149
testWidgets('show from inbox', (tester) async {
145150
await prepare(unreadMsgs: eg.unreadMsgs(count: 1,
146151
channels: [eg.unreadChannelMsgs(
147-
streamId: channel.streamId,
148-
topic: topic,
152+
streamId: someChannel.streamId,
153+
topic: someTopic,
149154
unreadMessageIds: [message.id],
150155
)]));
151156
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
152157
child: const HomePage()));
153158
await tester.pump();
154159
check(find.byType(InboxPageBody)).findsOne();
155160

156-
await tester.longPress(find.text(topic));
161+
await tester.longPress(find.text(someTopic));
157162
// sheet appears onscreen; default duration of bottom-sheet enter animation
158163
await tester.pump(const Duration(milliseconds: 250));
159164
checkButtons();
@@ -165,11 +170,13 @@ void main() {
165170
foundOldest: true, messages: [message]).toJson());
166171
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
167172
child: MessageListPage(
168-
initNarrow: eg.topicNarrow(channel.streamId, topic))));
173+
initNarrow: eg.topicNarrow(someChannel.streamId, someTopic))));
169174
// global store, per-account store, and message list get loaded
170175
await tester.pumpAndSettle();
171176

172-
final topicRow = find.descendant(of: find.byType(ZulipAppBar), matching: find.text(topic));
177+
final topicRow = find.descendant(
178+
of: find.byType(ZulipAppBar),
179+
matching: find.text(someTopic));
173180
await tester.longPress(topicRow);
174181
// sheet appears onscreen; default duration of bottom-sheet enter animation
175182
await tester.pump(const Duration(milliseconds: 250));
@@ -186,7 +193,7 @@ void main() {
186193
await tester.pumpAndSettle();
187194

188195
await tester.longPress(find.descendant(
189-
of: find.byType(RecipientHeader), matching: find.text(topic)));
196+
of: find.byType(RecipientHeader), matching: find.text(someTopic)));
190197
// sheet appears onscreen; default duration of bottom-sheet enter animation
191198
await tester.pump(const Duration(milliseconds: 250));
192199
checkButtons();

0 commit comments

Comments
 (0)