Skip to content

Commit 4ca273d

Browse files
committed
compose_box test: Switch to using subscribed channels, where boring
It's way more common to be using the app with subscribed channels than unsubscribed channels, so we might as well test with subscribed channels except where we specifically want to check behavior for unsubscribed channels.
1 parent 613f459 commit 4ca273d

File tree

1 file changed

+45
-28
lines changed

1 file changed

+45
-28
lines changed

test/widgets/compose_box_test.dart

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void main() {
160160
final channel = eg.stream();
161161
await prepareComposeBox(tester,
162162
narrow: ChannelNarrow(channel.streamId),
163-
streams: [channel],
163+
subscriptions: [eg.subscription(channel)],
164164
messages: [eg.streamMessage(stream: channel)]);
165165
check(controller).isA<StreamComposeBoxController>()
166166
..topicFocusNode.hasFocus.isFalse()
@@ -171,7 +171,7 @@ void main() {
171171
final channel = eg.stream();
172172
await prepareComposeBox(tester,
173173
narrow: ChannelNarrow(channel.streamId),
174-
streams: [channel],
174+
subscriptions: [eg.subscription(channel)],
175175
messages: []);
176176
check(controller).isA<StreamComposeBoxController>()
177177
.topicFocusNode.hasFocus.isTrue();
@@ -181,7 +181,7 @@ void main() {
181181
final channel = eg.stream();
182182
await prepareComposeBox(tester,
183183
narrow: TopicNarrow(channel.streamId, eg.t('topic')),
184-
streams: [channel],
184+
subscriptions: [eg.subscription(channel)],
185185
messages: [eg.streamMessage(stream: channel, topic: 'topic')]);
186186
check(controller).isNotNull().contentFocusNode.hasFocus.isFalse();
187187
});
@@ -190,7 +190,7 @@ void main() {
190190
final channel = eg.stream();
191191
await prepareComposeBox(tester,
192192
narrow: TopicNarrow(channel.streamId, eg.t('topic')),
193-
streams: [channel],
193+
subscriptions: [eg.subscription(channel)],
194194
messages: []);
195195
check(controller).isNotNull().contentFocusNode.hasFocus.isTrue();
196196
});
@@ -379,7 +379,7 @@ void main() {
379379
addTearDown(MessageStoreImpl.debugReset);
380380

381381
final narrow = ChannelNarrow(channel.streamId);
382-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
382+
await prepareComposeBox(tester, narrow: narrow, subscriptions: [eg.subscription(channel)]);
383383
await enterTopic(tester, narrow: narrow, topic: 'some topic');
384384
await enterContent(tester, content);
385385
}
@@ -418,7 +418,7 @@ void main() {
418418
addTearDown(MessageStoreImpl.debugReset);
419419

420420
final narrow = ChannelNarrow(channel.streamId);
421-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
421+
await prepareComposeBox(tester, narrow: narrow, subscriptions: [eg.subscription(channel)]);
422422
await enterTopic(tester, narrow: narrow, topic: topic);
423423
await enterContent(tester, 'some content');
424424
}
@@ -462,7 +462,7 @@ void main() {
462462
await prepareComposeBox(tester,
463463
narrow: narrow,
464464
otherUsers: [eg.otherUser, eg.thirdUser],
465-
streams: [channel],
465+
subscriptions: [eg.subscription(channel)],
466466
mandatoryTopics: mandatoryTopics,
467467
zulipFeatureLevel: zulipFeatureLevel);
468468
}
@@ -736,14 +736,14 @@ void main() {
736736
testWidgets('_StreamComposeBox', (tester) async {
737737
final channel = eg.stream();
738738
await prepareComposeBox(tester,
739-
narrow: ChannelNarrow(channel.streamId), streams: [channel]);
739+
narrow: ChannelNarrow(channel.streamId), subscriptions: [eg.subscription(channel)]);
740740
checkComposeBoxTextFields(tester, expectTopicTextField: true);
741741
});
742742

743743
testWidgets('_FixedDestinationComposeBox', (tester) async {
744744
final channel = eg.stream();
745745
await prepareComposeBox(tester,
746-
narrow: eg.topicNarrow(channel.streamId, 'topic'), streams: [channel]);
746+
narrow: eg.topicNarrow(channel.streamId, 'topic'), subscriptions: [eg.subscription(channel)]);
747747
checkComposeBoxTextFields(tester, expectTopicTextField: false);
748748
});
749749
});
@@ -762,7 +762,8 @@ void main() {
762762
}
763763

764764
testWidgets('smoke TopicNarrow', (tester) async {
765-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
765+
await prepareComposeBox(tester,
766+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
766767

767768
await checkStartTyping(tester, narrow);
768769

@@ -786,7 +787,8 @@ void main() {
786787
testWidgets('smoke ChannelNarrow', (tester) async {
787788
final narrow = ChannelNarrow(channel.streamId);
788789
final destinationNarrow = eg.topicNarrow(narrow.streamId, 'test topic');
789-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
790+
await prepareComposeBox(tester,
791+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
790792
await enterTopic(tester, narrow: narrow, topic: 'test topic');
791793

792794
await checkStartTyping(tester, destinationNarrow);
@@ -797,7 +799,8 @@ void main() {
797799
});
798800

799801
testWidgets('clearing text sends a "typing stopped" notice', (tester) async {
800-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
802+
await prepareComposeBox(tester,
803+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
801804

802805
await checkStartTyping(tester, narrow);
803806

@@ -809,7 +812,8 @@ void main() {
809812
testWidgets('hitting send button sends a "typing stopped" notice', (tester) async {
810813
MessageStoreImpl.debugOutboxEnable = false;
811814
addTearDown(MessageStoreImpl.debugReset);
812-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
815+
await prepareComposeBox(tester,
816+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
813817

814818
await checkStartTyping(tester, narrow);
815819

@@ -855,7 +859,8 @@ void main() {
855859
testWidgets('for content input, unfocusing sends a "typing stopped" notice', (tester) async {
856860
final narrow = ChannelNarrow(channel.streamId);
857861
final destinationNarrow = eg.topicNarrow(narrow.streamId, 'test topic');
858-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
862+
await prepareComposeBox(tester,
863+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
859864
await enterTopic(tester, narrow: narrow, topic: 'test topic');
860865

861866
await checkStartTyping(tester, destinationNarrow);
@@ -867,7 +872,8 @@ void main() {
867872
});
868873

869874
testWidgets('selection change sends a "typing started" notice', (tester) async {
870-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
875+
await prepareComposeBox(tester,
876+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
871877

872878
await checkStartTyping(tester, narrow);
873879

@@ -887,7 +893,8 @@ void main() {
887893
});
888894

889895
testWidgets('unfocusing app sends a "typing stopped" notice', (tester) async {
890-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
896+
await prepareComposeBox(tester,
897+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
891898

892899
await checkStartTyping(tester, narrow);
893900

@@ -919,8 +926,9 @@ void main() {
919926
addTearDown(MessageStoreImpl.debugReset);
920927

921928
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
922-
await prepareComposeBox(tester, narrow: eg.topicNarrow(123, 'some topic'),
923-
streams: [eg.stream(streamId: 123)]);
929+
await prepareComposeBox(tester,
930+
narrow: eg.topicNarrow(123, 'some topic'),
931+
subscriptions: [eg.subscription(eg.stream(streamId: 123))]);
924932

925933
await enterContent(tester, 'hello world');
926934

@@ -977,7 +985,7 @@ void main() {
977985
channel = eg.stream();
978986
final narrow = ChannelNarrow(channel.streamId);
979987
await prepareComposeBox(tester,
980-
narrow: narrow, streams: [channel],
988+
narrow: narrow, subscriptions: [eg.subscription(channel)],
981989
mandatoryTopics: mandatoryTopics,
982990
zulipFeatureLevel: zulipFeatureLevel);
983991

@@ -1057,7 +1065,8 @@ void main() {
10571065

10581066
final channel = eg.stream();
10591067
final narrow = ChannelNarrow(channel.streamId);
1060-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
1068+
await prepareComposeBox(tester,
1069+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
10611070

10621071
// (When we check that the send button looks disabled, it should be because
10631072
// the file is uploading, not a pre-existing reason.)
@@ -1175,7 +1184,8 @@ void main() {
11751184

11761185
final channel = eg.stream();
11771186
final narrow = eg.topicNarrow(channel.streamId, 'a topic');
1178-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
1187+
await prepareComposeBox(tester,
1188+
narrow: narrow, subscriptions: [eg.subscription(channel)]);
11791189

11801190
testBinding.pickFilesResult = FilePickerResult([PlatformFile(
11811191
readStream: Stream.fromIterable(['asdf'.codeUnits]),
@@ -1631,7 +1641,8 @@ void main() {
16311641
}
16321642

16331643
testWidgets('normal text scale factor', (tester) async {
1634-
await prepareComposeBox(tester, narrow: narrow, streams: [stream]);
1644+
await prepareComposeBox(tester,
1645+
narrow: narrow, subscriptions: [eg.subscription(stream)]);
16351646

16361647
await checkContentInputMaxHeight(tester,
16371648
maxHeight: verticalPadding + 170, maxVisibleLines: 8);
@@ -1640,23 +1651,26 @@ void main() {
16401651
testWidgets('lower text scale factor', (tester) async {
16411652
tester.platformDispatcher.textScaleFactorTestValue = 0.8;
16421653
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
1643-
await prepareComposeBox(tester, narrow: narrow, streams: [stream]);
1654+
await prepareComposeBox(tester,
1655+
narrow: narrow, subscriptions: [eg.subscription(stream)]);
16441656
await checkContentInputMaxHeight(tester,
16451657
maxHeight: verticalPadding + 170 * 0.8, maxVisibleLines: 8);
16461658
});
16471659

16481660
testWidgets('higher text scale factor', (tester) async {
16491661
tester.platformDispatcher.textScaleFactorTestValue = 1.5;
16501662
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
1651-
await prepareComposeBox(tester, narrow: narrow, streams: [stream]);
1663+
await prepareComposeBox(tester,
1664+
narrow: narrow, subscriptions: [eg.subscription(stream)]);
16521665
await checkContentInputMaxHeight(tester,
16531666
maxHeight: verticalPadding + 170 * 1.5, maxVisibleLines: 8);
16541667
});
16551668

16561669
testWidgets('higher text scale factor exceeding threshold', (tester) async {
16571670
tester.platformDispatcher.textScaleFactorTestValue = 2;
16581671
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
1659-
await prepareComposeBox(tester, narrow: narrow, streams: [stream]);
1672+
await prepareComposeBox(tester,
1673+
narrow: narrow, subscriptions: [eg.subscription(stream)]);
16601674
await checkContentInputMaxHeight(tester,
16611675
maxHeight: verticalPadding + 170 * 1.5, maxVisibleLines: 6);
16621676
});
@@ -1671,7 +1685,8 @@ void main() {
16711685

16721686
final channel = eg.stream();
16731687
await prepareComposeBox(tester,
1674-
narrow: eg.topicNarrow(channel.streamId, 'topic'), streams: [channel]);
1688+
narrow: eg.topicNarrow(channel.streamId, 'topic'),
1689+
subscriptions: [eg.subscription(channel)]);
16751690

16761691
await enterContent(tester, 'some content');
16771692
checkContentInputValue(tester, 'some content');
@@ -1769,7 +1784,9 @@ void main() {
17691784
TypingNotifier.debugEnable = false;
17701785
addTearDown(TypingNotifier.debugReset);
17711786
await prepareComposeBox(tester,
1772-
narrow: narrow, streams: [channel], otherUsers: otherUsers);
1787+
narrow: narrow,
1788+
subscriptions: [eg.subscription(channel)],
1789+
otherUsers: otherUsers);
17731790

17741791
if (narrow is ChannelNarrow) {
17751792
connection.prepare(json: GetStreamTopicsResult(topics: []).toJson());
@@ -1937,7 +1954,7 @@ void main() {
19371954
addTearDown(MessageStoreImpl.debugReset);
19381955
await prepareComposeBox(tester,
19391956
narrow: narrow,
1940-
streams: [channel]);
1957+
subscriptions: [eg.subscription(channel)]);
19411958
await store.addMessages([message, dmMessage]);
19421959
await tester.pump(); // message list updates
19431960
}

0 commit comments

Comments
 (0)