Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for comparing cross type numbers #2264

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4019,6 +4019,47 @@ describe('Query class', () => {
unsubscribe();
});

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('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
Expand Down
Loading