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