Visitar URL original
fix(firestore,windows): fix CI issue (#18218) · firebase/flutterfire@b9c8a9e · GitHub
Skip to content

Commit b9c8a9e

Browse files
authored
fix(firestore,windows): fix CI issue (#18218)
* fix(firestore,windows): fix CI issue * fix(firestore,windows): emit Pigeon objects on snapshot event sinks The Pigeon 26 upgrade (#18205) changed the Dart-side EventChannel handlers in `method_channel_document_reference.dart` and `method_channel_query.dart` to expect the generated Pigeon class directly (`snapshot as InternalDocumentSnapshot` / `InternalQuerySnapshot`) and updated the Android stream handlers to emit `PigeonParser.toPigeonQuerySnapshot(...)` / `toPigeonDocumentSnapshot(...)` directly, but the Windows stream handlers in `cloud_firestore_plugin.cpp` were missed and still emitted `Parse...(...).ToEncodableList()`. As a result, on Windows every `DocumentReference.snapshots()`, `Query.snapshots()` and (transitively) `FirebaseFirestore.snapshotsInSync()` call threw `type 'List<Object?>' is not a subtype of type 'InternalDocumentSnapshot' in type cast` on the first event. Wrap the Pigeon class in `CustomEncodableValue(...)` so the Pigeon-aware codec on the EventChannel serializes it end-to-end, the same way Android does. * test(firestore,windows): skip cache snapshot listener tests on Windows * skip vectorevalues * try that * more fixes * fixes * fix * fix * fixes * format
1 parent ea5bd20 commit b9c8a9e

8 files changed

Lines changed: 483 additions & 251 deletions

File tree

‎.github/workflows/windows.yaml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
- name: Start Firebase Emulator and run tests
6464
run: cd ./.github/workflows/scripts && firebase emulators:exec --project flutterfire-e2e-tests "cd ../../../tests && flutter test .\integration_test\e2e_test.dart -d windows --verbose"
6565

66-
# We cannot run the tests but we can still try to build the app because of https://github.com/flutter/flutter/issues/79213
6766
windows-firestore:
6867
runs-on: windows-latest
6968
if: ${{ !inputs.nightly_test_mode }}
@@ -94,4 +93,13 @@ jobs:
9493
run: |
9594
npm install -g firebase-tools
9695
- name: Start Firebase Emulator and run tests
97-
run: cd ./.github/workflows/scripts && firebase emulators:exec --project flutterfire-e2e-tests "cd ../../../packages/cloud_firestore/cloud_firestore/example && flutter build windows"
96+
run: |
97+
cd ./.github/workflows/scripts
98+
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
99+
$exitCode = $LASTEXITCODE
100+
$output = Get-Content output.log -Raw
101+
if ($output -match '\[E\]' -or $output -match 'Some tests failed') {
102+
Write-Error "All tests did not pass. Please check the logs for more information."
103+
exit 1
104+
}
105+
exit $exitCode

‎packages/cloud_firestore/cloud_firestore/example/integration_test/document_reference_e2e.dart‎

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -88,51 +88,62 @@ void runDocumentReferenceTests() {
8888
});
8989
});
9090

91-
test('listens to a single response from cache', () async {
92-
DocumentReference<Map<String, dynamic>> document =
93-
await initializeTest('document-snapshot');
94-
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
95-
document.snapshots(source: ListenSource.cache);
96-
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
97-
subscription;
98-
99-
subscription = stream.listen(
100-
expectAsync1(
101-
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
102-
expect(snapshot.exists, isFalse);
103-
},
104-
reason: 'Stream should only have been called once.',
105-
),
106-
);
107-
108-
addTearDown(() async {
109-
await subscription?.cancel();
110-
});
111-
});
91+
test(
92+
'listens to a single response from cache',
93+
() async {
94+
DocumentReference<Map<String, dynamic>> document =
95+
await initializeTest('document-snapshot');
96+
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
97+
document.snapshots(source: ListenSource.cache);
98+
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
99+
subscription;
100+
101+
subscription = stream.listen(
102+
expectAsync1(
103+
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
104+
expect(snapshot.exists, isFalse);
105+
},
106+
reason: 'Stream should only have been called once.',
107+
),
108+
);
112109

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

122-
subscription = stream.listen(
123-
expectAsync1(
124-
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
125-
expect(snapshot.exists, isTrue);
126-
expect(snapshot.data(), equals({'foo': 'bar'}));
127-
},
128-
reason: 'Stream should only have been called once.',
129-
),
130-
);
119+
test(
120+
'listens to a document from cache',
121+
() async {
122+
DocumentReference<Map<String, dynamic>> document =
123+
await initializeTest('document-snapshot-cache');
124+
await document.set({'foo': 'bar'});
125+
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
126+
document.snapshots(source: ListenSource.cache);
127+
StreamSubscription<DocumentSnapshot<Map<String, dynamic>>>?
128+
subscription;
129+
130+
subscription = stream.listen(
131+
expectAsync1(
132+
(DocumentSnapshot<Map<String, dynamic>> snapshot) {
133+
expect(snapshot.exists, isTrue);
134+
expect(snapshot.data(), equals({'foo': 'bar'}));
135+
},
136+
reason: 'Stream should only have been called once.',
137+
),
138+
);
131139

132-
addTearDown(() async {
133-
await subscription?.cancel();
134-
});
135-
});
140+
addTearDown(() async {
141+
await subscription?.cancel();
142+
});
143+
},
144+
// Listening from cache is not supported on Windows.
145+
skip: defaultTargetPlatform == TargetPlatform.windows,
146+
);
136147

137148
test('listens to multiple documents', () async {
138149
DocumentReference<Map<String, dynamic>> doc1 =
@@ -408,7 +419,8 @@ void runDocumentReferenceTests() {
408419
'null': null,
409420
'timestamp': Timestamp.now(),
410421
'geopoint': const GeoPoint(1, 2),
411-
'vectorValue': const VectorValue([1, 2, 3]),
422+
if (defaultTargetPlatform != TargetPlatform.windows)
423+
'vectorValue': const VectorValue([1, 2, 3]),
412424
'reference': firestore.doc('foo/bar'),
413425
'nan': double.nan,
414426
'infinity': double.infinity,
@@ -445,11 +457,13 @@ void runDocumentReferenceTests() {
445457
expect(data['geopoint'], isA<GeoPoint>());
446458
expect((data['geopoint'] as GeoPoint).latitude, equals(1));
447459
expect((data['geopoint'] as GeoPoint).longitude, equals(2));
448-
expect(data['vectorValue'], isA<VectorValue>());
449-
expect(
450-
(data['vectorValue'] as VectorValue).toArray(),
451-
equals([1, 2, 3]),
452-
);
460+
if (defaultTargetPlatform != TargetPlatform.windows) {
461+
expect(data['vectorValue'], isA<VectorValue>());
462+
expect(
463+
(data['vectorValue'] as VectorValue).toArray(),
464+
equals([1, 2, 3]),
465+
);
466+
}
453467
expect(data['reference'], isA<DocumentReference>());
454468
expect((data['reference'] as DocumentReference).id, equals('bar'));
455469
expect(data['nan'].isNaN, equals(true));

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

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ void runQueryTests() {
295295
await subscription?.cancel();
296296
});
297297
},
298-
// Failing on CI but works locally
299-
skip: kIsWeb,
298+
// Failing on CI but works locally. Listening from cache is not
299+
// supported on Windows.
300+
skip: kIsWeb || defaultTargetPlatform == TargetPlatform.windows,
300301
);
301302

302303
test('listens to multiple queries', () async {
@@ -1052,14 +1053,17 @@ void runQueryTests() {
10521053
isA<FirebaseException>().having(
10531054
(e) => e.message,
10541055
'message',
1055-
contains(
1056-
'Client specified an invalid argument',
1056+
anyOf(
1057+
contains('Client specified an invalid argument'),
1058+
contains('order by clause cannot contain more fields '
1059+
'after the key'),
10571060
),
10581061
),
10591062
),
10601063
);
10611064
},
1062-
// firebase-js-sdk does not require an orderBy() field to be set for this to work
1065+
// firebase-js-sdk does not require an orderBy() field to be set for
1066+
// this to work
10631067
skip: kIsWeb,
10641068
);
10651069

@@ -1106,8 +1110,10 @@ void runQueryTests() {
11061110
isA<FirebaseException>().having(
11071111
(e) => e.message,
11081112
'message',
1109-
contains(
1110-
'Client specified an invalid argument',
1113+
anyOf(
1114+
contains('Client specified an invalid argument'),
1115+
contains('order by clause cannot contain more fields '
1116+
'after the key'),
11111117
),
11121118
),
11131119
),
@@ -3798,6 +3804,7 @@ void runQueryTests() {
37983804
3,
37993805
);
38003806
},
3807+
skip: defaultTargetPlatform == TargetPlatform.windows,
38013808
);
38023809

38033810
test(
@@ -3820,6 +3827,7 @@ void runQueryTests() {
38203827
1,
38213828
);
38223829
},
3830+
skip: defaultTargetPlatform == TargetPlatform.windows,
38233831
);
38243832

38253833
test(
@@ -3841,6 +3849,7 @@ void runQueryTests() {
38413849
1.5,
38423850
);
38433851
},
3852+
skip: defaultTargetPlatform == TargetPlatform.windows,
38443853
);
38453854

38463855
test(
@@ -3863,6 +3872,7 @@ void runQueryTests() {
38633872
1,
38643873
);
38653874
},
3875+
skip: defaultTargetPlatform == TargetPlatform.windows,
38663876
);
38673877

38683878
test(
@@ -3894,37 +3904,42 @@ void runQueryTests() {
38943904
1.5,
38953905
);
38963906
},
3907+
skip: defaultTargetPlatform == TargetPlatform.windows,
38973908
);
38983909

3899-
test('chaining multiples aggregate queries', () async {
3900-
final collection = await initializeTest('chaining');
3910+
test(
3911+
'chaining multiples aggregate queries',
3912+
() async {
3913+
final collection = await initializeTest('chaining');
39013914

3902-
await Future.wait([
3903-
collection.add({'foo': 1}),
3904-
collection.add({'foo': 2}),
3905-
]);
3915+
await Future.wait([
3916+
collection.add({'foo': 1}),
3917+
collection.add({'foo': 2}),
3918+
]);
39063919

3907-
AggregateQuery query = collection
3908-
.where('foo', isEqualTo: 1)
3909-
.aggregate(count(), sum('foo'), average('foo'));
3920+
AggregateQuery query = collection
3921+
.where('foo', isEqualTo: 1)
3922+
.aggregate(count(), sum('foo'), average('foo'));
39103923

3911-
AggregateQuerySnapshot snapshot = await query.get();
3924+
AggregateQuerySnapshot snapshot = await query.get();
39123925

3913-
expect(
3914-
snapshot.count,
3915-
1,
3916-
);
3926+
expect(
3927+
snapshot.count,
3928+
1,
3929+
);
39173930

3918-
expect(
3919-
snapshot.getSum('foo'),
3920-
1,
3921-
);
3931+
expect(
3932+
snapshot.getSum('foo'),
3933+
1,
3934+
);
39223935

3923-
expect(
3924-
snapshot.getAverage('foo'),
3925-
1,
3926-
);
3927-
});
3936+
expect(
3937+
snapshot.getAverage('foo'),
3938+
1,
3939+
);
3940+
},
3941+
skip: defaultTargetPlatform == TargetPlatform.windows,
3942+
);
39283943

39293944
test(
39303945
'count() with collectionGroup',
@@ -3966,16 +3981,20 @@ void runQueryTests() {
39663981
},
39673982
);
39683983

3969-
test('count(), average() & sum() on empty collection', () async {
3970-
final collection = await initializeTest('empty-collection');
3984+
test(
3985+
'count(), average() & sum() on empty collection',
3986+
() async {
3987+
final collection = await initializeTest('empty-collection');
39713988

3972-
final snapshot = await collection
3973-
.aggregate(count(), sum('foo'), average('foo'))
3974-
.get();
3975-
expect(snapshot.count, 0);
3976-
expect(snapshot.getSum('foo'), 0);
3977-
expect(snapshot.getAverage('foo'), null);
3978-
});
3989+
final snapshot = await collection
3990+
.aggregate(count(), sum('foo'), average('foo'))
3991+
.get();
3992+
expect(snapshot.count, 0);
3993+
expect(snapshot.getSum('foo'), 0);
3994+
expect(snapshot.getAverage('foo'), null);
3995+
},
3996+
skip: defaultTargetPlatform == TargetPlatform.windows,
3997+
);
39793998
});
39803999

39814000
group('startAfterDocument', () {

0 commit comments

Comments
 (0)