@@ -47,15 +47,18 @@ void main() {
47
47
List <User > otherUsers = const [],
48
48
List <ZulipStream > streams = const [],
49
49
bool ? mandatoryTopics,
50
+ int ? zulipFeatureLevel,
50
51
}) async {
51
52
if (narrow case ChannelNarrow (: var streamId) || TopicNarrow (: var streamId)) {
52
53
assert (streams.any ((stream) => stream.streamId == streamId),
53
54
'Add a channel with "streamId" the same as of $narrow .streamId to the store.' );
54
55
}
55
56
addTearDown (testBinding.reset);
56
57
selfUser ?? = eg.selfUser;
57
- final selfAccount = eg.account (user: selfUser);
58
+ zulipFeatureLevel ?? = eg.futureZulipFeatureLevel;
59
+ final selfAccount = eg.account (user: selfUser, zulipFeatureLevel: zulipFeatureLevel);
58
60
await testBinding.globalStore.add (selfAccount, eg.initialSnapshot (
61
+ zulipFeatureLevel: zulipFeatureLevel,
59
62
realmMandatoryTopics: mandatoryTopics,
60
63
));
61
64
@@ -327,12 +330,14 @@ void main() {
327
330
Future <void > prepare (WidgetTester tester, {
328
331
required Narrow narrow,
329
332
bool ? mandatoryTopics,
333
+ int ? zulipFeatureLevel,
330
334
}) async {
331
335
await prepareComposeBox (tester,
332
336
narrow: narrow,
333
337
otherUsers: [eg.otherUser, eg.thirdUser],
334
338
streams: [channel],
335
- mandatoryTopics: mandatoryTopics);
339
+ mandatoryTopics: mandatoryTopics,
340
+ zulipFeatureLevel: zulipFeatureLevel);
336
341
}
337
342
338
343
/// This checks the input's configured hint text without regard to whether
@@ -357,6 +362,16 @@ void main() {
357
362
testWidgets ('with empty topic' , (tester) async {
358
363
await prepare (tester, narrow: ChannelNarrow (channel.streamId),
359
364
mandatoryTopics: false );
365
+ await tester.pump ();
366
+ checkComposeBoxHintTexts (tester,
367
+ topicHintText: 'Topic' ,
368
+ contentHintText: 'Message #${channel .name } > ${eg .defaultRealmEmptyTopicDisplayName }' );
369
+ }, skip: true ); // null topic names soon to be enabled
370
+
371
+ testWidgets ('legacy: with empty topic' , (tester) async {
372
+ await prepare (tester, narrow: ChannelNarrow (channel.streamId),
373
+ mandatoryTopics: false ,
374
+ zulipFeatureLevel: 333 );
360
375
checkComposeBoxHintTexts (tester,
361
376
topicHintText: 'Topic' ,
362
377
contentHintText: 'Message #${channel .name } > (no topic)' );
@@ -383,6 +398,15 @@ void main() {
383
398
contentHintText: 'Message #${channel .name }' );
384
399
});
385
400
401
+ testWidgets ('legacy: with empty topic' , (tester) async {
402
+ await prepare (tester, narrow: ChannelNarrow (channel.streamId),
403
+ mandatoryTopics: true ,
404
+ zulipFeatureLevel: 333 );
405
+ checkComposeBoxHintTexts (tester,
406
+ topicHintText: 'Topic' ,
407
+ contentHintText: 'Message #${channel .name }' );
408
+ });
409
+
386
410
testWidgets ('with non-empty topic' , (tester) async {
387
411
final narrow = ChannelNarrow (channel.streamId);
388
412
await prepare (tester, narrow: narrow,
@@ -689,6 +713,7 @@ void main() {
689
713
Future <void > setupAndTapSend (WidgetTester tester, {
690
714
required String topicInputText,
691
715
required bool mandatoryTopics,
716
+ int ? zulipFeatureLevel,
692
717
}) async {
693
718
TypingNotifier .debugEnable = false ;
694
719
addTearDown (TypingNotifier .debugReset);
@@ -697,7 +722,8 @@ void main() {
697
722
final narrow = ChannelNarrow (channel.streamId);
698
723
await prepareComposeBox (tester,
699
724
narrow: narrow, streams: [channel],
700
- mandatoryTopics: mandatoryTopics);
725
+ mandatoryTopics: mandatoryTopics,
726
+ zulipFeatureLevel: zulipFeatureLevel);
701
727
702
728
await enterTopic (tester, narrow: narrow, topic: topicInputText);
703
729
await tester.enterText (contentInputFinder, 'test content' );
@@ -712,10 +738,21 @@ void main() {
712
738
expectedMessage: 'Topics are required in this organization.' );
713
739
}
714
740
715
- testWidgets ('empty topic -> "(no topic)" ' , (tester) async {
741
+ testWidgets ('empty topic -> empty topic' , (tester) async {
716
742
await setupAndTapSend (tester,
717
743
topicInputText: '' ,
718
744
mandatoryTopics: false );
745
+ check (connection.lastRequest).isA< http.Request > ()
746
+ ..method.equals ('POST' )
747
+ ..url.path.equals ('/api/v1/messages' )
748
+ ..bodyFields['topic' ].equals ('' );
749
+ }, skip: true ); // null topic names soon to be enabled
750
+
751
+ testWidgets ('legacy: empty topic -> "(no topic)"' , (tester) async {
752
+ await setupAndTapSend (tester,
753
+ topicInputText: '' ,
754
+ mandatoryTopics: false ,
755
+ zulipFeatureLevel: 333 );
719
756
check (connection.lastRequest).isA< http.Request > ()
720
757
..method.equals ('POST' )
721
758
..url.path.equals ('/api/v1/messages' )
@@ -729,12 +766,27 @@ void main() {
729
766
checkMessageNotSent (tester);
730
767
});
731
768
769
+ testWidgets ('if topics are mandatory, reject `realmEmptyTopicDisplayName`' , (tester) async {
770
+ await setupAndTapSend (tester,
771
+ topicInputText: eg.defaultRealmEmptyTopicDisplayName,
772
+ mandatoryTopics: true );
773
+ checkMessageNotSent (tester);
774
+ }, skip: true ); // null topic names soon to be enabled
775
+
732
776
testWidgets ('if topics are mandatory, reject "(no topic)"' , (tester) async {
733
777
await setupAndTapSend (tester,
734
778
topicInputText: '(no topic)' ,
735
779
mandatoryTopics: true );
736
780
checkMessageNotSent (tester);
737
781
});
782
+
783
+ testWidgets ('legacy: if topics are mandatory, reject "(no topic)"' , (tester) async {
784
+ await setupAndTapSend (tester,
785
+ topicInputText: '(no topic)' ,
786
+ mandatoryTopics: true ,
787
+ zulipFeatureLevel: 333 );
788
+ checkMessageNotSent (tester);
789
+ });
738
790
});
739
791
740
792
group ('uploads' , () {
0 commit comments