@@ -20,10 +20,12 @@ void main() {
2020 required bool expectLegacy,
2121 required int messageId,
2222 bool ? applyMarkdown,
23+ required bool allowEmptyTopicName,
2324 }) async {
2425 final result = await getMessageCompat (connection,
2526 messageId: messageId,
2627 applyMarkdown: applyMarkdown,
28+ allowEmptyTopicName: allowEmptyTopicName,
2729 );
2830 if (expectLegacy) {
2931 check (connection.lastRequest).isA< http.Request > ()
@@ -35,6 +37,7 @@ void main() {
3537 'num_before' : '0' ,
3638 'num_after' : '0' ,
3739 if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
40+ 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
3841 'client_gravatar' : 'true' ,
3942 });
4043 } else {
@@ -43,6 +46,7 @@ void main() {
4346 ..url.path.equals ('/api/v1/messages/$messageId ' )
4447 ..url.queryParameters.deepEquals ({
4548 if (applyMarkdown != null ) 'apply_markdown' : applyMarkdown.toString (),
49+ 'allow_empty_topic_name' : allowEmptyTopicName.toString (),
4650 });
4751 }
4852 return result;
@@ -57,6 +61,7 @@ void main() {
5761 expectLegacy: false ,
5862 messageId: message.id,
5963 applyMarkdown: true ,
64+ allowEmptyTopicName: true ,
6065 );
6166 check (result).isNotNull ().jsonEquals (message);
6267 });
@@ -71,6 +76,7 @@ void main() {
7176 expectLegacy: false ,
7277 messageId: message.id,
7378 applyMarkdown: true ,
79+ allowEmptyTopicName: true ,
7480 );
7581 check (result).isNull ();
7682 });
@@ -92,6 +98,7 @@ void main() {
9298 expectLegacy: true ,
9399 messageId: message.id,
94100 applyMarkdown: true ,
101+ allowEmptyTopicName: true ,
95102 );
96103 check (result).isNotNull ().jsonEquals (message);
97104 });
@@ -113,6 +120,7 @@ void main() {
113120 expectLegacy: true ,
114121 messageId: message.id,
115122 applyMarkdown: true ,
123+ allowEmptyTopicName: true ,
116124 );
117125 check (result).isNull ();
118126 });
@@ -124,11 +132,13 @@ void main() {
124132 FakeApiConnection connection, {
125133 required int messageId,
126134 bool ? applyMarkdown,
135+ required bool allowEmptyTopicName,
127136 required Map <String , String > expected,
128137 }) async {
129138 final result = await getMessage (connection,
130139 messageId: messageId,
131140 applyMarkdown: applyMarkdown,
141+ allowEmptyTopicName: allowEmptyTopicName,
132142 );
133143 check (connection.lastRequest).isA< http.Request > ()
134144 ..method.equals ('GET' )
@@ -145,7 +155,11 @@ void main() {
145155 await checkGetMessage (connection,
146156 messageId: 1 ,
147157 applyMarkdown: true ,
148- expected: {'apply_markdown' : 'true' });
158+ allowEmptyTopicName: true ,
159+ expected: {
160+ 'apply_markdown' : 'true' ,
161+ 'allow_empty_topic_name' : 'true' ,
162+ });
149163 });
150164 });
151165
@@ -155,7 +169,21 @@ void main() {
155169 await checkGetMessage (connection,
156170 messageId: 1 ,
157171 applyMarkdown: false ,
158- expected: {'apply_markdown' : 'false' });
172+ allowEmptyTopicName: true ,
173+ expected: {
174+ 'apply_markdown' : 'false' ,
175+ 'allow_empty_topic_name' : 'true' ,
176+ });
177+ });
178+ });
179+
180+ test ('allow empty topic name' , () {
181+ return FakeApiConnection .with_ ((connection) async {
182+ connection.prepare (json: fakeResult.toJson ());
183+ await checkGetMessage (connection,
184+ messageId: 1 ,
185+ allowEmptyTopicName: true ,
186+ expected: {'allow_empty_topic_name' : 'true' });
159187 });
160188 });
161189
@@ -164,6 +192,7 @@ void main() {
164192 connection.prepare (json: fakeResult.toJson ());
165193 check (() => getMessage (connection,
166194 messageId: 1 ,
195+ allowEmptyTopicName: true ,
167196 )).throws <AssertionError >();
168197 });
169198 });
@@ -255,12 +284,14 @@ void main() {
255284 required int numAfter,
256285 bool ? clientGravatar,
257286 bool ? applyMarkdown,
287+ required bool allowEmptyTopicName,
258288 required Map <String , String > expected,
259289 }) async {
260290 final result = await getMessages (connection,
261291 narrow: narrow, anchor: anchor, includeAnchor: includeAnchor,
262292 numBefore: numBefore, numAfter: numAfter,
263293 clientGravatar: clientGravatar, applyMarkdown: applyMarkdown,
294+ allowEmptyTopicName: allowEmptyTopicName,
264295 );
265296 check (connection.lastRequest).isA< http.Request > ()
266297 ..method.equals ('GET' )
@@ -279,11 +310,13 @@ void main() {
279310 await checkGetMessages (connection,
280311 narrow: const CombinedFeedNarrow ().apiEncode (),
281312 anchor: AnchorCode .newest, numBefore: 10 , numAfter: 20 ,
313+ allowEmptyTopicName: true ,
282314 expected: {
283315 'narrow' : jsonEncode ([]),
284316 'anchor' : 'newest' ,
285317 'num_before' : '10' ,
286318 'num_after' : '20' ,
319+ 'allow_empty_topic_name' : 'true' ,
287320 });
288321 });
289322 });
@@ -294,13 +327,15 @@ void main() {
294327 await checkGetMessages (connection,
295328 narrow: [ApiNarrowDm ([123 , 234 ])],
296329 anchor: AnchorCode .newest, numBefore: 10 , numAfter: 20 ,
330+ allowEmptyTopicName: true ,
297331 expected: {
298332 'narrow' : jsonEncode ([
299333 {'operator' : 'pm-with' , 'operand' : [123 , 234 ]},
300334 ]),
301335 'anchor' : 'newest' ,
302336 'num_before' : '10' ,
303337 'num_after' : '20' ,
338+ 'allow_empty_topic_name' : 'true' ,
304339 });
305340 });
306341 });
@@ -312,11 +347,13 @@ void main() {
312347 narrow: const CombinedFeedNarrow ().apiEncode (),
313348 anchor: const NumericAnchor (42 ),
314349 numBefore: 10 , numAfter: 20 ,
350+ allowEmptyTopicName: true ,
315351 expected: {
316352 'narrow' : jsonEncode ([]),
317353 'anchor' : '42' ,
318354 'num_before' : '10' ,
319355 'num_after' : '20' ,
356+ 'allow_empty_topic_name' : 'true' ,
320357 });
321358 });
322359 });
0 commit comments