Skip to content

Commit 22f6798

Browse files
committed
action_sheet test [nfc]: Pull out showFromAppBar helper
1 parent cdc1d7b commit 22f6798

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,31 @@ void main() {
173173
await tester.pump(const Duration(milliseconds: 250));
174174
}
175175

176+
Future<void> showFromAppBar(WidgetTester tester, {
177+
ZulipStream? channel,
178+
String topic = someTopic,
179+
StreamMessage? message,
180+
}) async {
181+
final effectiveChannel = channel ?? someChannel;
182+
final effectiveMessage = message ?? someMessage;
183+
assert(effectiveMessage.topic.apiName == topic);
184+
185+
connection.prepare(json: eg.newestGetMessagesResult(
186+
foundOldest: true, messages: [effectiveMessage]).toJson());
187+
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
188+
child: MessageListPage(
189+
initNarrow: eg.topicNarrow(effectiveChannel.streamId, topic))));
190+
// global store, per-account store, and message list get loaded
191+
await tester.pumpAndSettle();
192+
193+
final topicRow = find.descendant(
194+
of: find.byType(ZulipAppBar),
195+
matching: find.text(topic));
196+
await tester.longPress(topicRow);
197+
// sheet appears onscreen; default duration of bottom-sheet enter animation
198+
await tester.pump(const Duration(milliseconds: 250));
199+
}
200+
176201
group('showTopicActionSheet', () {
177202
void checkButtons() {
178203
final actionSheetFinder = find.byType(BottomSheet);
@@ -200,20 +225,7 @@ void main() {
200225

201226
testWidgets('show from app bar', (tester) async {
202227
await prepare();
203-
connection.prepare(json: eg.newestGetMessagesResult(
204-
foundOldest: true, messages: [someMessage]).toJson());
205-
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
206-
child: MessageListPage(
207-
initNarrow: eg.topicNarrow(someChannel.streamId, someTopic))));
208-
// global store, per-account store, and message list get loaded
209-
await tester.pumpAndSettle();
210-
211-
final topicRow = find.descendant(
212-
of: find.byType(ZulipAppBar),
213-
matching: find.text(someTopic));
214-
await tester.longPress(topicRow);
215-
// sheet appears onscreen; default duration of bottom-sheet enter animation
216-
await tester.pump(const Duration(milliseconds: 250));
228+
await showFromAppBar(tester);
217229
checkButtons();
218230
});
219231

0 commit comments

Comments
 (0)