@@ -54,7 +54,8 @@ import {
5454 writeBatch ,
5555 CollectionReference ,
5656 WriteBatch ,
57- Firestore
57+ Firestore ,
58+ getDocsFromServer
5859} from '../util/firebase_export' ;
5960import {
6061 apiDescribe ,
@@ -66,7 +67,8 @@ import {
6667 withRetry ,
6768 withTestCollection ,
6869 withTestDb ,
69- checkOnlineAndOfflineResultsMatch
70+ checkOnlineAndOfflineResultsMatch ,
71+ toIds
7072} from '../util/helpers' ;
7173import { USE_EMULATOR } from '../util/settings' ;
7274import { captureExistenceFilterMismatches } from '../util/testing_hooks_util' ;
@@ -2262,6 +2264,35 @@ apiDescribe('Queries', persistence => {
22622264 }
22632265 ) ;
22642266 } ) ;
2267+
2268+ it ( 'snapshot listener sorts cross type numbers same way as server' , async ( ) => {
2269+ const testDocs = {
2270+ 'longMin' : { value : '-9223372036854775808' } ,
2271+ 'longMax' : { value : '9223372036854775807' } ,
2272+ 'NaN' : { value : NaN } ,
2273+ 'maxSafeInteger' : { value : Number . MAX_SAFE_INTEGER } ,
2274+ 'minSafeInteger' : { value : Number . MIN_SAFE_INTEGER } ,
2275+ 'maxValue' : { value : Number . MAX_VALUE } ,
2276+ 'negativeMaxValue' : { value : - Number . MAX_VALUE } ,
2277+ 'minValue' : { value : Number . MIN_VALUE } ,
2278+ 'negativeMinValue' : { value : - Number . MIN_VALUE } ,
2279+ 'negativeInfinity' : { value : - Infinity } ,
2280+ 'positiveInfinity' : { value : Infinity }
2281+ } ;
2282+
2283+ return withTestCollection ( persistence , testDocs , async collectionRef => {
2284+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2285+
2286+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2287+
2288+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2289+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2290+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2291+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2292+
2293+ unsubscribe ( ) ;
2294+ } ) ;
2295+ } ) ;
22652296} ) ;
22662297
22672298apiDescribe ( 'Hanging query issue - #7652' , persistence => {
0 commit comments