@@ -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 ('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
+ });
382
+
383
+ testWidgets ('legacy: with empty topic, topic input has focus' , (tester) async {
384
+ await prepare (tester, narrow: narrow, mandatoryTopics: false ,
385
+ zulipFeatureLevel: 333 );
386
+ await enterTopic (tester, narrow: narrow, topic: '' );
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 {
367
394
await prepare (tester, narrow: narrow, mandatoryTopics: false );
368
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
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' ,
@@ -394,13 +432,22 @@ void main() {
394
432
395
433
testWidgets ('with non-empty but vacuous topic' , (tester) async {
396
434
await prepare (tester, narrow: narrow, mandatoryTopics: true );
397
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
435
+ await enterTopic (tester, narrow: narrow,
436
+ topic: eg.defaultRealmEmptyTopicDisplayName);
398
437
await tester.pump ();
399
438
checkComposeBoxHintTexts (tester,
400
439
topicHintText: 'Topic' ,
401
440
contentHintText: 'Message #${channel .name }' );
402
441
});
403
442
443
+ testWidgets ('legacy: with empty topic' , (tester) async {
444
+ await prepare (tester, narrow: narrow, mandatoryTopics: true ,
445
+ zulipFeatureLevel: 333 );
446
+ checkComposeBoxHintTexts (tester,
447
+ topicHintText: 'Topic' ,
448
+ contentHintText: 'Message #${channel .name }' );
449
+ });
450
+
404
451
testWidgets ('with non-empty topic' , (tester) async {
405
452
await prepare (tester, narrow: narrow, mandatoryTopics: true );
406
453
await enterTopic (tester, narrow: narrow, topic: 'new topic' );
@@ -703,6 +750,7 @@ void main() {
703
750
Future <void > setupAndTapSend (WidgetTester tester, {
704
751
required String topicInputText,
705
752
required bool mandatoryTopics,
753
+ int ? zulipFeatureLevel,
706
754
}) async {
707
755
TypingNotifier .debugEnable = false ;
708
756
addTearDown (TypingNotifier .debugReset);
@@ -711,7 +759,8 @@ void main() {
711
759
final narrow = ChannelNarrow (channel.streamId);
712
760
await prepareComposeBox (tester,
713
761
narrow: narrow, streams: [channel],
714
- mandatoryTopics: mandatoryTopics);
762
+ mandatoryTopics: mandatoryTopics,
763
+ zulipFeatureLevel: zulipFeatureLevel);
715
764
716
765
await enterTopic (tester, narrow: narrow, topic: topicInputText);
717
766
await tester.enterText (contentInputFinder, 'test content' );
@@ -726,10 +775,21 @@ void main() {
726
775
expectedMessage: 'Topics are required in this organization.' );
727
776
}
728
777
729
- testWidgets ('empty topic -> "(no topic) "' , (tester) async {
778
+ testWidgets ('empty topic -> ""' , (tester) async {
730
779
await setupAndTapSend (tester,
731
780
topicInputText: '' ,
732
781
mandatoryTopics: false );
782
+ check (connection.lastRequest).isA< http.Request > ()
783
+ ..method.equals ('POST' )
784
+ ..url.path.equals ('/api/v1/messages' )
785
+ ..bodyFields['topic' ].equals ('' );
786
+ });
787
+
788
+ testWidgets ('legacy: empty topic -> "(no topic)"' , (tester) async {
789
+ await setupAndTapSend (tester,
790
+ topicInputText: '' ,
791
+ mandatoryTopics: false ,
792
+ zulipFeatureLevel: 333 );
733
793
check (connection.lastRequest).isA< http.Request > ()
734
794
..method.equals ('POST' )
735
795
..url.path.equals ('/api/v1/messages' )
@@ -743,6 +803,13 @@ void main() {
743
803
checkMessageNotSent (tester);
744
804
});
745
805
806
+ testWidgets ('if topics are mandatory, reject `realmEmptyTopicDisplayName`' , (tester) async {
807
+ await setupAndTapSend (tester,
808
+ topicInputText: eg.defaultRealmEmptyTopicDisplayName,
809
+ mandatoryTopics: true );
810
+ checkMessageNotSent (tester);
811
+ });
812
+
746
813
testWidgets ('if topics are mandatory, reject "(no topic)"' , (tester) async {
747
814
await setupAndTapSend (tester,
748
815
topicInputText: '(no topic)' ,
0 commit comments