@@ -240,14 +240,17 @@ void main() {
240
240
// Check that `lastProcessedId` returned from an initial
241
241
// response is used as `anchorId` for the subsequent request.
242
242
final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
243
+ final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
243
244
await prepare (tester);
244
245
245
246
connection.prepare (json: UpdateMessageFlagsForNarrowResult (
246
247
processedCount: 1000 , updatedCount: 890 ,
247
248
firstProcessedId: 1 , lastProcessedId: 1989 ,
248
249
foundOldest: true , foundNewest: false ).toJson ());
249
- markNarrowAsRead (context, narrow);
250
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
250
+ final didPass = updateMessageFlagsStartingFromAnchor (
251
+ context: context, apiNarrow: apiNarrow, op: UpdateMessageFlagsOp .add, flag: MessageFlag .read,
252
+ includeAnchor: false , startingAnchor: AnchorCode .oldest, onCompletedMessage: onCompletedMessage,
253
+ onFailedTitle: onFailedTitle, progressMessage: progressMessage);
251
254
check (connection.lastRequest).isA< http.Request > ()
252
255
..method.equals ('POST' )
253
256
..url.path.equals ('/api/v1/messages/flags/narrow' )
@@ -279,19 +282,23 @@ void main() {
279
282
'op' : 'add' ,
280
283
'flag' : 'read' ,
281
284
});
285
+ check (await didPass).isTrue ();
282
286
});
283
287
284
288
testWidgets ('on invalid response' , (WidgetTester tester) async {
285
289
final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
286
290
final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
291
+ final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
287
292
await prepare (tester);
288
293
connection.prepare (json: UpdateMessageFlagsForNarrowResult (
289
294
processedCount: 1000 , updatedCount: 0 ,
290
295
firstProcessedId: null , lastProcessedId: null ,
291
296
foundOldest: true , foundNewest: false ).toJson ());
292
- markNarrowAsRead (context, narrow);
297
+ final didPass = updateMessageFlagsStartingFromAnchor (
298
+ context: context, apiNarrow: apiNarrow, op: UpdateMessageFlagsOp .add, flag: MessageFlag .read,
299
+ includeAnchor: false , startingAnchor: AnchorCode .oldest, onCompletedMessage: onCompletedMessage,
300
+ onFailedTitle: onFailedTitle, progressMessage: progressMessage);
293
301
await tester.pump (Duration .zero);
294
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
295
302
check (connection.lastRequest).isA< http.Request > ()
296
303
..method.equals ('POST' )
297
304
..url.path.equals ('/api/v1/messages/flags/narrow' )
@@ -307,21 +314,26 @@ void main() {
307
314
308
315
await tester.pumpAndSettle ();
309
316
checkErrorDialog (tester,
310
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle ,
317
+ expectedTitle: onFailedTitle ,
311
318
expectedMessage: zulipLocalizations.errorInvalidResponse);
319
+ check (await didPass).isFalse ();
312
320
});
313
321
314
322
testWidgets ('catch-all api errors' , (WidgetTester tester) async {
315
- final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
316
323
const narrow = CombinedFeedNarrow ();
324
+ final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
317
325
await prepare (tester);
318
326
connection.prepare (exception: http.ClientException ('Oops' ));
319
- markNarrowAsRead (context, narrow);
327
+ final didPass = updateMessageFlagsStartingFromAnchor (
328
+ context: context, apiNarrow: apiNarrow, op: UpdateMessageFlagsOp .add, flag: MessageFlag .read,
329
+ includeAnchor: false , startingAnchor: AnchorCode .oldest, onCompletedMessage: onCompletedMessage,
330
+ onFailedTitle: onFailedTitle, progressMessage: progressMessage);
320
331
await tester.pump (Duration .zero);
321
332
await tester.pumpAndSettle ();
322
333
checkErrorDialog (tester,
323
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle ,
334
+ expectedTitle: onFailedTitle ,
324
335
expectedMessage: 'NetworkException: Oops (ClientException: Oops)' );
336
+ check (await didPass).isFalse ();
325
337
});
326
338
});
327
339
}
0 commit comments