@@ -326,11 +326,13 @@ void main() {
326
326
327
327
Future <void > prepare (WidgetTester tester, {
328
328
required Narrow narrow,
329
+ bool ? mandatoryTopics,
329
330
}) async {
330
331
await prepareComposeBox (tester,
331
332
narrow: narrow,
332
333
otherUsers: [eg.otherUser, eg.thirdUser],
333
- streams: [channel]);
334
+ streams: [channel],
335
+ mandatoryTopics: mandatoryTopics);
334
336
}
335
337
336
338
/// This checks the input's configured hint text without regard to whether
@@ -351,17 +353,56 @@ void main() {
351
353
.decoration.isNotNull ().hintText.equals (contentHintText);
352
354
}
353
355
354
- group ('to ChannelNarrow' , () {
356
+ group ('to ChannelNarrow, topics not mandatory' , () {
357
+ final narrow = ChannelNarrow (channel.streamId);
358
+
355
359
testWidgets ('with empty topic' , (tester) async {
356
- await prepare (tester, narrow: ChannelNarrow (channel.streamId));
360
+ await prepare (tester, narrow: narrow, mandatoryTopics: false );
361
+ checkComposeBoxHintTexts (tester,
362
+ topicHintText: 'Topic' ,
363
+ contentHintText: 'Message #${channel .name } > (no topic)' );
364
+ });
365
+
366
+ testWidgets ('with non-empty but vacuous topic' , (tester) async {
367
+ await prepare (tester, narrow: narrow, mandatoryTopics: false );
368
+ await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
369
+ await tester.pump ();
357
370
checkComposeBoxHintTexts (tester,
358
371
topicHintText: 'Topic' ,
359
372
contentHintText: 'Message #${channel .name } > (no topic)' );
360
373
});
361
374
362
375
testWidgets ('with non-empty topic' , (tester) async {
363
- final narrow = ChannelNarrow (channel.streamId);
364
- await prepare (tester, narrow: narrow);
376
+ await prepare (tester, narrow: narrow, mandatoryTopics: false );
377
+ await enterTopic (tester, narrow: narrow, topic: 'new topic' );
378
+ await tester.pump ();
379
+ checkComposeBoxHintTexts (tester,
380
+ topicHintText: 'Topic' ,
381
+ contentHintText: 'Message #${channel .name } > new topic' );
382
+ });
383
+ });
384
+
385
+ group ('to ChannelNarrow, mandatory topics' , () {
386
+ final narrow = ChannelNarrow (channel.streamId);
387
+
388
+ testWidgets ('with empty topic' , (tester) async {
389
+ await prepare (tester, narrow: narrow, mandatoryTopics: true );
390
+ checkComposeBoxHintTexts (tester,
391
+ topicHintText: 'Topic' ,
392
+ contentHintText: 'Message #${channel .name }' );
393
+ });
394
+
395
+ testWidgets ('with non-empty but vacuous topic' , (tester) async {
396
+ await prepare (tester, narrow: narrow, mandatoryTopics: true );
397
+ await enterTopic (tester, narrow: narrow, topic: '(no topic)' );
398
+ await tester.pump ();
399
+ checkComposeBoxHintTexts (tester,
400
+ topicHintText: 'Topic' ,
401
+ contentHintText: 'Message #${channel .name }' );
402
+ });
403
+
404
+ testWidgets ('with non-empty topic' , (tester) async {
405
+ await prepare (tester, narrow: narrow, mandatoryTopics: true );
365
406
await enterTopic (tester, narrow: narrow, topic: 'new topic' );
366
407
await tester.pump ();
367
408
checkComposeBoxHintTexts (tester,
0 commit comments