Skip to content

Commit c0fa83f

Browse files
test(firestore): switch testWidgets() to test() for e2e tests (#16709)
1 parent 3de12fc commit c0fa83f

16 files changed

+458
-483
lines changed

.github/workflows/ios.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'docs/**'
1111
- 'website/**'
1212
- '**/example/**'
13+
- '!**/example/integration_test/**'
1314
- '**/flutterfire_ui/**'
1415
- '**.md'
1516
push:
@@ -19,6 +20,7 @@ on:
1920
- 'docs/**'
2021
- 'website/**'
2122
- '**/example/**'
23+
- '!**/example/integration_test/**'
2224
- '**/flutterfire_ui/**'
2325
- '**.md'
2426

@@ -101,16 +103,16 @@ jobs:
101103
ccache -s
102104
- name: Start Firebase Emulator
103105
run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
106+
- uses: futureware-tech/simulator-action@48e51da14445b3eedca643bba4b78d9d8332ff31
107+
id: simulator
108+
with:
109+
# List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators
110+
model: "iPhone 15"
104111
- name: 'E2E Tests'
105112
working-directory: ${{ matrix.working_directory }}
113+
env:
114+
SIMULATOR: ${{ steps.simulator.outputs.udid }}
106115
run: |
107-
# Boot simulator and wait for System app to be ready.
108-
# List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators
109-
SIMULATOR="iPhone 15"
110-
xcrun simctl bootstatus "$SIMULATOR" -b
111-
xcrun simctl logverbose "$SIMULATOR" enable
112-
# Sleep to allow simulator to settle.
113-
sleep 15
114116
# Uncomment following line to have simulator logs printed out for debugging purposes.
115117
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
116118
flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --dart-define=CI=true

packages/cloud_firestore/cloud_firestore/example/integration_test/collection_reference_e2e.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void runCollectionReferenceTests() {
3030
return collection;
3131
}
3232

33-
testWidgets('add() adds a document', (_) async {
33+
test('add() adds a document', () async {
3434
CollectionReference<Map<String, dynamic>> collection =
3535
await initializeTest('collection-reference-add');
3636
var rand = Random();
@@ -42,9 +42,9 @@ void runCollectionReferenceTests() {
4242
expect(randNum, equals(snapshot.data()!['value']));
4343
});
4444

45-
testWidgets(
45+
test(
4646
'snapshots() can be reused',
47-
(_) async {
47+
() async {
4848
final foo = await initializeTest('foo');
4949

5050
final snapshot = foo.snapshots();
@@ -86,9 +86,9 @@ void runCollectionReferenceTests() {
8686
group(
8787
'withConverter',
8888
() {
89-
testWidgets(
89+
test(
9090
'add/snapshot',
91-
(_) async {
91+
() async {
9292
final foo = await initializeTest('foo');
9393
final fooConverter = foo.withConverter<int>(
9494
fromFirestore: (snapshots, _) =>
@@ -179,9 +179,9 @@ void runCollectionReferenceTests() {
179179
timeout: const Timeout.factor(3),
180180
);
181181

182-
testWidgets(
182+
test(
183183
'returning null from `fromFirestore` should not throw a null check error',
184-
(_) async {
184+
() async {
185185
final foo = await initializeTest('foo');
186186
await foo.add({'value': 42});
187187
final fooConverter = foo.withConverter(

packages/cloud_firestore/cloud_firestore/example/integration_test/document_change_e2e.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ void runDocumentChangeTests() {
3131
return collection;
3232
}
3333

34-
testWidgets(
34+
test(
3535
'can add/update values to null in the document',
36-
(_) async {
36+
() async {
3737
CollectionReference<Map<String, dynamic>> collection =
3838
await initializeTest('null-test');
3939
DocumentReference<Map<String, dynamic>> doc1 = collection.doc('doc1');
@@ -84,9 +84,9 @@ void runDocumentChangeTests() {
8484
skip: defaultTargetPlatform == TargetPlatform.windows,
8585
);
8686

87-
testWidgets(
87+
test(
8888
'returns the correct metadata when adding and removing',
89-
(_) async {
89+
() async {
9090
CollectionReference<Map<String, dynamic>> collection =
9191
await initializeTest('add-remove-document');
9292
DocumentReference<Map<String, dynamic>> doc1 = collection.doc('doc1');
@@ -141,9 +141,9 @@ void runDocumentChangeTests() {
141141
skip: defaultTargetPlatform == TargetPlatform.windows,
142142
);
143143

144-
testWidgets(
144+
test(
145145
'returns the correct metadata when modifying',
146-
(_) async {
146+
() async {
147147
CollectionReference<Map<String, dynamic>> collection =
148148
await initializeTest('add-modify-document');
149149
DocumentReference<Map<String, dynamic>> doc1 = collection.doc('doc1');

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ void runDocumentReferenceTests() {
2727
group(
2828
'DocumentReference.snapshots()',
2929
() {
30-
testWidgets('returns a [Stream]', (_) async {
30+
test('returns a [Stream]', () async {
3131
DocumentReference<Map<String, dynamic>> document =
3232
await initializeTest('document-snapshot');
3333
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
3434
document.snapshots();
3535
expect(stream, isA<Stream<DocumentSnapshot<Map<String, dynamic>>>>());
3636
});
3737

38-
testWidgets('can be reused', (_) async {
38+
test('can be reused', () async {
3939
final foo = await initializeTest('foo');
4040

4141
final snapshot = foo.snapshots();
@@ -66,7 +66,7 @@ void runDocumentReferenceTests() {
6666
);
6767
});
6868

69-
testWidgets('listens to a single response', (_) async {
69+
test('listens to a single response', () async {
7070
DocumentReference<Map<String, dynamic>> document =
7171
await initializeTest('document-snapshot');
7272
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
@@ -88,7 +88,7 @@ void runDocumentReferenceTests() {
8888
});
8989
});
9090

91-
testWidgets('listens to a single response from cache', (_) async {
91+
test('listens to a single response from cache', () async {
9292
DocumentReference<Map<String, dynamic>> document =
9393
await initializeTest('document-snapshot');
9494
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
@@ -110,7 +110,7 @@ void runDocumentReferenceTests() {
110110
});
111111
});
112112

113-
testWidgets('listens to a document from cache', (_) async {
113+
test('listens to a document from cache', () async {
114114
DocumentReference<Map<String, dynamic>> document =
115115
await initializeTest('document-snapshot-cache');
116116
await document.set({'foo': 'bar'});
@@ -134,7 +134,7 @@ void runDocumentReferenceTests() {
134134
});
135135
});
136136

137-
testWidgets('listens to multiple documents', (_) async {
137+
test('listens to multiple documents', () async {
138138
DocumentReference<Map<String, dynamic>> doc1 =
139139
await initializeTest('document-snapshot-1');
140140
DocumentReference<Map<String, dynamic>> doc2 =
@@ -150,7 +150,7 @@ void runDocumentReferenceTests() {
150150
await expectLater(value2, completion('value2'));
151151
});
152152

153-
testWidgets('listens to a multiple changes response', (_) async {
153+
test('listens to a multiple changes response', () async {
154154
DocumentReference<Map<String, dynamic>> document =
155155
await initializeTest('document-snapshot-multiple');
156156
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
@@ -197,7 +197,7 @@ void runDocumentReferenceTests() {
197197
);
198198
});
199199

200-
testWidgets('listeners throws a [FirebaseException]', (_) async {
200+
test('listeners throws a [FirebaseException]', () async {
201201
DocumentReference<Map<String, dynamic>> document =
202202
firestore.doc('not-allowed/document');
203203
Stream<DocumentSnapshot<Map<String, dynamic>>> stream =
@@ -220,7 +220,7 @@ void runDocumentReferenceTests() {
220220
);
221221

222222
group('DocumentReference.delete()', () {
223-
testWidgets('delete() deletes a document', (_) async {
223+
test('delete() deletes a document', () async {
224224
DocumentReference<Map<String, dynamic>> document =
225225
await initializeTest('document-delete');
226226
await document.set({
@@ -233,9 +233,9 @@ void runDocumentReferenceTests() {
233233
expect(snapshot2.exists, isFalse);
234234
});
235235

236-
testWidgets(
236+
test(
237237
'throws a [FirebaseException] on error',
238-
(_) async {
238+
() async {
239239
DocumentReference<Map<String, dynamic>> document =
240240
firestore.doc('not-allowed/document');
241241

@@ -257,7 +257,7 @@ void runDocumentReferenceTests() {
257257
});
258258

259259
group('DocumentReference.get()', () {
260-
testWidgets('gets a document from server', (_) async {
260+
test('gets a document from server', () async {
261261
DocumentReference<Map<String, dynamic>> document =
262262
await initializeTest('document-get-server');
263263
await document.set({'foo': 'bar'});
@@ -267,9 +267,9 @@ void runDocumentReferenceTests() {
267267
expect(snapshot.metadata.isFromCache, isFalse);
268268
});
269269

270-
testWidgets(
270+
test(
271271
'gets a document from cache',
272-
(_) async {
272+
() async {
273273
DocumentReference<Map<String, dynamic>> document =
274274
await initializeTest('document-get-cache');
275275
await document.set({'foo': 'bar'});
@@ -281,9 +281,9 @@ void runDocumentReferenceTests() {
281281
skip: kIsWeb,
282282
);
283283

284-
testWidgets(
284+
test(
285285
'throws a [FirebaseException] on error',
286-
(_) async {
286+
() async {
287287
DocumentReference<Map<String, dynamic>> document =
288288
firestore.doc('not-allowed/document');
289289

@@ -303,7 +303,7 @@ void runDocumentReferenceTests() {
303303
});
304304

305305
group('DocumentReference.set()', () {
306-
testWidgets('sets data', (_) async {
306+
test('sets data', () async {
307307
DocumentReference<Map<String, dynamic>> document =
308308
await initializeTest('document-set');
309309
await document.set({'foo': 'bar'});
@@ -314,7 +314,7 @@ void runDocumentReferenceTests() {
314314
expect(snapshot2.data(), equals({'bar': 'baz'}));
315315
});
316316

317-
testWidgets('set() merges data', (_) async {
317+
test('set() merges data', () async {
318318
DocumentReference<Map<String, dynamic>> document =
319319
await initializeTest('document-set-merge');
320320
await document.set({'foo': 'bar'});
@@ -326,9 +326,9 @@ void runDocumentReferenceTests() {
326326
expect(snapshot2.data(), equals({'foo': 'ben', 'bar': 'baz'}));
327327
});
328328

329-
testWidgets(
329+
test(
330330
'set() merges fields',
331-
(_) async {
331+
() async {
332332
DocumentReference<Map<String, dynamic>> document =
333333
await initializeTest('document-set-merge-fields');
334334
Map<String, dynamic> initialData = {
@@ -363,9 +363,9 @@ void runDocumentReferenceTests() {
363363
},
364364
);
365365

366-
testWidgets(
366+
test(
367367
'throws a [FirebaseException] on error',
368-
(_) async {
368+
() async {
369369
DocumentReference<Map<String, dynamic>> document =
370370
firestore.doc('not-allowed/document');
371371

@@ -383,7 +383,7 @@ void runDocumentReferenceTests() {
383383
},
384384
);
385385

386-
testWidgets('set and return all possible datatypes', (_) async {
386+
test('set and return all possible datatypes', () async {
387387
DocumentReference<Map<String, dynamic>> document =
388388
await initializeTest('document-types');
389389

@@ -453,7 +453,7 @@ void runDocumentReferenceTests() {
453453
});
454454

455455
group('DocumentReference.update()', () {
456-
testWidgets('updates data', (_) async {
456+
test('updates data', () async {
457457
DocumentReference<Map<String, dynamic>> document =
458458
await initializeTest('document-update');
459459
await document.set({'foo': 'bar'});
@@ -464,7 +464,7 @@ void runDocumentReferenceTests() {
464464
expect(snapshot2.data(), equals({'foo': 'bar', 'bar': 'baz'}));
465465
});
466466

467-
testWidgets('updates nested data using dots', (_) async {
467+
test('updates nested data using dots', () async {
468468
DocumentReference<Map<String, dynamic>> document =
469469
await initializeTest('document-update-field-path');
470470
await document.set({
@@ -488,7 +488,7 @@ void runDocumentReferenceTests() {
488488
);
489489
});
490490

491-
testWidgets('updates nested data using FieldPath', (_) async {
491+
test('updates nested data using FieldPath', () async {
492492
DocumentReference<Map<String, dynamic>> document =
493493
await initializeTest('document-update-field-path');
494494
await document.set({
@@ -514,8 +514,7 @@ void runDocumentReferenceTests() {
514514
);
515515
});
516516

517-
testWidgets('updates nested data containing a dot using FieldPath',
518-
(_) async {
517+
test('updates nested data containing a dot using FieldPath', () async {
519518
DocumentReference<Map<String, dynamic>> document =
520519
await initializeTest('document-update-field-path');
521520
await document.set({'foo.bar': 'baz'});
@@ -535,9 +534,9 @@ void runDocumentReferenceTests() {
535534
);
536535
});
537536

538-
testWidgets(
537+
test(
539538
'throws if document does not exist',
540-
(_) async {
539+
() async {
541540
DocumentReference<Map<String, dynamic>> document =
542541
await initializeTest('document-update-not-exists');
543542
try {
@@ -555,9 +554,9 @@ void runDocumentReferenceTests() {
555554
});
556555

557556
group('withConverter', () {
558-
testWidgets(
557+
test(
559558
'set/snapshot/get',
560-
(_) async {
559+
() async {
561560
final foo = await initializeTest('foo');
562561
final fooConverter = foo.withConverter<int>(
563562
fromFirestore: (snapshots, _) => snapshots.data()!['value']! as int,

0 commit comments

Comments
 (0)