Skip to content

Commit b592298

Browse files
authored
MIEQ: add negative test cases (#7680)
1 parent 8283a55 commit b592298

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/firestore/test/integration/api/query.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,34 @@ apiDescribe('Queries', persistence => {
19121912
});
19131913
}
19141914
);
1915+
1916+
it('inequality query will reject if document key is not the last orderBy field', () => {
1917+
return withEmptyTestCollection(persistence, async coll => {
1918+
// Implicitly ordered by: __name__ asc, 'key' asc,
1919+
const queryForRejection = query(
1920+
coll,
1921+
where('key', '!=', 42),
1922+
orderBy(documentId())
1923+
);
1924+
1925+
await expect(getDocs(queryForRejection)).to.be.eventually.rejectedWith(
1926+
'order by clause cannot contain more fields after the key'
1927+
);
1928+
});
1929+
});
1930+
1931+
it('inequality query will reject if document key appears only in equality filter', () => {
1932+
return withEmptyTestCollection(persistence, async coll => {
1933+
const query_ = query(
1934+
coll,
1935+
where('key', '!=', 42),
1936+
where(documentId(), '==', 'doc1')
1937+
);
1938+
await expect(getDocs(query_)).to.be.eventually.rejectedWith(
1939+
'Equality on key is not allowed if there are other inequality fields and key does not appear in inequalities.'
1940+
);
1941+
});
1942+
});
19151943
});
19161944

19171945
// OR Query tests only run when the SDK's local cache is configured to use

scripts/emulator-testing/emulators/firestore-emulator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class FirestoreEmulator extends Emulator {
2626
// Use locked version of emulator for test to be deterministic.
2727
// The latest version can be found from firestore emulator doc:
2828
// https://firebase.google.com/docs/firestore/security/test-rules-emulator
29-
'https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.18.1.jar',
29+
'https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.18.2.jar',
3030
port
3131
);
3232
this.projectId = projectId;

0 commit comments

Comments
 (0)