@@ -48,6 +48,7 @@ void main() {
4848 List <ZulipStream > streams = const [],
4949 bool ? mandatoryTopics,
5050 int ? zulipFeatureLevel,
51+ int ? maxTopicLength,
5152 }) async {
5253 if (narrow case ChannelNarrow (: var streamId) || TopicNarrow (: var streamId)) {
5354 assert (streams.any ((stream) => stream.streamId == streamId),
@@ -60,6 +61,7 @@ void main() {
6061 await testBinding.globalStore.add (selfAccount, eg.initialSnapshot (
6162 zulipFeatureLevel: zulipFeatureLevel,
6263 realmMandatoryTopics: mandatoryTopics,
64+ maxTopicLength: maxTopicLength,
6365 ));
6466
6567 store = await testBinding.globalStore.perAccount (selfAccount.id);
@@ -286,41 +288,47 @@ void main() {
286288 });
287289
288290 group ('topic' , () {
289- Future <void > prepareWithTopic (WidgetTester tester, String topic) async {
291+ Future <void > prepareWithTopic (WidgetTester tester, String topic, int maxTopicLength ) async {
290292 TypingNotifier .debugEnable = false ;
291293 addTearDown (TypingNotifier .debugReset);
292294
293295 final narrow = ChannelNarrow (channel.streamId);
294- await prepareComposeBox (tester, narrow: narrow, streams: [channel]);
296+ await prepareComposeBox (tester, narrow: narrow, streams: [channel],
297+ maxTopicLength: maxTopicLength);
295298 await enterTopic (tester, narrow: narrow, topic: topic);
296299 await enterContent (tester, 'some content' );
297300 }
298301
299- Future <void > checkErrorResponse (WidgetTester tester) async {
302+ Future <void > checkErrorResponse (WidgetTester tester, { required int maxTopicLength} ) async {
300303 await tester.tap (find.byWidget (checkErrorDialog (tester,
301304 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.' )));
303306 }
304307
308+ final ValueVariant <int > maxTopicLengthVariants = ValueVariant <int >({50 , 60 , 70 });
309+
305310 testWidgets ('too-long topic is rejected' , (tester) async {
311+ final maxTopicLength = maxTopicLengthVariants.currentValue! ;
306312 await prepareWithTopic (tester,
307- makeStringWithCodePoints (kMaxTopicLengthCodePoints + 1 ));
313+ makeStringWithCodePoints (maxTopicLength + 1 ), maxTopicLength );
308314 await tapSendButton (tester);
309- await checkErrorResponse (tester);
310- });
315+ await checkErrorResponse (tester, maxTopicLength : maxTopicLength );
316+ }, variant : maxTopicLengthVariants );
311317
312318 testWidgets ('max-length topic not rejected' , (tester) async {
319+ final maxTopicLength = maxTopicLengthVariants.currentValue! ;
313320 await prepareWithTopic (tester,
314- makeStringWithCodePoints (kMaxTopicLengthCodePoints) );
321+ makeStringWithCodePoints (maxTopicLength), maxTopicLength );
315322 await tapSendButton (tester);
316323 checkNoErrorDialog (tester);
317- });
324+ }, variant : maxTopicLengthVariants );
318325
319326 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);
321329 check ((controller as StreamComposeBoxController )
322330 .topic.debugLengthUnicodeCodePointsIfLong).isNull ();
323- });
331+ }, variant : maxTopicLengthVariants );
324332 });
325333 });
326334
0 commit comments