@@ -8,6 +8,7 @@ import 'package:zulip/api/model/events.dart';
8
8
import 'package:zulip/api/model/model.dart' ;
9
9
import 'package:zulip/api/route/events.dart' ;
10
10
import 'package:zulip/api/route/messages.dart' ;
11
+ import 'package:zulip/log.dart' ;
11
12
import 'package:zulip/model/store.dart' ;
12
13
import 'package:zulip/notifications/receive.dart' ;
13
14
@@ -427,7 +428,9 @@ void main() {
427
428
check (store.userSettings! .twentyFourHourTime).isTrue ();
428
429
}));
429
430
430
- void checkRetry (String description, void Function () prepareError) {
431
+ void checkRetry (String description, void Function () prepareError, {
432
+ String ? errorMessage,
433
+ }) {
431
434
test (description, () {
432
435
awaitFakeAsync ((async ) async {
433
436
await prepareStore (lastEventId: 1 );
@@ -438,7 +441,13 @@ void main() {
438
441
// Make the request, inducing an error in it.
439
442
prepareError ();
440
443
updateMachine.debugAdvanceLoop ();
444
+ check (debugLastReportedError).isNull ();
441
445
async .elapse (Duration .zero);
446
+ if (errorMessage == null ) {
447
+ check (takeLastReportedError ()).isNull ();
448
+ } else {
449
+ check (takeLastReportedError ()).isNotNull ().contains (errorMessage);
450
+ }
442
451
checkLastRequest (lastEventId: 1 );
443
452
check (store).isLoading.isTrue ();
444
453
@@ -470,10 +479,12 @@ void main() {
470
479
471
480
checkRetry ('retries on ZulipApiException' ,
472
481
() => connection.prepare (httpStatus: 400 , json: {
473
- 'result' : 'error' , 'code' : 'BAD_REQUEST' , 'msg' : 'Bad request' }));
482
+ 'result' : 'error' , 'code' : 'BAD_REQUEST' , 'msg' : 'Bad request' }),
483
+ errorMessage: 'Error loading server data. Will retry' );
474
484
475
485
checkRetry ('retries on MalformedServerResponseException' ,
476
- () => connection.prepare (httpStatus: 200 , body: 'nonsense' ));
486
+ () => connection.prepare (httpStatus: 200 , body: 'nonsense' ),
487
+ errorMessage: 'Error loading server data. Will retry' );
477
488
});
478
489
});
479
490
0 commit comments