Skip to content

Commit 3474058

Browse files
committed
action_sheet test [nfc]: Pull out showFromRecipientHeader helper
1 parent c918101 commit 3474058

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,26 @@ void main() {
198198
await tester.pump(const Duration(milliseconds: 250));
199199
}
200200

201+
Future<void> showFromRecipientHeader(WidgetTester tester, {
202+
String topic = someTopic,
203+
StreamMessage? message,
204+
}) async {
205+
final effectiveMessage = message ?? someMessage;
206+
assert(effectiveMessage.topic.apiName == topic);
207+
208+
connection.prepare(json: eg.newestGetMessagesResult(
209+
foundOldest: true, messages: [effectiveMessage]).toJson());
210+
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
211+
child: const MessageListPage(initNarrow: CombinedFeedNarrow())));
212+
// global store, per-account store, and message list get loaded
213+
await tester.pumpAndSettle();
214+
215+
await tester.longPress(find.descendant(
216+
of: find.byType(RecipientHeader), matching: find.text(topic)));
217+
// sheet appears onscreen; default duration of bottom-sheet enter animation
218+
await tester.pump(const Duration(milliseconds: 250));
219+
}
220+
201221
group('showTopicActionSheet', () {
202222
void checkButtons() {
203223
final actionSheetFinder = find.byType(BottomSheet);
@@ -231,17 +251,7 @@ void main() {
231251

232252
testWidgets('show from recipient header', (tester) async {
233253
await prepare();
234-
connection.prepare(json: eg.newestGetMessagesResult(
235-
foundOldest: true, messages: [someMessage]).toJson());
236-
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
237-
child: const MessageListPage(initNarrow: CombinedFeedNarrow())));
238-
// global store, per-account store, and message list get loaded
239-
await tester.pumpAndSettle();
240-
241-
await tester.longPress(find.descendant(
242-
of: find.byType(RecipientHeader), matching: find.text(someTopic)));
243-
// sheet appears onscreen; default duration of bottom-sheet enter animation
244-
await tester.pump(const Duration(milliseconds: 250));
254+
await showFromRecipientHeader(tester);
245255
checkButtons();
246256
});
247257
});

0 commit comments

Comments
 (0)