Skip to content

Commit fa8a07c

Browse files
committed
action_sheet test [nfc]: Pull out showFromAppBar helper
1 parent 212afe5 commit fa8a07c

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
@@ -170,6 +170,31 @@ void main() {
170170
await tester.pump(const Duration(milliseconds: 250));
171171
}
172172

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

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

0 commit comments

Comments
 (0)