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