@@ -580,12 +580,14 @@ void main() {
580
580
connection = store.connection as FakeApiConnection ;
581
581
}
582
582
583
- Future <void > prepareStore ({int ? lastEventId}) async {
583
+ Future <void > preparePoll ({int ? lastEventId}) async {
584
584
globalStore = TestGlobalStore (accounts: []);
585
585
await globalStore.add (eg.selfAccount, eg.initialSnapshot (
586
586
lastEventId: lastEventId));
587
587
await globalStore.perAccount (eg.selfAccount.id);
588
588
updateFromGlobalStore ();
589
+ updateMachine.debugPauseLoop ();
590
+ updateMachine.poll ();
589
591
}
590
592
591
593
void checkLastRequest ({required int lastEventId}) {
@@ -599,12 +601,9 @@ void main() {
599
601
}
600
602
601
603
test ('loops on success' , () => awaitFakeAsync ((async ) async {
602
- await prepareStore (lastEventId: 1 );
604
+ await preparePoll (lastEventId: 1 );
603
605
check (updateMachine.lastEventId).equals (1 );
604
606
605
- updateMachine.debugPauseLoop ();
606
- updateMachine.poll ();
607
-
608
607
// Loop makes first request, and processes result.
609
608
connection.prepare (json: GetEventsResult (events: [
610
609
HeartbeatEvent (id: 2 ),
@@ -627,9 +626,7 @@ void main() {
627
626
}));
628
627
629
628
test ('handles events' , () => awaitFakeAsync ((async ) async {
630
- await prepareStore ();
631
- updateMachine.debugPauseLoop ();
632
- updateMachine.poll ();
629
+ await preparePoll ();
633
630
634
631
// Pick some arbitrary event and check it gets processed on the store.
635
632
check (store.userSettings! .twentyFourHourTime).isFalse ();
@@ -644,9 +641,7 @@ void main() {
644
641
}));
645
642
646
643
test ('handles expired queue' , () => awaitFakeAsync ((async ) async {
647
- await prepareStore ();
648
- updateMachine.debugPauseLoop ();
649
- updateMachine.poll ();
644
+ await preparePoll ();
650
645
check (globalStore.perAccountSync (store.accountId)).identicalTo (store);
651
646
652
647
// Let the server expire the event queue.
@@ -681,9 +676,7 @@ void main() {
681
676
682
677
test ('expired queue disposes registered MessageListView instances' , () => awaitFakeAsync ((async ) async {
683
678
// Regression test for: https://github.com/zulip/zulip-flutter/issues/810
684
- await prepareStore ();
685
- updateMachine.debugPauseLoop ();
686
- updateMachine.poll ();
679
+ await preparePoll ();
687
680
688
681
// Make sure there are [MessageListView]s in the message store.
689
682
MessageListView .init (store: store, narrow: const MentionsNarrow ());
@@ -707,9 +700,7 @@ void main() {
707
700
708
701
void checkRetry (void Function () prepareError) {
709
702
awaitFakeAsync ((async ) async {
710
- await prepareStore (lastEventId: 1 );
711
- updateMachine.debugPauseLoop ();
712
- updateMachine.poll ();
703
+ await preparePoll (lastEventId: 1 );
713
704
check (async .pendingTimers).length.equals (0 );
714
705
715
706
// Make the request, inducing an error in it.
@@ -774,10 +765,7 @@ void main() {
774
765
Future <void > prepare () async {
775
766
reportErrorToUserBriefly = logAndReportErrorToUserBriefly;
776
767
addTearDown (() => reportErrorToUserBriefly = defaultReportErrorToUserBriefly);
777
-
778
- await prepareStore (lastEventId: 1 );
779
- updateMachine.debugPauseLoop ();
780
- updateMachine.poll ();
768
+ await preparePoll (lastEventId: 1 );
781
769
}
782
770
783
771
void pollAndFail (FakeAsync async ) {
0 commit comments