Skip to content

Commit 296e600

Browse files
committed
action_sheet test: Also test showing channel sheet from topic list app bar
1 parent d0db6d4 commit 296e600

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
@@ -33,6 +33,7 @@ import 'package:zulip/widgets/inbox.dart';
3333
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/subscription_list.dart';
36+
import 'package:zulip/widgets/topic_list.dart';
3637
import 'package:zulip/widgets/user.dart';
3738
import '../api/fake_api.dart';
3839

@@ -197,7 +198,7 @@ void main() {
197198
await tester.pump(const Duration(milliseconds: 250));
198199
}
199200

200-
Future<void> showFromAppBar(WidgetTester tester, {
201+
Future<void> showFromMsglistAppBar(WidgetTester tester, {
201202
ZulipStream? channel,
202203
required Narrow narrow,
203204
}) async {
@@ -239,6 +240,22 @@ void main() {
239240
await tester.pump(const Duration(milliseconds: 250));
240241
}
241242

243+
Future<void> showFromTopicListAppBar(WidgetTester tester) async {
244+
final transitionDurationObserver = TransitionDurationObserver();
245+
246+
connection.prepare(json: GetStreamTopicsResult(topics: []).toJson());
247+
await tester.pumpWidget(TestZulipApp(
248+
navigatorObservers: [transitionDurationObserver],
249+
accountId: eg.selfAccount.id,
250+
child: TopicListPage(streamId: someChannel.streamId)));
251+
await tester.pump();
252+
253+
await tester.longPress(find.descendant(
254+
of: find.byType(ZulipAppBar),
255+
matching: find.text(someChannel.name)));
256+
await transitionDurationObserver.pumpPastTransition(tester);
257+
}
258+
242259
final actionSheetFinder = find.byType(BottomSheet);
243260
Finder findButtonForLabel(String label) =>
244261
find.descendant(of: actionSheetFinder, matching: find.text(label));
@@ -277,17 +294,17 @@ void main() {
277294
check(findButtonForLabel('Mark channel as read')).findsNothing();
278295
});
279296

280-
testWidgets('show from app bar in channel narrow', (tester) async {
297+
testWidgets('show from message-list app bar in channel narrow', (tester) async {
281298
await prepare();
282299
final narrow = ChannelNarrow(someChannel.streamId);
283-
await showFromAppBar(tester, narrow: narrow);
300+
await showFromMsglistAppBar(tester, narrow: narrow);
284301
checkButtons();
285302
});
286303

287-
testWidgets('show from app bar in topic narrow', (tester) async {
304+
testWidgets('show from message-list app bar in topic narrow', (tester) async {
288305
await prepare();
289306
final narrow = eg.topicNarrow(someChannel.streamId, someTopic);
290-
await showFromAppBar(tester, narrow: narrow);
307+
await showFromMsglistAppBar(tester, narrow: narrow);
291308
checkButtons();
292309
});
293310

@@ -296,6 +313,12 @@ void main() {
296313
await showFromRecipientHeader(tester, message: someMessage);
297314
checkButtons();
298315
});
316+
317+
testWidgets('show from topic-list app bar', (tester) async {
318+
await prepare();
319+
await showFromTopicListAppBar(tester);
320+
checkButtons();
321+
});
299322
});
300323

301324
group('SubscribeButton', () {
@@ -308,23 +331,23 @@ void main() {
308331
await prepare();
309332
final narrow = ChannelNarrow(someChannel.streamId);
310333
await store.removeSubscription(narrow.streamId);
311-
await showFromAppBar(tester, narrow: narrow);
334+
await showFromMsglistAppBar(tester, narrow: narrow);
312335
checkButton('Subscribe');
313336
});
314337

315338
testWidgets('channel subscribed', (tester) async {
316339
await prepare();
317340
final narrow = ChannelNarrow(someChannel.streamId);
318341
check(store.subscriptions[narrow.streamId]).isNotNull();
319-
await showFromAppBar(tester, narrow: narrow);
342+
await showFromMsglistAppBar(tester, narrow: narrow);
320343
checkNoButton('Subscribe');
321344
});
322345

323346
testWidgets('smoke', (tester) async {
324347
await prepare();
325348
final narrow = ChannelNarrow(someChannel.streamId);
326349
await store.removeSubscription(narrow.streamId);
327-
await showFromAppBar(tester, narrow: narrow);
350+
await showFromMsglistAppBar(tester, narrow: narrow);
328351

329352
connection.prepare(json: {});
330353
await tapButton(tester);
@@ -387,7 +410,7 @@ void main() {
387410

388411
testWidgets('TopicListButton', (tester) async {
389412
await prepare();
390-
await showFromAppBar(tester,
413+
await showFromMsglistAppBar(tester,
391414
narrow: ChannelNarrow(someChannel.streamId));
392415

393416
connection.prepare(json: GetStreamTopicsResult(topics: [
@@ -415,7 +438,7 @@ void main() {
415438
testWidgets('copies channel link to clipboard', (tester) async {
416439
await prepare();
417440
final narrow = ChannelNarrow(someChannel.streamId);
418-
await showFromAppBar(tester, narrow: narrow);
441+
await showFromMsglistAppBar(tester, narrow: narrow);
419442

420443
await tapCopyChannelLinkButton(tester);
421444
await tester.pump(Duration.zero);
@@ -435,15 +458,15 @@ void main() {
435458
await prepare();
436459
final narrow = ChannelNarrow(someChannel.streamId);
437460
check(store.subscriptions[narrow.streamId]).isNotNull();
438-
await showFromAppBar(tester, narrow: narrow);
461+
await showFromMsglistAppBar(tester, narrow: narrow);
439462
checkButton('Unsubscribe');
440463
});
441464

442465
testWidgets('channel not subscribed', (tester) async {
443466
await prepare();
444467
final narrow = ChannelNarrow(someChannel.streamId);
445468
await store.removeSubscription(narrow.streamId);
446-
await showFromAppBar(tester, narrow: narrow);
469+
await showFromMsglistAppBar(tester, narrow: narrow);
447470
checkNoButton('Unsubscribe');
448471
});
449472

@@ -453,7 +476,7 @@ void main() {
453476
await store.addStream(channel);
454477
await store.addSubscription(eg.subscription(channel));
455478
final narrow = ChannelNarrow(channel.streamId);
456-
await showFromAppBar(tester, channel: channel, narrow: narrow);
479+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
457480

458481
connection.prepare(json: {});
459482
await tapButton(tester);
@@ -475,7 +498,7 @@ void main() {
475498
await store.addStream(channel);
476499
await store.addSubscription(eg.subscription(channel));
477500
final narrow = ChannelNarrow(channel.streamId);
478-
await showFromAppBar(tester, channel: channel, narrow: narrow);
501+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
479502
connection.takeRequests();
480503

481504
connection.prepare(json: {});

0 commit comments

Comments
 (0)