Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
style: catch remaining dart_style diffs from CI's newer Dart toolchain
CI runs Flutter stable (bundling a newer dart_style than the one used
locally for the previous formatting pass), which flagged 21 more files.
  • Loading branch information
russellwheatley committed Sep 1, 2026
commit 797baf6366e322732695926665a2f884b6737328
Original file line number Diff line number Diff line change
Expand Up @@ -43,62 +43,58 @@ void runCollectionReferenceTests() {
expect(randNum, equals(snapshot.data()!['value']));
});

test(
'snapshots() can be reused',
() async {
final foo = await initializeTest('foo');

final snapshot = foo.snapshots();
final snapshot2 = foo.snapshots();

expect(
await snapshot.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[],
),
);
expect(
await snapshot2.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[],
),
);

await foo.add({'value': 42});
test('snapshots() can be reused', () async {
final foo = await initializeTest('foo');

final snapshot = foo.snapshots();
final snapshot2 = foo.snapshots();

expect(
await snapshot.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[],
),
);
expect(
await snapshot2.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[],
),
);

expect(
await snapshot.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[
isA<QueryDocumentSnapshot>().having((e) => e.data(), 'data', {
'value': 42,
}),
],
),
);
expect(
await snapshot2.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[
isA<QueryDocumentSnapshot<Map<String, dynamic>>>().having(
(e) => e.data(),
'data',
{'value': 42},
),
],
),
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
await foo.add({'value': 42});

expect(
await snapshot.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[
isA<QueryDocumentSnapshot>().having((e) => e.data(), 'data', {
'value': 42,
}),
],
),
);
expect(
await snapshot2.first,
isA<QuerySnapshot<Map<String, dynamic>>>().having(
(e) => e.docs,
'docs',
[
isA<QueryDocumentSnapshot<Map<String, dynamic>>>().having(
(e) => e.data(),
'data',
{'value': 42},
),
],
),
);
}, skip: defaultTargetPlatform == TargetPlatform.windows);

group('withConverter', () {
test('add/snapshot', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,63 +136,58 @@ void runDocumentChangeTests() {
defaultTargetPlatform == TargetPlatform.android,
);

test(
'returns the correct metadata when modifying',
() async {
CollectionReference<Map<String, dynamic>> collection =
await initializeTest('add-modify-document');
DocumentReference<Map<String, dynamic>> doc1 = collection.doc('doc1');
DocumentReference<Map<String, dynamic>> doc2 = collection.doc('doc2');
DocumentReference<Map<String, dynamic>> doc3 = collection.doc('doc3');

await doc1.set({'value': 1});
await doc2.set({'value': 2});
await doc3.set({'value': 3});

final snapshots = <QuerySnapshot<Map<String, dynamic>>>[];
final receivedAll = Completer<void>();

StreamSubscription subscription = collection
.orderBy('value')
.snapshots()
.listen((snapshot) {
snapshots.add(snapshot);
if (snapshots.length >= 2 && !receivedAll.isCompleted) {
receivedAll.complete();
}
});

// Wait for the initial snapshot before modifying
await Future.delayed(const Duration(milliseconds: 500));
await doc1.update({'value': 4});

await receivedAll.future.timeout(const Duration(seconds: 30));
await subscription.cancel();

// Verify first snapshot (all 3 docs added)
expect(snapshots[0].docs.length, equals(3));
expect(snapshots[0].docChanges.length, equals(3));
snapshots[0].docChanges.asMap().forEach((
int index,
DocumentChange<Map<String, dynamic>> change,
) {
expect(change.oldIndex, equals(-1));
expect(change.newIndex, equals(index));
expect(change.type, equals(DocumentChangeType.added));
expect(change.doc.data()!['value'], equals(index + 1));
});
test('returns the correct metadata when modifying', () async {
CollectionReference<Map<String, dynamic>> collection =
await initializeTest('add-modify-document');
DocumentReference<Map<String, dynamic>> doc1 = collection.doc('doc1');
DocumentReference<Map<String, dynamic>> doc2 = collection.doc('doc2');
DocumentReference<Map<String, dynamic>> doc3 = collection.doc('doc3');

await doc1.set({'value': 1});
await doc2.set({'value': 2});
await doc3.set({'value': 3});

final snapshots = <QuerySnapshot<Map<String, dynamic>>>[];
final receivedAll = Completer<void>();

StreamSubscription subscription = collection
.orderBy('value')
.snapshots()
.listen((snapshot) {
snapshots.add(snapshot);
if (snapshots.length >= 2 && !receivedAll.isCompleted) {
receivedAll.complete();
}
});

// Wait for the initial snapshot before modifying
await Future.delayed(const Duration(milliseconds: 500));
await doc1.update({'value': 4});

await receivedAll.future.timeout(const Duration(seconds: 30));
await subscription.cancel();

// Verify first snapshot (all 3 docs added)
expect(snapshots[0].docs.length, equals(3));
expect(snapshots[0].docChanges.length, equals(3));
snapshots[0].docChanges.asMap().forEach((
int index,
DocumentChange<Map<String, dynamic>> change,
) {
expect(change.oldIndex, equals(-1));
expect(change.newIndex, equals(index));
expect(change.type, equals(DocumentChangeType.added));
expect(change.doc.data()!['value'], equals(index + 1));
});

// Verify second snapshot (doc1 modified, moved to end)
expect(snapshots[1].docs.length, equals(3));
expect(snapshots[1].docChanges.length, equals(1));
DocumentChange<Map<String, dynamic>> change =
snapshots[1].docChanges[0];
expect(change.oldIndex, equals(0));
expect(change.newIndex, equals(2));
expect(change.type, equals(DocumentChangeType.modified));
expect(change.doc.id, equals('doc1'));
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
// Verify second snapshot (doc1 modified, moved to end)
expect(snapshots[1].docs.length, equals(3));
expect(snapshots[1].docChanges.length, equals(1));
DocumentChange<Map<String, dynamic>> change = snapshots[1].docChanges[0];
expect(change.oldIndex, equals(0));
expect(change.newIndex, equals(2));
expect(change.type, equals(DocumentChangeType.modified));
expect(change.doc.id, equals('doc1'));
}, skip: defaultTargetPlatform == TargetPlatform.windows);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,30 @@ void runInstanceTests() {
await instance.terminate();
}, skip: kIsWeb);

test(
'setIndexConfigurationFromJSON()',
() async {
final json = jsonEncode({
'indexes': [
{
'collectionGroup': 'posts',
'queryScope': 'COLLECTION',
'fields': [
{'fieldPath': 'author', 'arrayConfig': 'CONTAINS'},
{'fieldPath': 'timestamp', 'order': 'DESCENDING'},
],
},
],
'fieldOverrides': [
{
'collectionGroup': 'posts',
'fieldPath': 'myBigMapField',
'indexes': [],
},
],
});

// ignore: experimental_member_use
await firestore.setIndexConfigurationFromJSON(json);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
test('setIndexConfigurationFromJSON()', () async {
final json = jsonEncode({
'indexes': [
{
'collectionGroup': 'posts',
'queryScope': 'COLLECTION',
'fields': [
{'fieldPath': 'author', 'arrayConfig': 'CONTAINS'},
{'fieldPath': 'timestamp', 'order': 'DESCENDING'},
],
},
],
'fieldOverrides': [
{
'collectionGroup': 'posts',
'fieldPath': 'myBigMapField',
'indexes': [],
},
],
});

// ignore: experimental_member_use
await firestore.setIndexConfigurationFromJSON(json);
}, skip: defaultTargetPlatform == TargetPlatform.windows);

test('setLoggingEnabled should resolve without issue', () async {
await FirebaseFirestore.setLoggingEnabled(true);
Expand Down
Loading
Loading