@@ -54,9 +54,11 @@ import {
54
54
apiDescribe ,
55
55
toChangesArray ,
56
56
toDataArray ,
57
+ withEmptyTestCollection ,
57
58
withTestCollection ,
58
59
withTestDb
59
60
} from '../util/helpers' ;
61
+ import { USE_EMULATOR } from '../util/settings' ;
60
62
61
63
apiDescribe ( 'Queries' , ( persistence : boolean ) => {
62
64
addEqualityMatcher ( ) ;
@@ -649,6 +651,38 @@ apiDescribe('Queries', (persistence: boolean) => {
649
651
} ) ;
650
652
} ) ;
651
653
654
+ // eslint-disable-next-line no-restricted-properties
655
+ ( USE_EMULATOR ? it . skip : it ) (
656
+ 'can catch error message for missing index with error handler' ,
657
+ ( ) => {
658
+ return withEmptyTestCollection ( persistence , async coll => {
659
+ const query_ = query (
660
+ coll ,
661
+ where ( 'sort' , '<=' , '2' ) ,
662
+ where ( 'filter' , '==' , true )
663
+ ) ;
664
+ const deferred = new Deferred < void > ( ) ;
665
+
666
+ const unsubscribe = onSnapshot (
667
+ query_ ,
668
+ ( ) => {
669
+ deferred . reject ( ) ;
670
+ } ,
671
+ err => {
672
+ expect ( err . code ) . to . equal ( 'failed-precondition' ) ;
673
+ expect ( err . message ) . to . exist ;
674
+ expect ( err . message ) . to . match (
675
+ / i n d e x .* h t t p s : \/ \/ c o n s o l e \. f i r e b a s e \. g o o g l e \. c o m /
676
+ ) ;
677
+ deferred . resolve ( ) ;
678
+ }
679
+ ) ;
680
+ await deferred . promise ;
681
+ unsubscribe ( ) ;
682
+ } ) ;
683
+ }
684
+ ) ;
685
+
652
686
it ( 'can explicitly sort by document ID' , ( ) => {
653
687
const testDocs = {
654
688
a : { key : 'a' } ,
0 commit comments