@@ -47,6 +47,7 @@ void main() {
47
47
List <User > otherUsers = const [],
48
48
List <ZulipStream > streams = const [],
49
49
bool ? mandatoryTopics,
50
+ int ? maxTopicLength,
50
51
}) async {
51
52
if (narrow case ChannelNarrow (: var streamId) || TopicNarrow (: var streamId)) {
52
53
assert (streams.any ((stream) => stream.streamId == streamId),
@@ -56,7 +57,7 @@ void main() {
56
57
selfUser ?? = eg.selfUser;
57
58
final selfAccount = eg.account (user: selfUser);
58
59
await testBinding.globalStore.add (selfAccount, eg.initialSnapshot (
59
- realmMandatoryTopics: mandatoryTopics,
60
+ realmMandatoryTopics: mandatoryTopics, maxTopicLength : maxTopicLength
60
61
));
61
62
62
63
store = await testBinding.globalStore.perAccount (selfAccount.id);
@@ -283,41 +284,47 @@ void main() {
283
284
});
284
285
285
286
group ('topic' , () {
286
- Future <void > prepareWithTopic (WidgetTester tester, String topic) async {
287
+ Future <void > prepareWithTopic (WidgetTester tester, String topic, int maxTopicLength ) async {
287
288
TypingNotifier .debugEnable = false ;
288
289
addTearDown (TypingNotifier .debugReset);
289
290
290
291
final narrow = ChannelNarrow (channel.streamId);
291
- await prepareComposeBox (tester, narrow: narrow, streams: [channel]);
292
+ await prepareComposeBox (tester, narrow: narrow, streams: [channel],
293
+ maxTopicLength: maxTopicLength);
292
294
await enterTopic (tester, narrow: narrow, topic: topic);
293
295
await enterContent (tester, 'some content' );
294
296
}
295
297
296
- Future <void > checkErrorResponse (WidgetTester tester) async {
298
+ Future <void > checkErrorResponse (WidgetTester tester, { required int maxTopicLength} ) async {
297
299
await tester.tap (find.byWidget (checkErrorDialog (tester,
298
300
expectedTitle: 'Message not sent' ,
299
- expectedMessage: 'Topic length shouldn\' t be greater than 60 characters.' )));
301
+ expectedMessage: 'Topic length shouldn\' t be greater than $ maxTopicLength characters.' )));
300
302
}
301
303
304
+ final ValueVariant <int > maxTopicLengthVariants = ValueVariant <int >({50 , 60 , 70 });
305
+
302
306
testWidgets ('too-long topic is rejected' , (tester) async {
307
+ final maxTopicLength = maxTopicLengthVariants.currentValue! ;
303
308
await prepareWithTopic (tester,
304
- makeStringWithCodePoints (kMaxTopicLengthCodePoints + 1 ));
309
+ makeStringWithCodePoints (maxTopicLength + 1 ), maxTopicLength );
305
310
await tapSendButton (tester);
306
- await checkErrorResponse (tester);
307
- });
311
+ await checkErrorResponse (tester, maxTopicLength : maxTopicLength );
312
+ }, variant : maxTopicLengthVariants );
308
313
309
314
testWidgets ('max-length topic not rejected' , (tester) async {
315
+ final maxTopicLength = maxTopicLengthVariants.currentValue! ;
310
316
await prepareWithTopic (tester,
311
- makeStringWithCodePoints (kMaxTopicLengthCodePoints) );
317
+ makeStringWithCodePoints (maxTopicLength), maxTopicLength );
312
318
await tapSendButton (tester);
313
319
checkNoErrorDialog (tester);
314
- });
320
+ }, variant : maxTopicLengthVariants );
315
321
316
322
testWidgets ('code points not counted unnecessarily' , (tester) async {
317
- await prepareWithTopic (tester, 'a' * kMaxTopicLengthCodePoints);
323
+ final maxTopicLength = maxTopicLengthVariants.currentValue! ;
324
+ await prepareWithTopic (tester, 'a' * maxTopicLength, maxTopicLength);
318
325
check ((controller as StreamComposeBoxController )
319
326
.topic.debugLengthUnicodeCodePointsIfLong).isNull ();
320
- });
327
+ }, variant : maxTopicLengthVariants );
321
328
});
322
329
});
323
330
0 commit comments