Skip to content

Commit c6a2e64

Browse files
committed
test: add test for startAfterDocument() to ensure Timestamp cursor precision is preserved
1 parent 9940fed commit c6a2e64

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

  • packages/cloud_firestore/cloud_firestore/example/integration_test

packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,29 @@ void runQueryTests() {
10231023
expect(snapshot.docs[1].id, equals('doc4'));
10241024
});
10251025

1026+
test('startAfterDocument() preserves Timestamp cursor precision',
1027+
() async {
1028+
CollectionReference<Map<String, dynamic>> collection =
1029+
await initializeTest('startAfter-document-timestamp-precision');
1030+
await collection.doc('doc1').set({
1031+
'createdAt': Timestamp(1, 123456789),
1032+
});
1033+
1034+
Query<Map<String, dynamic>> baseQuery = collection.orderBy('createdAt');
1035+
QuerySnapshot<Map<String, dynamic>> firstPage =
1036+
await baseQuery.limit(50).get();
1037+
1038+
expect(firstPage.docs.length, equals(1));
1039+
expect(firstPage.docs.first.id, equals('doc1'));
1040+
1041+
QuerySnapshot<Map<String, dynamic>> nextPage = await baseQuery
1042+
.startAfterDocument(firstPage.docs.last)
1043+
.limit(50)
1044+
.get();
1045+
1046+
expect(nextPage.docs, isEmpty);
1047+
});
1048+
10261049
testWidgets(
10271050
'throws exception without orderBy() on field used for inequality query',
10281051
(_) async {

0 commit comments

Comments
 (0)