Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
- name: Start Firebase Emulator and run tests
run: cd ./.github/workflows/scripts && firebase emulators:exec --project flutterfire-e2e-tests "cd ../../../tests && flutter test .\integration_test\e2e_test.dart -d windows --verbose"

# We cannot run the tests but we can still try to build the app because of https://github.com/flutter/flutter/issues/79213
windows-firestore:
runs-on: windows-latest
if: ${{ !inputs.nightly_test_mode }}
Expand Down Expand Up @@ -94,4 +93,13 @@ jobs:
run: |
npm install -g firebase-tools
- name: Start Firebase Emulator and run tests
run: cd ./.github/workflows/scripts && firebase emulators:exec --project flutterfire-e2e-tests "cd ../../../packages/cloud_firestore/cloud_firestore/example && flutter build windows"
run: |
cd ./.github/workflows/scripts
firebase emulators:exec --project flutterfire-e2e-tests "cd ../../../packages/cloud_firestore/cloud_firestore/example && flutter drive --target=.\integration_test\e2e_test.dart --driver=.\test_driver\integration_test.dart -d windows --verbose" 2>&1 | Tee-Object -FilePath output.log
$exitCode = $LASTEXITCODE
$output = Get-Content output.log -Raw
if ($output -match '\[E\]' -or $output -match 'Some tests failed') {
Write-Error "All tests did not pass. Please check the logs for more information."
exit 1
}
exit $exitCode
Original file line number Diff line number Diff line change
Expand Up @@ -88,51 +88,62 @@ void runDocumentReferenceTests() {
});
});

test('listens to a single response from cache', () async {
DocumentReference<Map<String, dynamic>> document =
await initializeTest('document-snapshot');
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
document.snapshots(source: ListenSource.cache);
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
subscription;

subscription = stream.listen(
expectAsync1(
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
expect(snapshot.exists, isFalse);
},
reason: 'Stream should only have been called once.',
),
);

addTearDown(() async {
await subscription?.cancel();
});
});
test(
'listens to a single response from cache',
() async {
DocumentReference<Map<String, dynamic>> document =
await initializeTest('document-snapshot');
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
document.snapshots(source: ListenSource.cache);
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
subscription;

subscription = stream.listen(
expectAsync1(
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
expect(snapshot.exists, isFalse);
},
reason: 'Stream should only have been called once.',
),
);

test('listens to a document from cache', () async {
DocumentReference<Map<String, dynamic>> document =
await initializeTest('document-snapshot-cache');
await document.set({'foo': 'bar'});
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
document.snapshots(source: ListenSource.cache);
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
subscription;
addTearDown(() async {
await subscription?.cancel();
});
},
// Listening from cache is not supported on Windows (see
// DocumentReference.snapshots in cloud_firestore).
skip: defaultTargetPlatform == TargetPlatform.windows,
);

subscription = stream.listen(
expectAsync1(
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
expect(snapshot.exists, isTrue);
expect(snapshot.data(), equals({'foo': 'bar'}));
},
reason: 'Stream should only have been called once.',
),
);
test(
'listens to a document from cache',
() async {
DocumentReference<Map<String, dynamic>> document =
await initializeTest('document-snapshot-cache');
await document.set({'foo': 'bar'});
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
document.snapshots(source: ListenSource.cache);
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
subscription;

subscription = stream.listen(
expectAsync1(
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
expect(snapshot.exists, isTrue);
expect(snapshot.data(), equals({'foo': 'bar'}));
},
reason: 'Stream should only have been called once.',
),
);

addTearDown(() async {
await subscription?.cancel();
});
});
addTearDown(() async {
await subscription?.cancel();
});
},
// Listening from cache is not supported on Windows.
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test('listens to multiple documents', () async {
DocumentReference<Map<String, dynamic>> doc1 =
Expand Down Expand Up @@ -408,7 +419,8 @@ void runDocumentReferenceTests() {
'null': null,
'timestamp': Timestamp.now(),
'geopoint': const GeoPoint(1, 2),
'vectorValue': const VectorValue([1, 2, 3]),
if (defaultTargetPlatform != TargetPlatform.windows)
'vectorValue': const VectorValue([1, 2, 3]),
'reference': firestore.doc('foo/bar'),
'nan': double.nan,
'infinity': double.infinity,
Expand Down Expand Up @@ -445,11 +457,13 @@ void runDocumentReferenceTests() {
expect(data['geopoint'], isA<GeoPoint>());
expect((data['geopoint'] as GeoPoint).latitude, equals(1));
expect((data['geopoint'] as GeoPoint).longitude, equals(2));
expect(data['vectorValue'], isA<VectorValue>());
expect(
(data['vectorValue'] as VectorValue).toArray(),
equals([1, 2, 3]),
);
if (defaultTargetPlatform != TargetPlatform.windows) {
expect(data['vectorValue'], isA<VectorValue>());
expect(
(data['vectorValue'] as VectorValue).toArray(),
equals([1, 2, 3]),
);
}
expect(data['reference'], isA<DocumentReference>());
expect((data['reference'] as DocumentReference).id, equals('bar'));
expect(data['nan'].isNaN, equals(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,9 @@ void runQueryTests() {
await subscription?.cancel();
});
},
// Failing on CI but works locally
skip: kIsWeb,
// Failing on CI but works locally. Listening from cache is not
// supported on Windows.
skip: kIsWeb || defaultTargetPlatform == TargetPlatform.windows,
);

test('listens to multiple queries', () async {
Expand Down Expand Up @@ -1052,14 +1053,17 @@ void runQueryTests() {
isA<FirebaseException>().having(
(e) => e.message,
'message',
contains(
'Client specified an invalid argument',
anyOf(
contains('Client specified an invalid argument'),
contains('order by clause cannot contain more fields '
'after the key'),
),
),
),
);
},
// firebase-js-sdk does not require an orderBy() field to be set for this to work
// firebase-js-sdk does not require an orderBy() field to be set for
// this to work
skip: kIsWeb,
);

Expand Down Expand Up @@ -1106,8 +1110,10 @@ void runQueryTests() {
isA<FirebaseException>().having(
(e) => e.message,
'message',
contains(
'Client specified an invalid argument',
anyOf(
contains('Client specified an invalid argument'),
contains('order by clause cannot contain more fields '
'after the key'),
),
),
),
Expand Down Expand Up @@ -3798,6 +3804,7 @@ void runQueryTests() {
3,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test(
Expand All @@ -3820,6 +3827,7 @@ void runQueryTests() {
1,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test(
Expand All @@ -3841,6 +3849,7 @@ void runQueryTests() {
1.5,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test(
Expand All @@ -3863,6 +3872,7 @@ void runQueryTests() {
1,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test(
Expand Down Expand Up @@ -3894,37 +3904,42 @@ void runQueryTests() {
1.5,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test('chaining multiples aggregate queries', () async {
final collection = await initializeTest('chaining');
test(
'chaining multiples aggregate queries',
() async {
final collection = await initializeTest('chaining');

await Future.wait([
collection.add({'foo': 1}),
collection.add({'foo': 2}),
]);
await Future.wait([
collection.add({'foo': 1}),
collection.add({'foo': 2}),
]);

AggregateQuery query = collection
.where('foo', isEqualTo: 1)
.aggregate(count(), sum('foo'), average('foo'));
AggregateQuery query = collection
.where('foo', isEqualTo: 1)
.aggregate(count(), sum('foo'), average('foo'));

AggregateQuerySnapshot snapshot = await query.get();
AggregateQuerySnapshot snapshot = await query.get();

expect(
snapshot.count,
1,
);
expect(
snapshot.count,
1,
);

expect(
snapshot.getSum('foo'),
1,
);
expect(
snapshot.getSum('foo'),
1,
);

expect(
snapshot.getAverage('foo'),
1,
);
});
expect(
snapshot.getAverage('foo'),
1,
);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);

test(
'count() with collectionGroup',
Expand Down Expand Up @@ -3966,16 +3981,20 @@ void runQueryTests() {
},
);

test('count(), average() & sum() on empty collection', () async {
final collection = await initializeTest('empty-collection');
test(
'count(), average() & sum() on empty collection',
() async {
final collection = await initializeTest('empty-collection');

final snapshot = await collection
.aggregate(count(), sum('foo'), average('foo'))
.get();
expect(snapshot.count, 0);
expect(snapshot.getSum('foo'), 0);
expect(snapshot.getAverage('foo'), null);
});
final snapshot = await collection
.aggregate(count(), sum('foo'), average('foo'))
.get();
expect(snapshot.count, 0);
expect(snapshot.getSum('foo'), 0);
expect(snapshot.getAverage('foo'), null);
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
});

group('startAfterDocument', () {
Expand Down
Loading
Loading