@@ -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 {
367
374
await prepare (tester, narrow: narrow, mandatoryTopics: false );
368
- await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
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 {
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
+ });
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' );
@@ -705,6 +752,7 @@ void main() {
705
752
Future <void > setupAndTapSend (WidgetTester tester, {
706
753
required String topicInputText,
707
754
required bool mandatoryTopics,
755
+ int ? zulipFeatureLevel,
708
756
}) async {
709
757
TypingNotifier .debugEnable = false ;
710
758
addTearDown (TypingNotifier .debugReset);
@@ -713,7 +761,8 @@ void main() {
713
761
final narrow = ChannelNarrow (channel.streamId);
714
762
await prepareComposeBox (tester,
715
763
narrow: narrow, streams: [channel],
716
- mandatoryTopics: mandatoryTopics);
764
+ mandatoryTopics: mandatoryTopics,
765
+ zulipFeatureLevel: zulipFeatureLevel);
717
766
718
767
await enterTopic (tester, narrow: narrow, topic: topicInputText);
719
768
await tester.enterText (contentInputFinder, 'test content' );
@@ -728,10 +777,21 @@ void main() {
728
777
expectedMessage: 'Topics are required in this organization.' );
729
778
}
730
779
731
- testWidgets ('empty topic -> "(no topic)" ' , (tester) async {
780
+ testWidgets ('empty topic -> empty topic' , (tester) async {
732
781
await setupAndTapSend (tester,
733
782
topicInputText: '' ,
734
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
+ }, skip: true ); // null topic names soon to be enabled
789
+
790
+ testWidgets ('legacy: empty topic -> "(no topic)"' , (tester) async {
791
+ await setupAndTapSend (tester,
792
+ topicInputText: '' ,
793
+ mandatoryTopics: false ,
794
+ zulipFeatureLevel: 333 );
735
795
check (connection.lastRequest).isA< http.Request > ()
736
796
..method.equals ('POST' )
737
797
..url.path.equals ('/api/v1/messages' )
@@ -745,6 +805,13 @@ void main() {
745
805
checkMessageNotSent (tester);
746
806
});
747
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
+ }, skip: true ); // null topic names soon to be enabled
814
+
748
815
testWidgets ('if topics are mandatory, reject "(no topic)"' , (tester) async {
749
816
await setupAndTapSend (tester,
750
817
topicInputText: '(no topic)' ,
0 commit comments