Skip to content

Commit 767d40c

Browse files
committed
action_sheet test: Also test showing channel sheet from topic list app bar
1 parent 9703379 commit 767d40c

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import 'package:zulip/widgets/message_list.dart';
3434
import 'package:share_plus_platform_interface/method_channel/method_channel_share.dart';
3535
import 'package:zulip/widgets/read_receipts.dart';
3636
import 'package:zulip/widgets/subscription_list.dart';
37+
import 'package:zulip/widgets/topic_list.dart';
3738
import 'package:zulip/widgets/user.dart';
3839
import '../api/fake_api.dart';
3940

@@ -201,7 +202,7 @@ void main() {
201202
await tester.pump(const Duration(milliseconds: 250));
202203
}
203204

204-
Future<void> showFromAppBar(WidgetTester tester, {
205+
Future<void> showFromMsglistAppBar(WidgetTester tester, {
205206
ZulipStream? channel,
206207
required Narrow narrow,
207208
}) async {
@@ -243,6 +244,22 @@ void main() {
243244
await tester.pump(const Duration(milliseconds: 250));
244245
}
245246

247+
Future<void> showFromTopicListAppBar(WidgetTester tester) async {
248+
final transitionDurationObserver = TransitionDurationObserver();
249+
250+
connection.prepare(json: GetStreamTopicsResult(topics: []).toJson());
251+
await tester.pumpWidget(TestZulipApp(
252+
navigatorObservers: [transitionDurationObserver],
253+
accountId: eg.selfAccount.id,
254+
child: TopicListPage(streamId: someChannel.streamId)));
255+
await tester.pump();
256+
257+
await tester.longPress(find.descendant(
258+
of: find.byType(ZulipAppBar),
259+
matching: find.text(someChannel.name)));
260+
await transitionDurationObserver.pumpPastTransition(tester);
261+
}
262+
246263
final actionSheetFinder = find.byType(BottomSheet);
247264
Finder findButtonForLabel(String label) =>
248265
find.descendant(of: actionSheetFinder, matching: find.text(label));
@@ -281,17 +298,17 @@ void main() {
281298
check(findButtonForLabel('Mark channel as read')).findsNothing();
282299
});
283300

284-
testWidgets('show from app bar in channel narrow', (tester) async {
301+
testWidgets('show from message-list app bar in channel narrow', (tester) async {
285302
await prepare();
286303
final narrow = ChannelNarrow(someChannel.streamId);
287-
await showFromAppBar(tester, narrow: narrow);
304+
await showFromMsglistAppBar(tester, narrow: narrow);
288305
checkButtons();
289306
});
290307

291-
testWidgets('show from app bar in topic narrow', (tester) async {
308+
testWidgets('show from message-list app bar in topic narrow', (tester) async {
292309
await prepare();
293310
final narrow = eg.topicNarrow(someChannel.streamId, someTopic);
294-
await showFromAppBar(tester, narrow: narrow);
311+
await showFromMsglistAppBar(tester, narrow: narrow);
295312
checkButtons();
296313
});
297314

@@ -300,6 +317,12 @@ void main() {
300317
await showFromRecipientHeader(tester, message: someMessage);
301318
checkButtons();
302319
});
320+
321+
testWidgets('show from topic-list app bar', (tester) async {
322+
await prepare();
323+
await showFromTopicListAppBar(tester);
324+
checkButtons();
325+
});
303326
});
304327

305328
group('SubscribeButton', () {
@@ -312,23 +335,23 @@ void main() {
312335
await prepare();
313336
final narrow = ChannelNarrow(someChannel.streamId);
314337
await store.removeSubscription(narrow.streamId);
315-
await showFromAppBar(tester, narrow: narrow);
338+
await showFromMsglistAppBar(tester, narrow: narrow);
316339
checkButton('Subscribe');
317340
});
318341

319342
testWidgets('channel subscribed', (tester) async {
320343
await prepare();
321344
final narrow = ChannelNarrow(someChannel.streamId);
322345
check(store.subscriptions[narrow.streamId]).isNotNull();
323-
await showFromAppBar(tester, narrow: narrow);
346+
await showFromMsglistAppBar(tester, narrow: narrow);
324347
checkNoButton('Subscribe');
325348
});
326349

327350
testWidgets('smoke', (tester) async {
328351
await prepare();
329352
final narrow = ChannelNarrow(someChannel.streamId);
330353
await store.removeSubscription(narrow.streamId);
331-
await showFromAppBar(tester, narrow: narrow);
354+
await showFromMsglistAppBar(tester, narrow: narrow);
332355

333356
connection.prepare(json: {});
334357
await tapButton(tester);
@@ -391,7 +414,7 @@ void main() {
391414

392415
testWidgets('TopicListButton', (tester) async {
393416
await prepare();
394-
await showFromAppBar(tester,
417+
await showFromMsglistAppBar(tester,
395418
narrow: ChannelNarrow(someChannel.streamId));
396419

397420
connection.prepare(json: GetStreamTopicsResult(topics: [
@@ -419,7 +442,7 @@ void main() {
419442
testWidgets('copies channel link to clipboard', (tester) async {
420443
await prepare();
421444
final narrow = ChannelNarrow(someChannel.streamId);
422-
await showFromAppBar(tester, narrow: narrow);
445+
await showFromMsglistAppBar(tester, narrow: narrow);
423446

424447
await tapCopyChannelLinkButton(tester);
425448
await tester.pump(Duration.zero);
@@ -439,15 +462,15 @@ void main() {
439462
await prepare();
440463
final narrow = ChannelNarrow(someChannel.streamId);
441464
check(store.subscriptions[narrow.streamId]).isNotNull();
442-
await showFromAppBar(tester, narrow: narrow);
465+
await showFromMsglistAppBar(tester, narrow: narrow);
443466
checkButton('Unsubscribe');
444467
});
445468

446469
testWidgets('channel not subscribed', (tester) async {
447470
await prepare();
448471
final narrow = ChannelNarrow(someChannel.streamId);
449472
await store.removeSubscription(narrow.streamId);
450-
await showFromAppBar(tester, narrow: narrow);
473+
await showFromMsglistAppBar(tester, narrow: narrow);
451474
checkNoButton('Unsubscribe');
452475
});
453476

@@ -457,7 +480,7 @@ void main() {
457480
await store.addStream(channel);
458481
await store.addSubscription(eg.subscription(channel));
459482
final narrow = ChannelNarrow(channel.streamId);
460-
await showFromAppBar(tester, channel: channel, narrow: narrow);
483+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
461484

462485
connection.prepare(json: {});
463486
await tapButton(tester);
@@ -479,7 +502,7 @@ void main() {
479502
await store.addStream(channel);
480503
await store.addSubscription(eg.subscription(channel));
481504
final narrow = ChannelNarrow(channel.streamId);
482-
await showFromAppBar(tester, channel: channel, narrow: narrow);
505+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
483506
connection.takeRequests();
484507

485508
connection.prepare(json: {});

0 commit comments

Comments
 (0)