Skip to content

Commit d7fe0ec

Browse files
committed
action_sheet test: Also test showing channel sheet from topic list app bar
1 parent 9afa307 commit d7fe0ec

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

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

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

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

283-
testWidgets('show from app bar in channel narrow', (tester) async {
300+
testWidgets('show from message-list app bar in channel narrow', (tester) async {
284301
await prepare();
285302
final narrow = ChannelNarrow(someChannel.streamId);
286-
await showFromAppBar(tester, narrow: narrow);
303+
await showFromMsglistAppBar(tester, narrow: narrow);
287304
checkButtons();
288305
});
289306

290-
testWidgets('show from app bar in topic narrow', (tester) async {
307+
testWidgets('show from message-list app bar in topic narrow', (tester) async {
291308
await prepare();
292309
final narrow = eg.topicNarrow(someChannel.streamId, someTopic);
293-
await showFromAppBar(tester, narrow: narrow);
310+
await showFromMsglistAppBar(tester, narrow: narrow);
294311
checkButtons();
295312
});
296313

@@ -299,6 +316,12 @@ void main() {
299316
await showFromRecipientHeader(tester, message: someMessage);
300317
checkButtons();
301318
});
319+
320+
testWidgets('show from topic-list app bar', (tester) async {
321+
await prepare();
322+
await showFromTopicListAppBar(tester);
323+
checkButtons();
324+
});
302325
});
303326

304327
group('SubscribeButton', () {
@@ -311,23 +334,23 @@ void main() {
311334
await prepare();
312335
final narrow = ChannelNarrow(someChannel.streamId);
313336
await store.removeSubscription(narrow.streamId);
314-
await showFromAppBar(tester, narrow: narrow);
337+
await showFromMsglistAppBar(tester, narrow: narrow);
315338
checkButton('Subscribe');
316339
});
317340

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

326349
testWidgets('smoke', (tester) async {
327350
await prepare();
328351
final narrow = ChannelNarrow(someChannel.streamId);
329352
await store.removeSubscription(narrow.streamId);
330-
await showFromAppBar(tester, narrow: narrow);
353+
await showFromMsglistAppBar(tester, narrow: narrow);
331354

332355
connection.prepare(json: {});
333356
await tapButton(tester);
@@ -390,7 +413,7 @@ void main() {
390413

391414
testWidgets('TopicListButton', (tester) async {
392415
await prepare();
393-
await showFromAppBar(tester,
416+
await showFromMsglistAppBar(tester,
394417
narrow: ChannelNarrow(someChannel.streamId));
395418

396419
connection.prepare(json: GetStreamTopicsResult(topics: [
@@ -418,7 +441,7 @@ void main() {
418441
testWidgets('copies channel link to clipboard', (tester) async {
419442
await prepare();
420443
final narrow = ChannelNarrow(someChannel.streamId);
421-
await showFromAppBar(tester, narrow: narrow);
444+
await showFromMsglistAppBar(tester, narrow: narrow);
422445

423446
await tapCopyChannelLinkButton(tester);
424447
await tester.pump(Duration.zero);
@@ -438,15 +461,15 @@ void main() {
438461
await prepare();
439462
final narrow = ChannelNarrow(someChannel.streamId);
440463
check(store.subscriptions[narrow.streamId]).isNotNull();
441-
await showFromAppBar(tester, narrow: narrow);
464+
await showFromMsglistAppBar(tester, narrow: narrow);
442465
checkButton('Unsubscribe');
443466
});
444467

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

@@ -456,7 +479,7 @@ void main() {
456479
await store.addStream(channel);
457480
await store.addSubscription(eg.subscription(channel));
458481
final narrow = ChannelNarrow(channel.streamId);
459-
await showFromAppBar(tester, channel: channel, narrow: narrow);
482+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
460483

461484
connection.prepare(json: {});
462485
await tapButton(tester);
@@ -478,7 +501,7 @@ void main() {
478501
await store.addStream(channel);
479502
await store.addSubscription(eg.subscription(channel));
480503
final narrow = ChannelNarrow(channel.streamId);
481-
await showFromAppBar(tester, channel: channel, narrow: narrow);
504+
await showFromMsglistAppBar(tester, channel: channel, narrow: narrow);
482505
connection.takeRequests();
483506

484507
connection.prepare(json: {});

0 commit comments

Comments
 (0)