@@ -248,15 +248,13 @@ void main() {
248
248
testWidgets ('pagination' , (WidgetTester tester) async {
249
249
// Check that `lastProcessedId` returned from an initial
250
250
// response is used as `anchorId` for the subsequent request.
251
- final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
252
251
await prepare (tester);
253
252
254
253
connection.prepare (json: UpdateMessageFlagsForNarrowResult (
255
254
processedCount: 1000 , updatedCount: 890 ,
256
255
firstProcessedId: 1 , lastProcessedId: 1989 ,
257
256
foundOldest: true , foundNewest: false ).toJson ());
258
- markNarrowAsRead (context, narrow);
259
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
257
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ();
260
258
check (connection.lastRequest).isA< http.Request > ()
261
259
..method.equals ('POST' )
262
260
..url.path.equals ('/api/v1/messages/flags/narrow' )
@@ -288,19 +286,18 @@ void main() {
288
286
'op' : 'add' ,
289
287
'flag' : 'read' ,
290
288
});
289
+ check (await didPass).isTrue ();
291
290
});
292
291
293
292
testWidgets ('on invalid response' , (WidgetTester tester) async {
294
293
final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
295
- final narrow = TopicNarrow .ofMessage (eg.streamMessage ());
296
294
await prepare (tester);
297
295
connection.prepare (json: UpdateMessageFlagsForNarrowResult (
298
296
processedCount: 1000 , updatedCount: 0 ,
299
297
firstProcessedId: null , lastProcessedId: null ,
300
298
foundOldest: true , foundNewest: false ).toJson ());
301
- markNarrowAsRead (context, narrow );
299
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ( );
302
300
await tester.pump (Duration .zero);
303
- final apiNarrow = narrow.apiEncode ()..add (ApiNarrowIsUnread ());
304
301
check (connection.lastRequest).isA< http.Request > ()
305
302
..method.equals ('POST' )
306
303
..url.path.equals ('/api/v1/messages/flags/narrow' )
@@ -316,21 +313,21 @@ void main() {
316
313
317
314
await tester.pumpAndSettle ();
318
315
checkErrorDialog (tester,
319
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle ,
316
+ expectedTitle: onFailedTitle ,
320
317
expectedMessage: zulipLocalizations.errorInvalidResponse);
318
+ check (await didPass).isFalse ();
321
319
});
322
320
323
321
testWidgets ('catch-all api errors' , (WidgetTester tester) async {
324
- final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
325
- const narrow = CombinedFeedNarrow ();
326
322
await prepare (tester);
327
323
connection.prepare (exception: http.ClientException ('Oops' ));
328
- markNarrowAsRead (context, narrow );
324
+ final didPass = invokeUpdateMessageFlagsStartingFromAnchor ( );
329
325
await tester.pump (Duration .zero);
330
326
await tester.pumpAndSettle ();
331
327
checkErrorDialog (tester,
332
- expectedTitle: zulipLocalizations.errorMarkAsReadFailedTitle ,
328
+ expectedTitle: onFailedTitle ,
333
329
expectedMessage: 'NetworkException: Oops (ClientException: Oops)' );
330
+ check (await didPass).isFalse ();
334
331
});
335
332
});
336
333
}
0 commit comments