From 39dd55009a2038d8c8d5ffee3179acdec88f3ad5 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:29:39 -0500 Subject: [PATCH 1/3] add test case --- dev/system-test/firestore.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index f57c2767c..768118a37 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -4019,6 +4019,40 @@ describe('Query class', () => { unsubscribe(); }); + it.only('snapshot listener sorts cross type numbers same way as server', async () => { + const batch = firestore.batch(); + batch.set(randomCol.doc('longMin'), {value: BigInt('-9223372036854775808')});// this gets converted to number and looses precision + batch.set(randomCol.doc('longMax'), {value: BigInt('9223372036854775807')}); + batch.set(randomCol.doc('NaN'), {value: NaN}); + batch.set(randomCol.doc('maxSafeInteger'), {value: Number.MAX_SAFE_INTEGER}); + batch.set(randomCol.doc('minSafeInteger'), {value: Number.MIN_SAFE_INTEGER}); + batch.set(randomCol.doc('maxValue'), {value: Number.MAX_VALUE}); + batch.set(randomCol.doc('negativeMaxValue'), {value: -Number.MAX_VALUE}); + batch.set(randomCol.doc('minValue'), {value: Number.MIN_VALUE}); + batch.set(randomCol.doc('negativeMinValue'), {value: -Number.MIN_VALUE}); + batch.set(randomCol.doc('negativeInfinity'), {value: -Infinity}); + batch.set(randomCol.doc('positiveInfinity'), {value: Infinity}); + await batch.commit(); + + const query = randomCol + .orderBy('value'); + + const getSnapshot = await query.get(); + + const unsubscribe = query.onSnapshot(snapshot => + currentDeferred.resolve(snapshot) + ); + + const watchSnapshot = await waitForSnapshot(); + + // Compare the snapshot (including sort order) of a snapshot + snapshotsEqual(watchSnapshot, { + docs: getSnapshot.docs, + docChanges: getSnapshot.docChanges(), + }); + unsubscribe(); + }); + it('SDK orders vector field same way as backend', async () => { // We validate that the SDK orders the vector field the same way as the backend // by comparing the sort order of vector fields from a Query.get() and From 8844dc67ab4deacfcb4e05cbc025beb7fcec30d6 Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:30:43 -0500 Subject: [PATCH 2/3] fix lint --- dev/system-test/firestore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 768118a37..6c8dcaa6b 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -4019,7 +4019,7 @@ describe('Query class', () => { unsubscribe(); }); - it.only('snapshot listener sorts cross type numbers same way as server', async () => { + it('snapshot listener sorts cross type numbers same way as server', async () => { const batch = firestore.batch(); batch.set(randomCol.doc('longMin'), {value: BigInt('-9223372036854775808')});// this gets converted to number and looses precision batch.set(randomCol.doc('longMax'), {value: BigInt('9223372036854775807')}); From baef7af7abc9a886b39e764c50e0109483ad05bd Mon Sep 17 00:00:00 2001 From: milaGGL <107142260+milaGGL@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:29:29 -0500 Subject: [PATCH 3/3] format --- dev/system-test/firestore.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 6c8dcaa6b..75effe098 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -4021,11 +4021,19 @@ describe('Query class', () => { it('snapshot listener sorts cross type numbers same way as server', async () => { const batch = firestore.batch(); - batch.set(randomCol.doc('longMin'), {value: BigInt('-9223372036854775808')});// this gets converted to number and looses precision - batch.set(randomCol.doc('longMax'), {value: BigInt('9223372036854775807')}); + batch.set(randomCol.doc('longMin'), { + value: BigInt('-9223372036854775808'), + }); // this gets converted to number and looses precision + batch.set(randomCol.doc('longMax'), { + value: BigInt('9223372036854775807'), + }); batch.set(randomCol.doc('NaN'), {value: NaN}); - batch.set(randomCol.doc('maxSafeInteger'), {value: Number.MAX_SAFE_INTEGER}); - batch.set(randomCol.doc('minSafeInteger'), {value: Number.MIN_SAFE_INTEGER}); + batch.set(randomCol.doc('maxSafeInteger'), { + value: Number.MAX_SAFE_INTEGER, + }); + batch.set(randomCol.doc('minSafeInteger'), { + value: Number.MIN_SAFE_INTEGER, + }); batch.set(randomCol.doc('maxValue'), {value: Number.MAX_VALUE}); batch.set(randomCol.doc('negativeMaxValue'), {value: -Number.MAX_VALUE}); batch.set(randomCol.doc('minValue'), {value: Number.MIN_VALUE}); @@ -4034,13 +4042,12 @@ describe('Query class', () => { batch.set(randomCol.doc('positiveInfinity'), {value: Infinity}); await batch.commit(); - const query = randomCol - .orderBy('value'); + const query = randomCol.orderBy('value'); const getSnapshot = await query.get(); const unsubscribe = query.onSnapshot(snapshot => - currentDeferred.resolve(snapshot) + currentDeferred.resolve(snapshot) ); const watchSnapshot = await waitForSnapshot();