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