@@ -640,39 +640,36 @@ void main() {
640
640
check (store.userSettings! .twentyFourHourTime).isTrue ();
641
641
}));
642
642
643
- test ('handles expired queue' , () => awaitFakeAsync ((async ) async {
644
- await preparePoll ();
645
- check (globalStore.perAccountSync (store.accountId)).identicalTo (store);
643
+ void checkReload (void Function () prepareError) {
644
+ awaitFakeAsync ((async ) async {
645
+ await preparePoll ();
646
+ check (globalStore.perAccountSync (store.accountId)).identicalTo (store);
646
647
647
- // Let the server expire the event queue.
648
- connection.prepare (httpStatus: 400 , json: {
649
- 'result' : 'error' , 'code' : 'BAD_EVENT_QUEUE_ID' ,
650
- 'queue_id' : updateMachine.queueId,
651
- 'msg' : 'Bad event queue ID: ${updateMachine .queueId }' ,
652
- });
653
- updateMachine.debugAdvanceLoop ();
654
- async .flushMicrotasks ();
655
- await Future <void >.delayed (Duration .zero);
656
- check (store).isLoading.isTrue ();
648
+ prepareError ();
649
+ updateMachine.debugAdvanceLoop ();
650
+ async .flushMicrotasks ();
651
+ await Future <void >.delayed (Duration .zero);
652
+ check (store).isLoading.isTrue ();
657
653
658
- // The global store has a new store.
659
- check (globalStore.perAccountSync (store.accountId)).not ((it) => it.identicalTo (store));
660
- updateFromGlobalStore ();
661
- check (store).isLoading.isFalse ();
654
+ // The global store has a new store.
655
+ check (globalStore.perAccountSync (store.accountId)).not ((it) => it.identicalTo (store));
656
+ updateFromGlobalStore ();
657
+ check (store).isLoading.isFalse ();
662
658
663
- // The new UpdateMachine updates the new store.
664
- updateMachine.debugPauseLoop ();
665
- updateMachine.poll ();
666
- check (store.userSettings! .twentyFourHourTime).isFalse ();
667
- connection.prepare (json: GetEventsResult (events: [
668
- UserSettingsUpdateEvent (id: 2 ,
669
- property: UserSettingName .twentyFourHourTime, value: true ),
670
- ], queueId: null ).toJson ());
671
- updateMachine.debugAdvanceLoop ();
672
- async .flushMicrotasks ();
673
- await Future <void >.delayed (Duration .zero);
674
- check (store.userSettings! .twentyFourHourTime).isTrue ();
675
- }));
659
+ // The new UpdateMachine updates the new store.
660
+ updateMachine.debugPauseLoop ();
661
+ updateMachine.poll ();
662
+ check (store.userSettings! .twentyFourHourTime).isFalse ();
663
+ connection.prepare (json: GetEventsResult (events: [
664
+ UserSettingsUpdateEvent (id: 2 ,
665
+ property: UserSettingName .twentyFourHourTime, value: true ),
666
+ ], queueId: null ).toJson ());
667
+ updateMachine.debugAdvanceLoop ();
668
+ async .flushMicrotasks ();
669
+ await Future <void >.delayed (Duration .zero);
670
+ check (store.userSettings! .twentyFourHourTime).isTrue ();
671
+ });
672
+ }
676
673
677
674
test ('expired queue disposes registered MessageListView instances' , () => awaitFakeAsync ((async ) async {
678
675
// Regression test for: https://github.com/zulip/zulip-flutter/issues/810
@@ -747,6 +744,14 @@ void main() {
747
744
'result' : 'error' , 'code' : 'BAD_REQUEST' , 'msg' : 'Bad request' }));
748
745
});
749
746
747
+ test ('reloads on expired queue' , () {
748
+ checkReload (() => connection.prepare (httpStatus: 400 , json: {
749
+ 'result' : 'error' , 'code' : 'BAD_EVENT_QUEUE_ID' ,
750
+ 'queue_id' : updateMachine.queueId,
751
+ 'msg' : 'Bad event queue ID: ${updateMachine .queueId }' ,
752
+ }));
753
+ });
754
+
750
755
group ('report error' , () {
751
756
String ? lastReportedError;
752
757
String ? takeLastReportedError () {
0 commit comments