@@ -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
@@ -326,11 +329,15 @@ void main() {
326
329
327
330
Future <void > prepare (WidgetTester tester, {
328
331
required Narrow narrow,
332
+ bool ? mandatoryTopics,
333
+ int ? zulipFeatureLevel,
329
334
}) async {
330
335
await prepareComposeBox (tester,
331
336
narrow: narrow,
332
337
otherUsers: [eg.otherUser, eg.thirdUser],
333
- streams: [channel]);
338
+ streams: [channel],
339
+ mandatoryTopics: mandatoryTopics,
340
+ zulipFeatureLevel: zulipFeatureLevel);
334
341
}
335
342
336
343
void checkComposeBoxHintTexts (WidgetTester tester, {
@@ -347,48 +354,79 @@ void main() {
347
354
of: contentInputFinder, matching: find.text (contentHintText))).findsOne ();
348
355
}
349
356
350
- testWidgets ('to ChannelNarrow without topic' , (tester) async {
351
- await prepare (tester, narrow: ChannelNarrow (channel.streamId));
357
+ testWidgets ('to ChannelNarrow with empty topic' , (tester) async {
358
+ await prepare (tester, narrow: ChannelNarrow (channel.streamId),
359
+ mandatoryTopics: false );
360
+ checkComposeBoxHintTexts (tester,
361
+ topicHintText: eg.defaultRealmEmptyTopicDisplayName,
362
+ contentHintText: 'Message #${channel .name } > ${eg .defaultRealmEmptyTopicDisplayName }' );
363
+ }, skip: true ); // null topic names soon to be enabled
364
+
365
+ testWidgets ('to ChannelNarrow with empty topic (mandatory topics)' , (tester) async {
366
+ await prepare (tester, narrow: ChannelNarrow (channel.streamId),
367
+ mandatoryTopics: true );
368
+ checkComposeBoxHintTexts (tester,
369
+ topicHintText: 'Topic' ,
370
+ contentHintText: 'Message #${channel .name } > ${eg .defaultRealmEmptyTopicDisplayName }' );
371
+ }, skip: true ); // null topic names soon to be enabled
372
+
373
+ testWidgets ('legacy: to ChannelNarrow with empty topic' , (tester) async {
374
+ await prepare (tester, narrow: ChannelNarrow (channel.streamId),
375
+ mandatoryTopics: false ,
376
+ zulipFeatureLevel: 333 );
352
377
checkComposeBoxHintTexts (tester,
353
378
topicHintText: 'Topic' ,
354
379
contentHintText: 'Message #${channel .name } > (no topic)' );
355
380
});
356
381
357
- testWidgets ('to ChannelNarrow with topic' , (tester) async {
382
+ testWidgets ('to ChannelNarrow with non-empty topic' , (tester) async {
358
383
final narrow = ChannelNarrow (channel.streamId);
359
- await prepare (tester, narrow: narrow);
384
+ await prepare (tester, narrow: narrow,
385
+ mandatoryTopics: false );
360
386
await enterTopic (tester, narrow: narrow, topic: 'new topic' );
361
387
await tester.pump ();
362
388
checkComposeBoxHintTexts (tester,
363
- topicHintText: 'Topic' ,
389
+ topicHintText: eg.defaultRealmEmptyTopicDisplayName ,
364
390
contentHintText: 'Message #${channel .name } > new topic' );
365
391
});
366
392
367
- testWidgets ('to TopicNarrow' , (tester) async {
393
+ testWidgets ('to TopicNarrow with non-empty topic ' , (tester) async {
368
394
await prepare (tester,
369
- narrow: TopicNarrow (channel.streamId, TopicName ('topic' )));
395
+ narrow: TopicNarrow (channel.streamId, TopicName ('topic' )),
396
+ mandatoryTopics: false );
370
397
checkComposeBoxHintTexts (tester,
371
398
contentHintText: 'Message #${channel .name } > topic' );
372
399
});
373
400
401
+ testWidgets ('to TopicNarrow with empty topic' , (tester) async {
402
+ await prepare (tester,
403
+ narrow: TopicNarrow (channel.streamId, TopicName ('' )),
404
+ mandatoryTopics: false );
405
+ checkComposeBoxHintTexts (tester, contentHintText:
406
+ 'Message #${channel .name } > ${eg .defaultRealmEmptyTopicDisplayName }' );
407
+ }, skip: true ); // null topic names soon to be enabled
408
+
374
409
testWidgets ('to DmNarrow with self' , (tester) async {
375
410
await prepare (tester, narrow: DmNarrow .withUser (
376
- eg.selfUser.userId, selfUserId: eg.selfUser.userId));
411
+ eg.selfUser.userId, selfUserId: eg.selfUser.userId),
412
+ mandatoryTopics: false );
377
413
checkComposeBoxHintTexts (tester,
378
414
contentHintText: 'Jot down something' );
379
415
});
380
416
381
417
testWidgets ('to 1:1 DmNarrow' , (tester) async {
382
418
await prepare (tester, narrow: DmNarrow .withUser (
383
- eg.otherUser.userId, selfUserId: eg.selfUser.userId));
419
+ eg.otherUser.userId, selfUserId: eg.selfUser.userId),
420
+ mandatoryTopics: false );
384
421
checkComposeBoxHintTexts (tester,
385
422
contentHintText: 'Message @${eg .otherUser .fullName }' );
386
423
});
387
424
388
425
testWidgets ('to group DmNarrow' , (tester) async {
389
426
await prepare (tester, narrow: DmNarrow .withOtherUsers (
390
427
[eg.otherUser.userId, eg.thirdUser.userId],
391
- selfUserId: eg.selfUser.userId));
428
+ selfUserId: eg.selfUser.userId),
429
+ mandatoryTopics: false );
392
430
checkComposeBoxHintTexts (tester,
393
431
contentHintText: 'Message group' );
394
432
});
0 commit comments