@@ -754,7 +754,7 @@ describeSpec('Listens:', [], () => {
754
754
) ;
755
755
756
756
specTest (
757
- 'Query is re-listened to after primary tab failover' ,
757
+ 'Listen is re-listened to after primary tab failover' ,
758
758
[ 'multi-client' ] ,
759
759
( ) => {
760
760
const query = Query . atPath ( path ( 'collection' ) ) ;
@@ -787,13 +787,13 @@ describeSpec('Listens:', [], () => {
787
787
}
788
788
) ;
789
789
790
- specTest ( 'Query is established in new primary tab' , [ 'multi-client' ] , ( ) => {
790
+ specTest ( 'Listen is established in new primary tab' , [ 'multi-client' ] , ( ) => {
791
791
const query = Query . atPath ( path ( 'collection' ) ) ;
792
792
const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
793
793
const docB = doc ( 'collection/b' , 2000 , { key : 'b' } ) ;
794
794
795
- // Client 1 and Client 3 listen to the same query. When client 1 shuts
796
- // down, client 2 becomes primary and takes ownership of a query it
795
+ // Client 0 and Client 2 listen to the same query. When client 0 shuts
796
+ // down, client 1 becomes primary and takes ownership of a query it
797
797
// did not previously listen to.
798
798
return client ( 0 )
799
799
. expectPrimaryState ( true )
@@ -814,4 +814,36 @@ describeSpec('Listens:', [], () => {
814
814
. client ( 2 )
815
815
. expectEvents ( query , { added : [ docB ] } ) ;
816
816
} ) ;
817
+
818
+ specTest (
819
+ 'Listen is established in newly started primary' ,
820
+ [ 'multi-client' ] ,
821
+ ( ) => {
822
+ const query = Query . atPath ( path ( 'collection' ) ) ;
823
+ const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
824
+ const docB = doc ( 'collection/b' , 2000 , { key : 'b' } ) ;
825
+
826
+ // Client 0 executes a query on behalf of Client 1. When client 0 shuts
827
+ // down, client 2 starts up and becomes primary, taking ownership of the
828
+ // existing query.
829
+ return client ( 0 )
830
+ . expectPrimaryState ( true )
831
+ . client ( 1 )
832
+ . userListens ( query )
833
+ . expectEvents ( query , { fromCache : true } )
834
+ . client ( 0 )
835
+ . expectListen ( query )
836
+ . watchAcksFull ( query , 1000 , docA )
837
+ . client ( 1 )
838
+ . expectEvents ( query , { added : [ docA ] } )
839
+ . client ( 0 )
840
+ . shutdown ( )
841
+ . client ( 2 )
842
+ . expectPrimaryState ( true )
843
+ . expectListen ( query , 'resume-token-1000' )
844
+ . watchAcksFull ( query , 2000 , docB )
845
+ . client ( 1 )
846
+ . expectEvents ( query , { added : [ docB ] } ) ;
847
+ }
848
+ ) ;
817
849
} ) ;
0 commit comments