@@ -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,49 @@ 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 ('legacy: with empty topic, topic input has focus' , (tester) async {
374
+ await prepare (tester, narrow: narrow, mandatoryTopics: false ,
375
+ zulipFeatureLevel: 333 ); // TODO(server-10)
376
+ await enterTopic (tester, narrow: narrow, topic: '' );
377
+ await tester.pump ();
378
+ checkComposeBoxHintTexts (tester,
379
+ topicHintText: 'Topic' ,
380
+ contentHintText: 'Message #${channel .name }' );
381
+ });
382
+
383
+ testWidgets ('with non-empty but vacuous topic, topic input has focus' , (tester) async {
367
384
await prepare (tester, narrow: narrow, mandatoryTopics: false );
368
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
385
+ await enterTopic (tester, narrow: narrow,
386
+ topic: eg.defaultRealmEmptyTopicDisplayName);
387
+ await tester.pump ();
388
+ checkComposeBoxHintTexts (tester,
389
+ topicHintText: 'Topic' ,
390
+ contentHintText: 'Message #${channel .name }' );
391
+ });
392
+
393
+ testWidgets ('with empty topic, content input has focus' , (tester) async {
394
+ await prepare (tester, narrow: narrow, mandatoryTopics: false );
395
+ await enterContent (tester, '' );
396
+ await tester.pump ();
397
+ checkComposeBoxHintTexts (tester,
398
+ topicHintText: 'Topic' ,
399
+ contentHintText: 'Message #${channel .name } > '
400
+ '${eg .defaultRealmEmptyTopicDisplayName }' );
401
+ }, skip: true ); // null topic names soon to be enabled
402
+
403
+ testWidgets ('legacy: with empty topic, content input has focus' , (tester) async {
404
+ await prepare (tester, narrow: narrow, mandatoryTopics: false ,
405
+ zulipFeatureLevel: 333 );
406
+ await enterContent (tester, '' );
369
407
await tester.pump ();
370
408
checkComposeBoxHintTexts (tester,
371
409
topicHintText: 'Topic' ,
@@ -392,15 +430,36 @@ void main() {
392
430
contentHintText: 'Message #${channel .name }' );
393
431
});
394
432
395
- testWidgets ('with non-empty but vacuous topic' , (tester) async {
396
- await prepare (tester, narrow: narrow, mandatoryTopics: true );
397
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
398
- await tester.pump ();
433
+ testWidgets ('legacy: with empty topic' , (tester) async {
434
+ await prepare (tester, narrow: narrow, mandatoryTopics: true ,
435
+ zulipFeatureLevel: 333 ); // TODO(server-10)
399
436
checkComposeBoxHintTexts (tester,
400
437
topicHintText: 'Topic' ,
401
438
contentHintText: 'Message #${channel .name }' );
402
439
});
403
440
441
+ group ('with non-empty but vacuous topics' , () {
442
+ testWidgets ('realm_empty_topic_display_name' , (tester) async {
443
+ await prepare (tester, narrow: narrow, mandatoryTopics: true );
444
+ await enterTopic (tester, narrow: narrow,
445
+ topic: eg.defaultRealmEmptyTopicDisplayName);
446
+ await tester.pump ();
447
+ checkComposeBoxHintTexts (tester,
448
+ topicHintText: 'Topic' ,
449
+ contentHintText: 'Message #${channel .name }' );
450
+ });
451
+
452
+ testWidgets ('"(no topic)"' , (tester) async {
453
+ await prepare (tester, narrow: narrow, mandatoryTopics: true );
454
+ await enterTopic (tester, narrow: narrow,
455
+ topic: '(no topic)' );
456
+ await tester.pump ();
457
+ checkComposeBoxHintTexts (tester,
458
+ topicHintText: 'Topic' ,
459
+ contentHintText: 'Message #${channel .name }' );
460
+ });
461
+ });
462
+
404
463
testWidgets ('with non-empty topic' , (tester) async {
405
464
await prepare (tester, narrow: narrow, mandatoryTopics: true );
406
465
await enterTopic (tester, narrow: narrow, topic: 'new topic' );
@@ -703,6 +762,7 @@ void main() {
703
762
Future <void > setupAndTapSend (WidgetTester tester, {
704
763
required String topicInputText,
705
764
required bool mandatoryTopics,
765
+ int ? zulipFeatureLevel,
706
766
}) async {
707
767
TypingNotifier .debugEnable = false ;
708
768
addTearDown (TypingNotifier .debugReset);
@@ -711,7 +771,8 @@ void main() {
711
771
final narrow = ChannelNarrow (channel.streamId);
712
772
await prepareComposeBox (tester,
713
773
narrow: narrow, streams: [channel],
714
- mandatoryTopics: mandatoryTopics);
774
+ mandatoryTopics: mandatoryTopics,
775
+ zulipFeatureLevel: zulipFeatureLevel);
715
776
716
777
await enterTopic (tester, narrow: narrow, topic: topicInputText);
717
778
await tester.enterText (contentInputFinder, 'test content' );
@@ -726,10 +787,21 @@ void main() {
726
787
expectedMessage: 'Topics are required in this organization.' );
727
788
}
728
789
729
- testWidgets ('empty topic -> "(no topic) "' , (tester) async {
790
+ testWidgets ('empty topic -> ""' , (tester) async {
730
791
await setupAndTapSend (tester,
731
792
topicInputText: '' ,
732
793
mandatoryTopics: false );
794
+ check (connection.lastRequest).isA< http.Request > ()
795
+ ..method.equals ('POST' )
796
+ ..url.path.equals ('/api/v1/messages' )
797
+ ..bodyFields['topic' ].equals ('' );
798
+ });
799
+
800
+ testWidgets ('legacy: empty topic -> "(no topic)"' , (tester) async {
801
+ await setupAndTapSend (tester,
802
+ topicInputText: '' ,
803
+ mandatoryTopics: false ,
804
+ zulipFeatureLevel: 333 );
733
805
check (connection.lastRequest).isA< http.Request > ()
734
806
..method.equals ('POST' )
735
807
..url.path.equals ('/api/v1/messages' )
@@ -743,6 +815,13 @@ void main() {
743
815
checkMessageNotSent (tester);
744
816
});
745
817
818
+ testWidgets ('if topics are mandatory, reject `realmEmptyTopicDisplayName`' , (tester) async {
819
+ await setupAndTapSend (tester,
820
+ topicInputText: eg.defaultRealmEmptyTopicDisplayName,
821
+ mandatoryTopics: true );
822
+ checkMessageNotSent (tester);
823
+ });
824
+
746
825
testWidgets ('if topics are mandatory, reject "(no topic)"' , (tester) async {
747
826
await setupAndTapSend (tester,
748
827
topicInputText: '(no topic)' ,
0 commit comments