@@ -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
@@ -356,16 +361,50 @@ void main() {
356
361
group ('to ChannelNarrow, topics not mandatory' , () {
357
362
final narrow = ChannelNarrow (channel.streamId);
358
363
359
- testWidgets ('with empty topic' , (tester) async {
364
+ testWidgets ('with empty topic, topic input has focus ' , (tester) async {
360
365
await prepare (tester, narrow: narrow, mandatoryTopics: false );
366
+ await enterTopic (tester, narrow: narrow, topic: '' );
367
+ await tester.pump ();
361
368
checkComposeBoxHintTexts (tester,
362
369
topicHintText: 'Topic' ,
363
- contentHintText: 'Message #${channel .name } > (no topic) ' );
370
+ contentHintText: 'Message #${channel .name }' );
364
371
});
365
372
366
- testWidgets ('with non-empty but vacuous topic' , (tester) async {
373
+ testWidgets ('with non-empty but vacuous topic, topic input has focus' , (tester) async {
374
+ await prepare (tester, narrow: narrow, mandatoryTopics: false );
375
+ await enterTopic (tester, narrow: narrow,
376
+ topic: eg.defaultRealmEmptyTopicDisplayName);
377
+ await tester.pump ();
378
+ checkComposeBoxHintTexts (tester,
379
+ topicHintText: 'Topic' ,
380
+ contentHintText: 'Message #${channel .name } > '
381
+ '${eg .defaultRealmEmptyTopicDisplayName }' );
382
+ });
383
+
384
+ testWidgets ('legacy: with empty topic, topic input has focus' , (tester) async {
385
+ await prepare (tester, narrow: narrow, mandatoryTopics: false ,
386
+ zulipFeatureLevel: 333 );
387
+ await enterTopic (tester, narrow: narrow, topic: '' );
388
+ await tester.pump ();
389
+ checkComposeBoxHintTexts (tester,
390
+ topicHintText: 'Topic' ,
391
+ contentHintText: 'Message #${channel .name }' );
392
+ });
393
+
394
+ testWidgets ('with empty topic, content input has focus' , (tester) async {
367
395
await prepare (tester, narrow: narrow, mandatoryTopics: false );
368
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
396
+ await enterContent (tester, '' );
397
+ await tester.pump ();
398
+ checkComposeBoxHintTexts (tester,
399
+ topicHintText: 'Topic' ,
400
+ contentHintText: 'Message #${channel .name } > '
401
+ '${eg .defaultRealmEmptyTopicDisplayName }' );
402
+ });
403
+
404
+ testWidgets ('legacy: with empty topic, content input has focus' , (tester) async {
405
+ await prepare (tester, narrow: narrow, mandatoryTopics: false ,
406
+ zulipFeatureLevel: 333 );
407
+ await enterContent (tester, '' );
369
408
await tester.pump ();
370
409
checkComposeBoxHintTexts (tester,
371
410
topicHintText: 'Topic' ,
@@ -394,11 +433,21 @@ void main() {
394
433
395
434
testWidgets ('with non-empty but vacuous topic' , (tester) async {
396
435
await prepare (tester, narrow: narrow, mandatoryTopics: true );
397
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
436
+ await enterTopic (tester, narrow: narrow,
437
+ topic: eg.defaultRealmEmptyTopicDisplayName);
398
438
await tester.pump ();
399
439
checkComposeBoxHintTexts (tester,
400
440
topicHintText: 'Topic' ,
401
- contentHintText: 'Message #${channel .name } > (no topic)' );
441
+ contentHintText: 'Message #${channel .name } > '
442
+ '${eg .defaultRealmEmptyTopicDisplayName }' );
443
+ });
444
+
445
+ testWidgets ('legacy: with empty topic' , (tester) async {
446
+ await prepare (tester, narrow: narrow, mandatoryTopics: true ,
447
+ zulipFeatureLevel: 333 );
448
+ checkComposeBoxHintTexts (tester,
449
+ topicHintText: 'Topic' ,
450
+ contentHintText: 'Message #${channel .name }' );
402
451
});
403
452
404
453
testWidgets ('with non-empty topic' , (tester) async {
@@ -703,6 +752,7 @@ void main() {
703
752
Future <void > setupAndTapSend (WidgetTester tester, {
704
753
required String topicInputText,
705
754
required bool mandatoryTopics,
755
+ int ? zulipFeatureLevel,
706
756
}) async {
707
757
TypingNotifier .debugEnable = false ;
708
758
addTearDown (TypingNotifier .debugReset);
@@ -711,7 +761,8 @@ void main() {
711
761
final narrow = ChannelNarrow (channel.streamId);
712
762
await prepareComposeBox (tester,
713
763
narrow: narrow, streams: [channel],
714
- mandatoryTopics: mandatoryTopics);
764
+ mandatoryTopics: mandatoryTopics,
765
+ zulipFeatureLevel: zulipFeatureLevel);
715
766
716
767
await enterTopic (tester, narrow: narrow, topic: topicInputText);
717
768
await tester.enterText (contentInputFinder, 'test content' );
@@ -726,10 +777,21 @@ void main() {
726
777
expectedMessage: 'Topics are required in this organization.' );
727
778
}
728
779
729
- testWidgets ('empty topic -> "(no topic) "' , (tester) async {
780
+ testWidgets ('empty topic -> ""' , (tester) async {
730
781
await setupAndTapSend (tester,
731
782
topicInputText: '' ,
732
783
mandatoryTopics: false );
784
+ check (connection.lastRequest).isA< http.Request > ()
785
+ ..method.equals ('POST' )
786
+ ..url.path.equals ('/api/v1/messages' )
787
+ ..bodyFields['topic' ].equals ('' );
788
+ });
789
+
790
+ testWidgets ('legacy: empty topic -> "(no topic)"' , (tester) async {
791
+ await setupAndTapSend (tester,
792
+ topicInputText: '' ,
793
+ mandatoryTopics: false ,
794
+ zulipFeatureLevel: 333 );
733
795
check (connection.lastRequest).isA< http.Request > ()
734
796
..method.equals ('POST' )
735
797
..url.path.equals ('/api/v1/messages' )
@@ -743,6 +805,13 @@ void main() {
743
805
checkMessageNotSent (tester);
744
806
});
745
807
808
+ testWidgets ('if topics are mandatory, reject `realmEmptyTopicDisplayName`' , (tester) async {
809
+ await setupAndTapSend (tester,
810
+ topicInputText: eg.defaultRealmEmptyTopicDisplayName,
811
+ mandatoryTopics: true );
812
+ checkMessageNotSent (tester);
813
+ });
814
+
746
815
testWidgets ('if topics are mandatory, reject "(no topic)"' , (tester) async {
747
816
await setupAndTapSend (tester,
748
817
topicInputText: '(no topic)' ,
0 commit comments