From 2a7982a4ef89ae72f1a0da0ac77b8babb5158015 Mon Sep 17 00:00:00 2001 From: Cynthia J Date: Mon, 18 Nov 2024 05:21:09 -0800 Subject: [PATCH 1/7] chore(vertexai): update example code (#13546) Co-authored-by: Nate Bosch --- .../firebase_vertexai/example/lib/main.dart | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/packages/firebase_vertexai/firebase_vertexai/example/lib/main.dart b/packages/firebase_vertexai/firebase_vertexai/example/lib/main.dart index 99c551039d00..669252a77d82 100644 --- a/packages/firebase_vertexai/firebase_vertexai/example/lib/main.dart +++ b/packages/firebase_vertexai/firebase_vertexai/example/lib/main.dart @@ -75,6 +75,13 @@ class ChatWidget extends StatefulWidget { State createState() => _ChatWidgetState(); } +final class Location { + final String city; + final String state; + + Location(this.city, this.state); +} + class _ChatWidgetState extends State { late final GenerativeModel _model; late final GenerativeModel _functionCallModel; @@ -109,16 +116,13 @@ class _ChatWidgetState extends State { // This is a hypothetical API to return a fake weather data collection for // certain location Future> fetchWeather( - double latitude, - double longitude, + Location location, String date, ) async { // TODO(developer): Call a real weather API. // Mock response from the API. In developer live code this would call the // external API and return what that API returns. final apiResponse = { - 'location': '$latitude, $longitude', - 'date': date, 'temperature': 38, 'chancePrecipitation': '56%', 'cloudConditions': 'partly-cloudy', @@ -132,20 +136,14 @@ class _ChatWidgetState extends State { 'Get the weather conditions for a specific city on a specific date.', parameters: { 'location': Schema.object( - description: 'The longitude and latitude of the city for which to get ' - 'the weather. Must always be a nested object of ' - '`longitude` and `latitude`. The values must be floats.', + description: 'The name of the city and its state for which to get ' + 'the weather. Only cities in the USA are supported.', properties: { - 'latitude': Schema.number( - format: 'float', - description: 'A numeric value indicating the latitude of the ' - 'desired location between -90 and 90', + 'city': Schema.string( + description: 'The city of the location.', ), - 'longitude': Schema.number( - format: 'float', - description: - 'A numeric value indicating the longitude of the desired ' - 'location between -180 and 180', + 'state': Schema.string( + description: 'The state of the location.', ), }, ), @@ -341,17 +339,35 @@ class _ChatWidgetState extends State { _loading = true; }); try { - final content = [Content.text('Create a list of 20 $subject.')]; + final content = [ + Content.text( + "For use in a children's card game, generate 10 animal-based " + 'characters.', + ), + ]; + + final jsonSchema = Schema.object( + properties: { + 'characters': Schema.array( + items: Schema.object( + properties: { + 'name': Schema.string(), + 'age': Schema.integer(), + 'species': Schema.string(), + 'accessory': + Schema.enumString(enumValues: ['hat', 'belt', 'shoes']), + }, + ), + ), + }, + optionalProperties: ['accessory'], + ); final response = await _model.generateContent( content, generationConfig: GenerationConfig( responseMimeType: 'application/json', - responseSchema: Schema.array( - items: Schema.string( - description: 'A single word that a player will need to guess.', - ), - ), + responseSchema: jsonSchema, ), ); @@ -537,9 +553,9 @@ class _ChatWidgetState extends State { Map location = functionCall.args['location']! as Map; var date = functionCall.args['date']! as String; - var latitude = location['latitude']! as double; - var longitude = location['longitude']! as double; - final functionResult = await fetchWeather(latitude, longitude, date); + var city = location['city'] as String; + var state = location['state'] as String; + final functionResult = await fetchWeather(Location(city, state), date); // Send the response to the model so that it can use the result to // generate text for the user. response = await functionCallChat.sendMessage( From 0e992b827dfc7525b497540ebaf9d173445cdb13 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Mon, 18 Nov 2024 14:12:10 +0000 Subject: [PATCH 2/7] fix(firestore, android): synchronize access to firestore instances (#16675) --- .../FlutterFirebaseFirestorePlugin.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java b/packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java index 35e4697f7128..1684d7dfd4a5 100644 --- a/packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java +++ b/packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java @@ -108,11 +108,13 @@ protected static void setCachedFirebaseFirestoreInstanceForKey( protected static FirebaseFirestore getFirestoreInstanceByNameAndDatabaseUrl( String appName, String databaseURL) { - for (Map.Entry entry : - firestoreInstanceCache.entrySet()) { - if (entry.getValue().getInstance().getApp().getName().equals(appName) - && entry.getValue().getDatabaseURL().equals(databaseURL)) { - return entry.getKey(); + synchronized (firestoreInstanceCache) { + for (Map.Entry entry : + firestoreInstanceCache.entrySet()) { + if (entry.getValue().getInstance().getApp().getName().equals(appName) + && entry.getValue().getDatabaseURL().equals(databaseURL)) { + return entry.getKey(); + } } } return null; @@ -200,12 +202,14 @@ public Task didReinitializeFirebaseCore() { () -> { try { // Context is ignored by API so we don't send it over even though annotated non-null. - for (Map.Entry entry : - firestoreInstanceCache.entrySet()) { - FirebaseFirestore firestore = entry.getKey(); - Tasks.await(firestore.terminate()); - FlutterFirebaseFirestorePlugin.destroyCachedFirebaseFirestoreInstanceForKey( - firestore); + synchronized (firestoreInstanceCache) { + for (Map.Entry entry : + firestoreInstanceCache.entrySet()) { + FirebaseFirestore firestore = entry.getKey(); + Tasks.await(firestore.terminate()); + FlutterFirebaseFirestorePlugin.destroyCachedFirebaseFirestoreInstanceForKey( + firestore); + } } removeEventListeners(); From 95a99351fc6f56516ce4a8d6ba4410a95e21afd3 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 19 Nov 2024 10:56:02 +0000 Subject: [PATCH 3/7] fix(storage, apple): clean up event channel, stream handler and task on completion (#16708) --- .../ios/Classes/FLTFirebaseStoragePlugin.h | 1 + .../ios/Classes/FLTFirebaseStoragePlugin.m | 32 +++++++++++++++---- .../FLTTaskStateChannelStreamHandler.h | 6 ++-- .../FLTTaskStateChannelStreamHandler.m | 16 ++++++++-- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.h b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.h index 6505c369ab93..dd04c63b72aa 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.h +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.h @@ -19,4 +19,5 @@ + (NSDictionary *)parseTaskSnapshot:(FIRStorageTaskSnapshot *)snapshot; + (NSDictionary *)NSDictionaryFromNSError:(NSError *)error; +- (void)cleanUpTask:(NSString *)channelName handle:(NSNumber *)handle; @end diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m index 437f21cef1a4..d4309fe0beb8 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m @@ -412,10 +412,10 @@ - (void)referencePutDataApp:(PigeonStorageFirebaseApp *)app self->_tasks[handle] = task; } - completion([self setupTaskListeners:task], nil); + completion([self setupTaskListeners:task handle:handle], nil); } -- (NSString *)setupTaskListeners:(FIRStorageObservableTask *)task { +- (NSString *)setupTaskListeners:(FIRStorageObservableTask *)task handle:(NSNumber *)handle { // Generate a random UUID to register with NSString *uuid = [[NSUUID UUID] UUIDString]; @@ -426,7 +426,10 @@ - (NSString *)setupTaskListeners:(FIRStorageObservableTask *)task { FlutterEventChannel *channel = [FlutterEventChannel eventChannelWithName:channelName binaryMessenger:_binaryMessenger]; FLTTaskStateChannelStreamHandler *handler = - [[FLTTaskStateChannelStreamHandler alloc] initWithTask:task]; + [[FLTTaskStateChannelStreamHandler alloc] initWithTask:task + storagePlugin:self + channelName:channelName + handle:handle]; [channel setStreamHandler:handler]; [_eventChannels setObject:channel forKey:channelName]; @@ -435,6 +438,23 @@ - (NSString *)setupTaskListeners:(FIRStorageObservableTask *)task { return uuid; } +- (void)cleanUpTask:(NSString *)channelName handle:(NSNumber *)handle { + NSObject *handler = [_streamHandlers objectForKey:channelName]; + if (handler) { + [_streamHandlers removeObjectForKey:channelName]; + } + + FlutterEventChannel *channel = [_eventChannels objectForKey:channelName]; + if (channel) { + [channel setStreamHandler:nil]; + [_eventChannels removeObjectForKey:channelName]; + } + + @synchronized(self->_tasks) { + [self->_tasks removeObjectForKey:handle]; + } +} + - (void)referencePutStringApp:(PigeonStorageFirebaseApp *)app reference:(PigeonStorageReference *)reference data:(NSString *)data @@ -456,7 +476,7 @@ - (void)referencePutStringApp:(PigeonStorageFirebaseApp *)app self->_tasks[handle] = task; } - completion([self setupTaskListeners:task], nil); + completion([self setupTaskListeners:task handle:handle], nil); } - (void)referencePutFileApp:(PigeonStorageFirebaseApp *)app @@ -481,7 +501,7 @@ - (void)referencePutFileApp:(PigeonStorageFirebaseApp *)app self->_tasks[handle] = task; } - completion([self setupTaskListeners:task], nil); + completion([self setupTaskListeners:task handle:handle], nil); } - (void)referenceDownloadFileApp:(PigeonStorageFirebaseApp *)app @@ -501,7 +521,7 @@ - (void)referenceDownloadFileApp:(PigeonStorageFirebaseApp *)app self->_tasks[handle] = task; } - completion([self setupTaskListeners:task], nil); + completion([self setupTaskListeners:task handle:handle], nil); } - (void)referenceUpdateMetadataApp:(PigeonStorageFirebaseApp *)app diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.h b/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.h index 51a3afae5128..c252761eecfb 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.h +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.h @@ -17,8 +17,10 @@ NS_ASSUME_NONNULL_BEGIN @interface FLTTaskStateChannelStreamHandler : NSObject - -- (instancetype)initWithTask:(FIRStorageObservableTask *)task; +- (instancetype)initWithTask:(FIRStorageObservableTask *)task + storagePlugin:(FLTFirebaseStoragePlugin *)storagePlugin + channelName:(NSString *)channelName + handle:(NSNumber *)handle; @end diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.m b/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.m index 8549df556389..cbf182eb397f 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.m +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTTaskStateChannelStreamHandler.m @@ -9,17 +9,25 @@ @implementation FLTTaskStateChannelStreamHandler { FIRStorageObservableTask *_task; - + FLTFirebaseStoragePlugin *_storagePlugin; + NSString *_channelName; + NSNumber *_handle; FIRStorageHandle successHandle; FIRStorageHandle failureHandle; FIRStorageHandle pausedHandle; FIRStorageHandle progressHandle; } -- (instancetype)initWithTask:(FIRStorageObservableTask *)task { +- (instancetype)initWithTask:(FIRStorageObservableTask *)task + storagePlugin:(FLTFirebaseStoragePlugin *)storagePlugin + channelName:(NSString *)channelName + handle:(NSNumber *)handle { self = [super init]; if (self) { _task = task; + _storagePlugin = storagePlugin; + _channelName = channelName; + _handle = handle; } return self; } @@ -98,6 +106,10 @@ - (FlutterError *)onCancelWithArguments:(id)arguments { } progressHandle = nil; + if (_storagePlugin) { + [_storagePlugin cleanUpTask:_channelName handle:_handle]; + } + return nil; } From f25e21cedc256f4f1529a293eb34074b3025c130 Mon Sep 17 00:00:00 2001 From: Rohit Sangwan Date: Tue, 19 Nov 2024 17:05:00 +0530 Subject: [PATCH 4/7] fix(auth, android): `signInWithProvider()` for non-default instances (#13522) --- .../plugins/firebase/auth/FlutterFirebaseAuthPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java b/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java index a2f84fcf6a42..a8157601ffea 100755 --- a/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java +++ b/packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java @@ -419,7 +419,8 @@ public void signInWithProvider( result) { FirebaseAuth firebaseAuth = getAuthFromPigeon(app); - OAuthProvider.Builder provider = OAuthProvider.newBuilder(signInProvider.getProviderId()); + OAuthProvider.Builder provider = + OAuthProvider.newBuilder(signInProvider.getProviderId(), firebaseAuth); if (signInProvider.getScopes() != null) { provider.setScopes(signInProvider.getScopes()); } From 3de12fc63f593dd3b0eeab3ecff356e366db883c Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 19 Nov 2024 12:47:41 +0000 Subject: [PATCH 5/7] chore: fix running web e2e tests script (#13314) --- melos.yaml | 2 +- tests/integration_test/e2e_test.dart | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/melos.yaml b/melos.yaml index bd93fcaf3991..a12d8e47d9b6 100644 --- a/melos.yaml +++ b/melos.yaml @@ -182,7 +182,7 @@ scripts: test:e2e:web: run: | melos exec -c 1 --fail-fast -- \ - "flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --dart-define=APP_CHECK_E2E=true" + "flutter drive --target=./integration_test/e2e_test.dart --driver=./test_driver/integration_test.dart -d chrome --dart-define=LOCAL_WEB_E2E=true" description: | Run all e2e tests on web platform. Please ensure you have "chromedriver" installed and running. packageFilters: diff --git a/tests/integration_test/e2e_test.dart b/tests/integration_test/e2e_test.dart index 2d15056283c2..0adbcd1de9cb 100644 --- a/tests/integration_test/e2e_test.dart +++ b/tests/integration_test/e2e_test.dart @@ -38,6 +38,13 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('FlutterFire', () { + // ignore: do_not_use_environment + if (const String.fromEnvironment('LOCAL_WEB_E2E') == 'true') { + // for running web e2e locally which doesn't suffer throttling issues + runAllTests(); + return; + } + // ignore: do_not_use_environment if (const String.fromEnvironment('APP_CHECK_E2E') == 'true') { // app check has been separated out for web due to throttling issues From c0fa83f435a6e8ded57e49dc0d4ab810e9b46e6d Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Tue, 19 Nov 2024 15:49:12 +0000 Subject: [PATCH 6/7] test(firestore): switch `testWidgets()` to `test()` for e2e tests (#16709) --- .github/workflows/ios.yaml | 16 +- .../collection_reference_e2e.dart | 14 +- .../integration_test/document_change_e2e.dart | 12 +- .../document_reference_e2e.dart | 63 ++- .../integration_test/field_value_e2e.dart | 39 +- .../integration_test/geo_point_e2e.dart | 4 +- .../integration_test/instance_e2e.dart | 56 ++- .../integration_test/load_bundle_e2e.dart | 28 +- .../example/integration_test/query_e2e.dart | 359 +++++++++--------- .../integration_test/second_database.dart | 273 +++++++------ .../integration_test/settings_e2e.dart | 2 +- .../snapshot_metadata_e2e.dart | 3 +- .../integration_test/timestamp_e2e.dart | 4 +- .../integration_test/transaction_e2e.dart | 48 ++- .../web_snapshot_listeners.dart | 16 +- .../integration_test/write_batch_e2e.dart | 4 +- 16 files changed, 458 insertions(+), 483 deletions(-) diff --git a/.github/workflows/ios.yaml b/.github/workflows/ios.yaml index ff1e64e57522..ccfeaa8a444d 100644 --- a/.github/workflows/ios.yaml +++ b/.github/workflows/ios.yaml @@ -10,6 +10,7 @@ on: - 'docs/**' - 'website/**' - '**/example/**' + - '!**/example/integration_test/**' - '**/flutterfire_ui/**' - '**.md' push: @@ -19,6 +20,7 @@ on: - 'docs/**' - 'website/**' - '**/example/**' + - '!**/example/integration_test/**' - '**/flutterfire_ui/**' - '**.md' @@ -101,16 +103,16 @@ jobs: ccache -s - name: Start Firebase Emulator run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh + - uses: futureware-tech/simulator-action@48e51da14445b3eedca643bba4b78d9d8332ff31 + id: simulator + with: + # List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators + model: "iPhone 15" - name: 'E2E Tests' working-directory: ${{ matrix.working_directory }} + env: + SIMULATOR: ${{ steps.simulator.outputs.udid }} run: | - # Boot simulator and wait for System app to be ready. - # List of available simulators: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators - SIMULATOR="iPhone 15" - xcrun simctl bootstatus "$SIMULATOR" -b - xcrun simctl logverbose "$SIMULATOR" enable - # Sleep to allow simulator to settle. - sleep 15 # Uncomment following line to have simulator logs printed out for debugging purposes. # xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' & flutter test integration_test/e2e_test.dart -d "$SIMULATOR" --dart-define=CI=true diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/collection_reference_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/collection_reference_e2e.dart index 1f07c032c5f7..73038acec97b 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/collection_reference_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/collection_reference_e2e.dart @@ -30,7 +30,7 @@ void runCollectionReferenceTests() { return collection; } - testWidgets('add() adds a document', (_) async { + test('add() adds a document', () async { CollectionReference> collection = await initializeTest('collection-reference-add'); var rand = Random(); @@ -42,9 +42,9 @@ void runCollectionReferenceTests() { expect(randNum, equals(snapshot.data()!['value'])); }); - testWidgets( + test( 'snapshots() can be reused', - (_) async { + () async { final foo = await initializeTest('foo'); final snapshot = foo.snapshots(); @@ -86,9 +86,9 @@ void runCollectionReferenceTests() { group( 'withConverter', () { - testWidgets( + test( 'add/snapshot', - (_) async { + () async { final foo = await initializeTest('foo'); final fooConverter = foo.withConverter( fromFirestore: (snapshots, _) => @@ -179,9 +179,9 @@ void runCollectionReferenceTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'returning null from `fromFirestore` should not throw a null check error', - (_) async { + () async { final foo = await initializeTest('foo'); await foo.add({'value': 42}); final fooConverter = foo.withConverter( diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/document_change_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/document_change_e2e.dart index 42ef50490983..f397adcc502a 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/document_change_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/document_change_e2e.dart @@ -31,9 +31,9 @@ void runDocumentChangeTests() { return collection; } - testWidgets( + test( 'can add/update values to null in the document', - (_) async { + () async { CollectionReference> collection = await initializeTest('null-test'); DocumentReference> doc1 = collection.doc('doc1'); @@ -84,9 +84,9 @@ void runDocumentChangeTests() { skip: defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets( + test( 'returns the correct metadata when adding and removing', - (_) async { + () async { CollectionReference> collection = await initializeTest('add-remove-document'); DocumentReference> doc1 = collection.doc('doc1'); @@ -141,9 +141,9 @@ void runDocumentChangeTests() { skip: defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets( + test( 'returns the correct metadata when modifying', - (_) async { + () async { CollectionReference> collection = await initializeTest('add-modify-document'); DocumentReference> doc1 = collection.doc('doc1'); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/document_reference_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/document_reference_e2e.dart index 94aa83078672..e22eb5deec97 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/document_reference_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/document_reference_e2e.dart @@ -27,7 +27,7 @@ void runDocumentReferenceTests() { group( 'DocumentReference.snapshots()', () { - testWidgets('returns a [Stream]', (_) async { + test('returns a [Stream]', () async { DocumentReference> document = await initializeTest('document-snapshot'); Stream>> stream = @@ -35,7 +35,7 @@ void runDocumentReferenceTests() { expect(stream, isA>>>()); }); - testWidgets('can be reused', (_) async { + test('can be reused', () async { final foo = await initializeTest('foo'); final snapshot = foo.snapshots(); @@ -66,7 +66,7 @@ void runDocumentReferenceTests() { ); }); - testWidgets('listens to a single response', (_) async { + test('listens to a single response', () async { DocumentReference> document = await initializeTest('document-snapshot'); Stream>> stream = @@ -88,7 +88,7 @@ void runDocumentReferenceTests() { }); }); - testWidgets('listens to a single response from cache', (_) async { + test('listens to a single response from cache', () async { DocumentReference> document = await initializeTest('document-snapshot'); Stream>> stream = @@ -110,7 +110,7 @@ void runDocumentReferenceTests() { }); }); - testWidgets('listens to a document from cache', (_) async { + test('listens to a document from cache', () async { DocumentReference> document = await initializeTest('document-snapshot-cache'); await document.set({'foo': 'bar'}); @@ -134,7 +134,7 @@ void runDocumentReferenceTests() { }); }); - testWidgets('listens to multiple documents', (_) async { + test('listens to multiple documents', () async { DocumentReference> doc1 = await initializeTest('document-snapshot-1'); DocumentReference> doc2 = @@ -150,7 +150,7 @@ void runDocumentReferenceTests() { await expectLater(value2, completion('value2')); }); - testWidgets('listens to a multiple changes response', (_) async { + test('listens to a multiple changes response', () async { DocumentReference> document = await initializeTest('document-snapshot-multiple'); Stream>> stream = @@ -197,7 +197,7 @@ void runDocumentReferenceTests() { ); }); - testWidgets('listeners throws a [FirebaseException]', (_) async { + test('listeners throws a [FirebaseException]', () async { DocumentReference> document = firestore.doc('not-allowed/document'); Stream>> stream = @@ -220,7 +220,7 @@ void runDocumentReferenceTests() { ); group('DocumentReference.delete()', () { - testWidgets('delete() deletes a document', (_) async { + test('delete() deletes a document', () async { DocumentReference> document = await initializeTest('document-delete'); await document.set({ @@ -233,9 +233,9 @@ void runDocumentReferenceTests() { expect(snapshot2.exists, isFalse); }); - testWidgets( + test( 'throws a [FirebaseException] on error', - (_) async { + () async { DocumentReference> document = firestore.doc('not-allowed/document'); @@ -257,7 +257,7 @@ void runDocumentReferenceTests() { }); group('DocumentReference.get()', () { - testWidgets('gets a document from server', (_) async { + test('gets a document from server', () async { DocumentReference> document = await initializeTest('document-get-server'); await document.set({'foo': 'bar'}); @@ -267,9 +267,9 @@ void runDocumentReferenceTests() { expect(snapshot.metadata.isFromCache, isFalse); }); - testWidgets( + test( 'gets a document from cache', - (_) async { + () async { DocumentReference> document = await initializeTest('document-get-cache'); await document.set({'foo': 'bar'}); @@ -281,9 +281,9 @@ void runDocumentReferenceTests() { skip: kIsWeb, ); - testWidgets( + test( 'throws a [FirebaseException] on error', - (_) async { + () async { DocumentReference> document = firestore.doc('not-allowed/document'); @@ -303,7 +303,7 @@ void runDocumentReferenceTests() { }); group('DocumentReference.set()', () { - testWidgets('sets data', (_) async { + test('sets data', () async { DocumentReference> document = await initializeTest('document-set'); await document.set({'foo': 'bar'}); @@ -314,7 +314,7 @@ void runDocumentReferenceTests() { expect(snapshot2.data(), equals({'bar': 'baz'})); }); - testWidgets('set() merges data', (_) async { + test('set() merges data', () async { DocumentReference> document = await initializeTest('document-set-merge'); await document.set({'foo': 'bar'}); @@ -326,9 +326,9 @@ void runDocumentReferenceTests() { expect(snapshot2.data(), equals({'foo': 'ben', 'bar': 'baz'})); }); - testWidgets( + test( 'set() merges fields', - (_) async { + () async { DocumentReference> document = await initializeTest('document-set-merge-fields'); Map initialData = { @@ -363,9 +363,9 @@ void runDocumentReferenceTests() { }, ); - testWidgets( + test( 'throws a [FirebaseException] on error', - (_) async { + () async { DocumentReference> document = firestore.doc('not-allowed/document'); @@ -383,7 +383,7 @@ void runDocumentReferenceTests() { }, ); - testWidgets('set and return all possible datatypes', (_) async { + test('set and return all possible datatypes', () async { DocumentReference> document = await initializeTest('document-types'); @@ -453,7 +453,7 @@ void runDocumentReferenceTests() { }); group('DocumentReference.update()', () { - testWidgets('updates data', (_) async { + test('updates data', () async { DocumentReference> document = await initializeTest('document-update'); await document.set({'foo': 'bar'}); @@ -464,7 +464,7 @@ void runDocumentReferenceTests() { expect(snapshot2.data(), equals({'foo': 'bar', 'bar': 'baz'})); }); - testWidgets('updates nested data using dots', (_) async { + test('updates nested data using dots', () async { DocumentReference> document = await initializeTest('document-update-field-path'); await document.set({ @@ -488,7 +488,7 @@ void runDocumentReferenceTests() { ); }); - testWidgets('updates nested data using FieldPath', (_) async { + test('updates nested data using FieldPath', () async { DocumentReference> document = await initializeTest('document-update-field-path'); await document.set({ @@ -514,8 +514,7 @@ void runDocumentReferenceTests() { ); }); - testWidgets('updates nested data containing a dot using FieldPath', - (_) async { + test('updates nested data containing a dot using FieldPath', () async { DocumentReference> document = await initializeTest('document-update-field-path'); await document.set({'foo.bar': 'baz'}); @@ -535,9 +534,9 @@ void runDocumentReferenceTests() { ); }); - testWidgets( + test( 'throws if document does not exist', - (_) async { + () async { DocumentReference> document = await initializeTest('document-update-not-exists'); try { @@ -555,9 +554,9 @@ void runDocumentReferenceTests() { }); group('withConverter', () { - testWidgets( + test( 'set/snapshot/get', - (_) async { + () async { final foo = await initializeTest('foo'); final fooConverter = foo.withConverter( fromFirestore: (snapshots, _) => snapshots.data()!['value']! as int, diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/field_value_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/field_value_e2e.dart index 20ac0efd9878..0afcfbc3acc3 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/field_value_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/field_value_e2e.dart @@ -22,7 +22,7 @@ void runFieldValueTests() { } group('FieldValue.increment()', () { - testWidgets('increments a number if it exists', (_) async { + test('increments a number if it exists', () async { DocumentReference> doc = await initializeTest('field-value-increment-exists'); await doc.set({'foo': 2}); @@ -33,7 +33,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], isA()); }); - testWidgets('increments a big number if it exists', (_) async { + test('increments a big number if it exists', () async { DocumentReference> doc = await initializeTest('field-value-increment-exists'); await doc.set({'foo': 0}); @@ -42,7 +42,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals(2148000000)); }); - testWidgets('decrements a number', (_) async { + test('decrements a number', () async { DocumentReference> doc = await initializeTest('field-value-decrement-exists'); await doc.set({'foo': 2}); @@ -51,7 +51,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals(1)); }); - testWidgets('sets an increment if it does not exist', (_) async { + test('sets an increment if it does not exist', () async { DocumentReference> doc = await initializeTest('field-value-increment-not-exists'); DocumentSnapshot> snapshot = await doc.get(); @@ -63,7 +63,7 @@ void runFieldValueTests() { }); group('FieldValue.serverTimestamp()', () { - testWidgets('sets a new server time value', (_) async { + test('sets a new server time value', () async { DocumentReference> doc = await initializeTest('field-value-server-timestamp-new'); await doc.set({'foo': FieldValue.serverTimestamp()}); @@ -71,7 +71,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], isA()); }); - testWidgets('updates a server time value', (_) async { + test('updates a server time value', () async { DocumentReference> doc = await initializeTest('field-value-server-timestamp-update'); await doc.set({'foo': FieldValue.serverTimestamp()}); @@ -92,7 +92,7 @@ void runFieldValueTests() { }); group('FieldValue.delete()', () { - testWidgets('removes a value', (_) async { + test('removes a value', () async { DocumentReference> doc = await initializeTest('field-value-delete'); await doc.set({'foo': 'bar', 'bar': 'baz'}); @@ -103,7 +103,7 @@ void runFieldValueTests() { }); group('FieldValue.arrayUnion()', () { - testWidgets('updates an existing array', (_) async { + test('updates an existing array', () async { DocumentReference> doc = await initializeTest('field-value-array-union-update-array'); await doc.set({ @@ -116,8 +116,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals([1, 2, 3, 4])); }); - testWidgets('updates an array if current value is not an array', - (_) async { + test('updates an array if current value is not an array', () async { DocumentReference> doc = await initializeTest('field-value-array-union-replace'); await doc.set({'foo': 'bar'}); @@ -128,7 +127,7 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals([3, 4])); }); - testWidgets('sets an array if current value is not an array', (_) async { + test('sets an array if current value is not an array', () async { DocumentReference> doc = await initializeTest('field-value-array-union-replace'); await doc.set({'foo': 'bar'}); @@ -141,7 +140,7 @@ void runFieldValueTests() { }); group('FieldValue.arrayRemove()', () { - testWidgets('removes items in an array', (_) async { + test('removes items in an array', () async { DocumentReference> doc = await initializeTest('field-value-array-remove-existing'); await doc.set({ @@ -154,8 +153,8 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals([1, 2])); }); - testWidgets('removes & updates an array if existing item is not an array', - (_) async { + test('removes & updates an array if existing item is not an array', + () async { DocumentReference> doc = await initializeTest('field-value-array-remove-replace'); await doc.set({'foo': 'bar'}); @@ -166,8 +165,8 @@ void runFieldValueTests() { expect(snapshot.data()!['foo'], equals([3, 4])); }); - testWidgets('removes & sets an array if existing item is not an array', - (_) async { + test('removes & sets an array if existing item is not an array', + () async { DocumentReference> doc = await initializeTest('field-value-array-remove-replace'); await doc.set({'foo': 'bar'}); @@ -180,9 +179,9 @@ void runFieldValueTests() { // ignore: todo // TODO(salakar): test is currently failing on CI but unable to reproduce locally - testWidgets( + test( 'updates with nested types', - (_) async { + () async { DocumentReference> doc = await initializeTest('field-value-nested-types'); @@ -201,7 +200,7 @@ void runFieldValueTests() { skip: true, ); - testWidgets('query should restore nested Timestamp', (_) async { + test('query should restore nested Timestamp', () async { DocumentReference> doc = await initializeTest('nested-timestamp'); await Future.wait([ @@ -219,7 +218,7 @@ void runFieldValueTests() { expect(snapshot.data()!['nested']['timestamp'], isA()); }); - testWidgets('query should restore nested Timestamp in List', (_) async { + test('query should restore nested Timestamp in List', () async { DocumentReference> doc = await initializeTest('nested-timestamp'); await doc.set({ diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/geo_point_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/geo_point_e2e.dart index a7993c1747a1..b9ee4b27b0c6 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/geo_point_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/geo_point_e2e.dart @@ -21,7 +21,7 @@ void runGeoPointTests() { return firestore.doc(prefixedPath); } - testWidgets('sets a $GeoPoint & returns one', (_) async { + test('sets a $GeoPoint & returns one', () async { DocumentReference> doc = await initializeTest('geo-point'); @@ -35,7 +35,7 @@ void runGeoPointTests() { expect(geopoint.longitude, equals(-10)); }); - testWidgets('updates a $GeoPoint & returns', (_) async { + test('updates a $GeoPoint & returns', () async { DocumentReference> doc = await initializeTest('geo-point-update'); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/instance_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/instance_e2e.dart index e8e8a445803e..6ee907202af8 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/instance_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/instance_e2e.dart @@ -20,9 +20,9 @@ void runInstanceTests() { firestore = FirebaseFirestore.instance; }); - testWidgets( + test( 'snapshotsInSync()', - (_) async { + () async { DocumentReference> documentReference = firestore.doc('flutter-tests/insync'); @@ -67,9 +67,9 @@ void runInstanceTests() { skip: kIsWeb, ); - testWidgets( + test( 'enableNetwork()', - (_) async { + () async { // Write some data while online await firestore.enableNetwork(); DocumentReference> documentReference = @@ -97,9 +97,9 @@ void runInstanceTests() { skip: kIsWeb, ); - testWidgets( + test( 'disableNetwork()', - (_) async { + () async { // Write some data while online await firestore.enableNetwork(); DocumentReference> documentReference = @@ -121,17 +121,17 @@ void runInstanceTests() { skip: kIsWeb, ); - testWidgets( + test( 'waitForPendingWrites()', - (_) async { + () async { await firestore.waitForPendingWrites(); }, skip: kIsWeb, ); - testWidgets( + test( 'terminate() / clearPersistence()', - (_) async { + () async { // Since the firestore instance has already been used, // calling `clearPersistence` will throw a native error. // We first check it does throw as expected, then terminate @@ -151,9 +151,9 @@ void runInstanceTests() { skip: kIsWeb || defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets( + test( 'setIndexConfiguration()', - (_) async { + () async { Index index1 = Index( collectionGroup: 'bar', queryScope: QueryScope.collectionGroup, @@ -236,9 +236,9 @@ void runInstanceTests() { skip: defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets( + test( 'setIndexConfigurationFromJSON()', - (_) async { + () async { final json = jsonEncode({ 'indexes': [ { @@ -264,15 +264,14 @@ void runInstanceTests() { skip: defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets('setLoggingEnabled should resolve without issue', - (widgetTester) async { + test('setLoggingEnabled should resolve without issue', () async { await FirebaseFirestore.setLoggingEnabled(true); await FirebaseFirestore.setLoggingEnabled(false); }); - testWidgets( + test( 'Settings() - `persistenceEnabled` & `cacheSizeBytes` with acceptable number', - (widgetTester) async { + () async { FirebaseFirestore.instance.settings = const Settings(persistenceEnabled: true, cacheSizeBytes: 10000000); // Used to trigger settings @@ -284,9 +283,9 @@ void runInstanceTests() { ); }); - testWidgets( + test( 'Settings() - `persistenceEnabled` & `cacheSizeBytes` with `Settings.CACHE_SIZE_UNLIMITED`', - (widgetTester) async { + () async { FirebaseFirestore.instance.settings = const Settings( persistenceEnabled: true, cacheSizeBytes: Settings.CACHE_SIZE_UNLIMITED, @@ -300,9 +299,8 @@ void runInstanceTests() { ); }); - testWidgets( - 'Settings() - `persistenceEnabled` & without `cacheSizeBytes`', - (widgetTester) async { + test('Settings() - `persistenceEnabled` & without `cacheSizeBytes`', + () async { FirebaseFirestore.instance.settings = const Settings(persistenceEnabled: true); // Used to trigger settings @@ -313,9 +311,9 @@ void runInstanceTests() { {'some': 'data'}, ); }); - testWidgets( + test( '`PersistenceCacheIndexManager` with default persistence settings for each platform', - (widgetTester) async { + () async { if (defaultTargetPlatform == TargetPlatform.windows) { try { // Windows does not have `PersistenceCacheIndexManager` support @@ -351,9 +349,9 @@ void runInstanceTests() { }, ); - testWidgets( + test( '`PersistenceCacheIndexManager` with persistence enabled for each platform', - (widgetTester) async { + () async { if (kIsWeb) { final firestore = FirebaseFirestore.instanceFor( app: Firebase.app(), @@ -399,9 +397,9 @@ void runInstanceTests() { skip: defaultTargetPlatform == TargetPlatform.windows, ); - testWidgets( + test( '`PersistenceCacheIndexManager` with persistence disabled for each platform', - (widgetTester) async { + () async { if (kIsWeb) { final firestore = FirebaseFirestore.instanceFor( app: Firebase.app(), diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/load_bundle_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/load_bundle_e2e.dart index a5859d019a39..9d1651780bc5 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/load_bundle_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/load_bundle_e2e.dart @@ -26,7 +26,7 @@ void runLoadBundleTests() { }); group('FirebaseFirestore.loadBundle()', () { - testWidgets('loadBundle()', (_) async { + test('loadBundle()', () async { const int number = 1; const String collection = 'firestore-bundle-tests-$number'; Uint8List buffer = await loadBundleSetup(number); @@ -45,9 +45,9 @@ void runLoadBundleTests() { ); }); - testWidgets( + test( 'loadBundle(): LoadBundleTaskProgress stream snapshots', - (_) async { + () async { Uint8List buffer = await loadBundleSetup(2); LoadBundleTask task = firestore.loadBundle(buffer); @@ -77,9 +77,9 @@ void runLoadBundleTests() { skip: kIsWeb, ); - testWidgets( + test( 'loadBundle(): error handling for malformed bundle', - (_) async { + () async { final url = Uri.https( 'api.rnfirebase.io', '/firestore/e2e-tests/malformed-bundle', @@ -100,9 +100,9 @@ void runLoadBundleTests() { }, ); - testWidgets( + test( 'loadBundle(): pause and resume stream', - (_) async { + () async { Uint8List buffer = await loadBundleSetup(3); LoadBundleTask task = firestore.loadBundle(buffer); // Illustrates the pause() & resume() function. @@ -139,9 +139,9 @@ void runLoadBundleTests() { }); group('FirebaseFirestore.namedQueryGet()', () { - testWidgets( + test( 'namedQueryGet() successful', - (_) async { + () async { const int number = 4; Uint8List buffer = await loadBundleSetup(number); LoadBundleTask task = firestore.loadBundle(buffer); @@ -165,9 +165,9 @@ void runLoadBundleTests() { skip: kIsWeb, ); - testWidgets( + test( 'namedQueryGet() error', - (_) async { + () async { Uint8List buffer = await loadBundleSetup(4); LoadBundleTask task = firestore.loadBundle(buffer); @@ -190,7 +190,7 @@ void runLoadBundleTests() { }); group('FirebaeFirestore.namedQueryWithConverterGet()', () { - testWidgets('namedQueryWithConverterGet() successful', (_) async { + test('namedQueryWithConverterGet() successful', () async { const int number = 4; Uint8List buffer = await loadBundleSetup(number); LoadBundleTask task = firestore.loadBundle(buffer); @@ -214,9 +214,9 @@ void runLoadBundleTests() { ); }); - testWidgets( + test( 'namedQueryWithConverterGet() error', - (_) async { + () async { Uint8List buffer = await loadBundleSetup(4); LoadBundleTask task = firestore.loadBundle(buffer); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart index 936d30888066..af745ec65223 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/query_e2e.dart @@ -34,7 +34,7 @@ void runQueryTests() { group('equality', () { // testing == override using e2e tests as it is dependent on the platform - testWidgets('handles deeply compares query parameters', (_) async { + test('handles deeply compares query parameters', () async { final movies = firestore.collection('/movies'); final starWarsComments = firestore.collection('/movies/star-wars/comments'); @@ -53,8 +53,7 @@ void runQueryTests() { ); }); - testWidgets('differentiate queries from a different app instance', - (_) async { + test('differentiate queries from a different app instance', () async { final fooApp = await Firebase.initializeApp( name: 'foo', options: Firebase.app().options, @@ -79,7 +78,7 @@ void runQueryTests() { ); }); - testWidgets('differentiate collection group', (_) async { + test('differentiate collection group', () async { expect( firestore.collectionGroup('comments').limit(42), firestore.collectionGroup('comments').limit(42), @@ -95,7 +94,7 @@ void runQueryTests() { * collectionGroup */ group('collectionGroup()', () { - testWidgets('returns a data via a sub-collection', (_) async { + test('returns a data via a sub-collection', () async { CollectionReference> collection = firestore.collection('flutter-tests/collection-group/group-test'); QuerySnapshot> snapshot = await collection.get(); @@ -117,9 +116,9 @@ void runQueryTests() { expect(groupSnapshot.docs[1].data()['foo'], equals(1)); }); - testWidgets( + test( 'should respond with a FirebaseException, the query requires an index', - (_) async { + () async { try { await FirebaseFirestore.instance .collectionGroup('collection-group') @@ -143,14 +142,14 @@ void runQueryTests() { * get */ group('Query.get()', () { - testWidgets('returns a [QuerySnapshot]', (_) async { + test('returns a [QuerySnapshot]', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get(); expect(qs, isA>>()); }); - testWidgets('uses [GetOptions] cache', (_) async { + test('uses [GetOptions] cache', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = @@ -159,7 +158,7 @@ void runQueryTests() { expect(qs.metadata.isFromCache, isTrue); }); - testWidgets('uses [GetOptions] server', (_) async { + test('uses [GetOptions] server', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = @@ -168,8 +167,7 @@ void runQueryTests() { expect(qs.metadata.isFromCache, isFalse); }); - testWidgets('uses [GetOptions] serverTimestampBehavior previous', - (_) async { + test('uses [GetOptions] serverTimestampBehavior previous', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get( @@ -180,8 +178,7 @@ void runQueryTests() { expect(qs, isA>>()); }); - testWidgets('uses [GetOptions] serverTimestampBehavior estimate', - (_) async { + test('uses [GetOptions] serverTimestampBehavior estimate', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get( @@ -192,9 +189,9 @@ void runQueryTests() { expect(qs, isA>>()); }); - testWidgets( + test( 'throws a [FirebaseException]', - (_) async { + () async { CollectionReference> collection = firestore.collection('not-allowed'); @@ -212,9 +209,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'should respond with a FirebaseException, the query requires an index', - (_) async { + () async { try { await FirebaseFirestore.instance .collection('flutter-tests') @@ -239,7 +236,7 @@ void runQueryTests() { * snapshots */ group('Query.snapshots()', () { - testWidgets('returns a [Stream]', (_) async { + test('returns a [Stream]', () async { CollectionReference> collection = await initializeTest('get'); Stream>> stream = @@ -247,7 +244,7 @@ void runQueryTests() { expect(stream, isA>>>()); }); - testWidgets('listens to a single response', (_) async { + test('listens to a single response', () async { CollectionReference> collection = await initializeTest('get-single'); await collection.add({'foo': 'bar'}); @@ -272,9 +269,9 @@ void runQueryTests() { }); }); - testWidgets( + test( 'listens to a single response from cache with QuerySnapshot', - (_) async { + () async { CollectionReference> collection = await initializeTest('get-single-cache'); await collection.add({'foo': 'bar'}); @@ -302,7 +299,7 @@ void runQueryTests() { skip: kIsWeb, ); - testWidgets('listens to multiple queries', (_) async { + test('listens to multiple queries', () async { CollectionReference> collection1 = await initializeTest('document-snapshot-1'); CollectionReference> collection2 = @@ -324,7 +321,7 @@ void runQueryTests() { await expectLater(value2, completion('value2')); }); - testWidgets('listens to a multiple changes response', (_) async { + test('listens to a multiple changes response', () async { CollectionReference> collection = await initializeTest('get-multiple'); await collection.add({'foo': 'bar'}); @@ -381,9 +378,9 @@ void runQueryTests() { await subscription.cancel(); }); - testWidgets( + test( 'listeners throws a [FirebaseException] with Query', - (_) async { + () async { CollectionReference> collection = firestore.collection('not-allowed'); Stream>> stream = @@ -412,7 +409,7 @@ void runQueryTests() { */ group('Query.endAt{Document}()', () { - testWidgets('ends at string field paths', (_) async { + test('ends at string field paths', () async { CollectionReference> collection = await initializeTest('endAt-string'); await Future.wait([ @@ -446,7 +443,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends at string field paths with Iterable', (_) async { + test('ends at string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('endAt-string'); await Future.wait([ @@ -480,7 +477,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends at field paths', (_) async { + test('ends at field paths', () async { CollectionReference> collection = await initializeTest('endAt-field-path'); await Future.wait([ @@ -514,7 +511,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('endAtDocument() ends at a document field value', (_) async { + test('endAtDocument() ends at a document field value', () async { CollectionReference> collection = await initializeTest('endAt-document'); await Future.wait([ @@ -541,7 +538,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets('endAtDocument() ends at a document', (_) async { + test('endAtDocument() ends at a document', () async { CollectionReference> collection = await initializeTest('endAt-document'); await Future.wait([ @@ -576,7 +573,7 @@ void runQueryTests() { */ group('Query.startAt{Document}()', () { - testWidgets('starts at string field paths', (_) async { + test('starts at string field paths', () async { CollectionReference> collection = await initializeTest('startAt-string'); await Future.wait([ @@ -610,7 +607,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts at string field paths with Iterable', (_) async { + test('starts at string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('startAt-string'); await Future.wait([ @@ -644,7 +641,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts at field paths', (_) async { + test('starts at field paths', () async { CollectionReference> collection = await initializeTest('startAt-field-path'); await Future.wait([ @@ -679,8 +676,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('startAtDocument() starts at a document field value', - (_) async { + test('startAtDocument() starts at a document field value', () async { CollectionReference> collection = await initializeTest('startAt-document-field-value'); await Future.wait([ @@ -707,7 +703,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc1')); }); - testWidgets('startAtDocument() starts at a document', (_) async { + test('startAtDocument() starts at a document', () async { CollectionReference> collection = await initializeTest('startAt-document'); await Future.wait([ @@ -741,7 +737,7 @@ void runQueryTests() { */ group('Query.endBefore{Document}()', () { - testWidgets('ends before string field paths', (_) async { + test('ends before string field paths', () async { CollectionReference> collection = await initializeTest('endBefore-string'); await Future.wait([ @@ -775,7 +771,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends before string field paths with Iterable', (_) async { + test('ends before string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('endBefore-string'); await Future.wait([ @@ -809,7 +805,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends before field paths', (_) async { + test('ends before field paths', () async { CollectionReference> collection = await initializeTest('endBefore-field-path'); await Future.wait([ @@ -844,8 +840,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('endbeforeDocument() ends before a document field value', - (_) async { + test('endbeforeDocument() ends before a document field value', () async { CollectionReference> collection = await initializeTest('endBefore-document-field-value'); await Future.wait([ @@ -872,7 +867,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets('endBeforeDocument() ends before a document', (_) async { + test('endBeforeDocument() ends before a document', () async { CollectionReference> collection = await initializeTest('endBefore-document'); await Future.wait([ @@ -906,7 +901,7 @@ void runQueryTests() { * Start after */ group('Query.startAfter{Document}()', () { - testWidgets('starts after string field paths', (_) async { + test('starts after string field paths', () async { CollectionReference> collection = await initializeTest('startAfter-string'); await Future.wait([ @@ -940,7 +935,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts after field paths', (_) async { + test('starts after field paths', () async { CollectionReference> collection = await initializeTest('startAfter-field-path'); await Future.wait([ @@ -975,8 +970,8 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('startAfterDocument() starts after a document field value', - (_) async { + test('startAfterDocument() starts after a document field value', + () async { CollectionReference> collection = await initializeTest('startAfter-document-field-value'); await Future.wait([ @@ -1004,7 +999,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc1')); }); - testWidgets('startAfterDocument() starts after a document', (_) async { + test('startAfterDocument() starts after a document', () async { CollectionReference> collection = await initializeTest('startAfter-document'); await Future.wait([ @@ -1038,7 +1033,7 @@ void runQueryTests() { */ group('Query.startAt/endAt', () { - testWidgets('starts at & ends at a document', (_) async { + test('starts at & ends at a document', () async { CollectionReference> collection = await initializeTest('start-end-string'); await Future.wait([ @@ -1064,7 +1059,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts at & ends before a document', (_) async { + test('starts at & ends before a document', () async { CollectionReference> collection = await initializeTest('start-end-string'); await Future.wait([ @@ -1090,7 +1085,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts after & ends at a document', (_) async { + test('starts after & ends at a document', () async { CollectionReference> collection = await initializeTest('start-end-field-path'); await Future.wait([ @@ -1116,7 +1111,7 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts a document and ends before document', (_) async { + test('starts a document and ends before document', () async { CollectionReference> collection = await initializeTest('start-end-document'); await Future.wait([ @@ -1153,7 +1148,7 @@ void runQueryTests() { */ group('Query.limit{toLast}()', () { - testWidgets('limits documents', (_) async { + test('limits documents', () async { CollectionReference> collection = await initializeTest('limit'); await Future.wait([ @@ -1183,7 +1178,7 @@ void runQueryTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('limits to last documents', (_) async { + test('limits to last documents', () async { CollectionReference> collection = await initializeTest('limitToLast'); await Future.wait([ @@ -1220,7 +1215,7 @@ void runQueryTests() { * Order */ group('Query.orderBy()', () { - testWidgets('allows ordering by documentId', (_) async { + test('allows ordering by documentId', () async { CollectionReference> collection = await initializeTest('order-document-id'); @@ -1248,7 +1243,7 @@ void runQueryTests() { expect(snapshot.docs[2].id, equals('doc3')); }); - testWidgets('orders async by default', (_) async { + test('orders async by default', () async { CollectionReference> collection = await initializeTest('order-asc'); @@ -1273,7 +1268,7 @@ void runQueryTests() { expect(snapshot.docs[2].id, equals('doc1')); }); - testWidgets('orders descending', (_) async { + test('orders descending', () async { CollectionReference> collection = await initializeTest('order-desc'); await Future.wait([ @@ -1303,9 +1298,8 @@ void runQueryTests() { */ group('Query.where()', () { - testWidgets( - 'returns documents when querying for properties that are not null', - (_) async { + test('returns documents when querying for properties that are not null', + () async { CollectionReference> collection = await initializeTest('not-null'); await Future.wait([ @@ -1328,9 +1322,8 @@ void runQueryTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets( - 'returns documents when querying properties that are equal to null', - (_) async { + test('returns documents when querying properties that are equal to null', + () async { CollectionReference> collection = await initializeTest('not-null'); await Future.wait([ @@ -1352,7 +1345,7 @@ void runQueryTests() { expect(snapshot.docs[0].id, equals('doc3')); }); - testWidgets('returns with equal checks', (_) async { + test('returns with equal checks', () async { CollectionReference> collection = await initializeTest('where-equal'); int rand = Random().nextInt(9999); @@ -1378,7 +1371,7 @@ void runQueryTests() { }); }); - testWidgets('returns with not equal checks', (_) async { + test('returns with not equal checks', () async { CollectionReference> collection = await initializeTest('where-not-equal'); int rand = Random().nextInt(9999); @@ -1404,7 +1397,7 @@ void runQueryTests() { }); }); - testWidgets('returns with greater than checks', (_) async { + test('returns with greater than checks', () async { CollectionReference> collection = await initializeTest('where-greater-than'); int rand = Random().nextInt(9999); @@ -1433,7 +1426,7 @@ void runQueryTests() { }); }); - testWidgets('returns with greater than or equal to checks', (_) async { + test('returns with greater than or equal to checks', () async { CollectionReference> collection = await initializeTest('where-greater-than-equal'); int rand = Random().nextInt(9999); @@ -1462,7 +1455,7 @@ void runQueryTests() { }); }); - testWidgets('returns with less than checks', (_) async { + test('returns with less than checks', () async { CollectionReference> collection = await initializeTest('where-less-than'); int rand = Random().nextInt(9999); @@ -1488,7 +1481,7 @@ void runQueryTests() { }); }); - testWidgets('returns with less than equal checks', (_) async { + test('returns with less than equal checks', () async { CollectionReference> collection = await initializeTest('where-less-than'); int rand = Random().nextInt(9999); @@ -1517,7 +1510,7 @@ void runQueryTests() { }); }); - testWidgets('returns with array-contains filter', (_) async { + test('returns with array-contains filter', () async { CollectionReference> collection = await initializeTest('where-array-contains'); int rand = Random().nextInt(9999); @@ -1543,7 +1536,7 @@ void runQueryTests() { }); }); - testWidgets('returns with in filter', (_) async { + test('returns with in filter', () async { CollectionReference> collection = await initializeTest('where-in'); @@ -1572,7 +1565,7 @@ void runQueryTests() { }); }); - testWidgets('returns with in filter using Iterable', (_) async { + test('returns with in filter using Iterable', () async { CollectionReference> collection = await initializeTest('where-in-iterable'); @@ -1606,7 +1599,7 @@ void runQueryTests() { }); }); - testWidgets('returns with in filter using Set', (_) async { + test('returns with in filter using Set', () async { CollectionReference> collection = await initializeTest('where-in'); @@ -1635,7 +1628,7 @@ void runQueryTests() { }); }); - testWidgets('returns with not-in filter', (_) async { + test('returns with not-in filter', () async { CollectionReference> collection = await initializeTest('where-not-in'); @@ -1664,7 +1657,7 @@ void runQueryTests() { }); }); - testWidgets('returns with not-in filter with Iterable', (_) async { + test('returns with not-in filter with Iterable', () async { CollectionReference> collection = await initializeTest('where-not-in'); @@ -1693,7 +1686,7 @@ void runQueryTests() { }); }); - testWidgets('returns with array-contains-any filter', (_) async { + test('returns with array-contains-any filter', () async { CollectionReference> collection = await initializeTest('where-array-contains-any'); @@ -1721,8 +1714,7 @@ void runQueryTests() { expect(snapshot.docs.length, equals(3)); }); - testWidgets('returns with array-contains-any filter using Set', - (_) async { + test('returns with array-contains-any filter using Set', () async { CollectionReference> collection = await initializeTest('where-array-contains-any'); @@ -1752,7 +1744,7 @@ void runQueryTests() { // When documents have a key with a '.' in them, only a [FieldPath] // can access the value, rather than a raw string - testWidgets('returns where FieldPath', (_) async { + test('returns where FieldPath', () async { CollectionReference> collection = await initializeTest('where-field-path'); @@ -1786,7 +1778,7 @@ void runQueryTests() { expect(snapshot.docs[1].get('foo'), equals('bar')); }); - testWidgets('returns results using FieldPath.documentId', (_) async { + test('returns results using FieldPath.documentId', () async { CollectionReference> collection = await initializeTest('where-field-path-document-id'); @@ -1807,7 +1799,7 @@ void runQueryTests() { expect(snapshot.docs[0].get('foo'), equals('bar')); }); - testWidgets('returns an encoded DocumentReference', (_) async { + test('returns an encoded DocumentReference', () async { CollectionReference> collection = await initializeTest('where-document-reference'); @@ -1836,9 +1828,9 @@ void runQueryTests() { }); group('Query.where() with Filter class', () { - testWidgets( + test( 'returns documents with `DocumentReference` as an argument in `isEqualTo`', - (_) async { + () async { CollectionReference> collection = await initializeTest('doc-ref-arg-isequal-to'); final ref = FirebaseFirestore.instance.doc('foo/bar'); @@ -1886,9 +1878,9 @@ void runQueryTests() { expect(results.docs[2].data()['title'], equals('Book A')); }); - testWidgets( + test( 'returns documents with `DocumentReference` as an argument in `arrayContains`', - (_) async { + () async { CollectionReference> collection = await initializeTest('doc-ref-arg-array-contains'); final ref = FirebaseFirestore.instance.doc('foo/bar'); @@ -1936,8 +1928,7 @@ void runQueryTests() { expect(results.docs[2].data()['title'], equals('Book A')); }); - testWidgets('returns documents with OR filter for arrayContainsAny', - (_) async { + test('returns documents with OR filter for arrayContainsAny', () async { CollectionReference> collection = await initializeTest('where-filter-array-contains-any'); await Future.wait([ @@ -1970,7 +1961,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('Book A')); }); - testWidgets('returns documents with AND filter', (_) async { + test('returns documents with AND filter', () async { CollectionReference> collection = await initializeTest('where-filter-and'); await Future.wait([ @@ -2004,8 +1995,8 @@ void runQueryTests() { expect(results.docs[0].data()['genre'], equals(['sci-fi', 'action'])); }); - testWidgets('returns documents with OR filter and a previous condition', - (_) async { + test('returns documents with OR filter and a previous condition', + () async { CollectionReference> collection = await initializeTest('where-filter-and'); await Future.wait([ @@ -2044,8 +2035,7 @@ void runQueryTests() { expect(results.docs[1].data()['rating'], equals(4.5)); }); - testWidgets('returns documents with nested OR and AND filters', - (_) async { + test('returns documents with nested OR and AND filters', () async { CollectionReference> collection = await initializeTest('where-filter-nested'); await Future.wait([ @@ -2095,7 +2085,7 @@ void runQueryTests() { expect(results.docs[1].data()['genre'], equals(['sci-fi', 'action'])); }); - testWidgets('allow FieldPathType for Filter queries', (_) async { + test('allow FieldPathType for Filter queries', () async { CollectionReference> collection = await initializeTest('filter-path-type'); @@ -2142,7 +2132,7 @@ void runQueryTests() { expect(results.docs[1].data()['rating'], equals(3.8)); }); - testWidgets('allow multiple conjunctive queries', (_) async { + test('allow multiple conjunctive queries', () async { CollectionReference> collection = await initializeTest('multiple-conjunctive-queries'); @@ -2238,9 +2228,9 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets( + test( 'Can combine `arrayContainsAny` & `isNotEqualTo` in multiple conjunctive queries', - (_) async { + () async { CollectionReference> collection = await initializeTest( 'array-contain-not-equal-conjunctive-queries', @@ -2277,7 +2267,7 @@ void runQueryTests() { }, ); - testWidgets('allow multiple disjunctive queries', (_) async { + test('allow multiple disjunctive queries', () async { CollectionReference> collection = await initializeTest('multiple-disjunctive-queries'); @@ -2392,9 +2382,9 @@ void runQueryTests() { expect(results.docs[2].data()['genre'], equals(['sci-fi', 'thriller'])); }); - testWidgets( + test( 'Can combine `arrayContainsAny` & `isNotEqualTo` in disjunctive queries', - (_) async { + () async { CollectionReference> collection = await initializeTest( 'array-contain-not-equal-disjunctive-queries', @@ -2435,9 +2425,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'allow multiple disjunctive queries for "arrayContainsAny" using ".where() API"', - (_) async { + () async { CollectionReference> collection = await initializeTest('multiple-disjunctive-where'); @@ -2501,9 +2491,9 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets( + test( 'allow multiple disjunctive queries for "whereIn" using ".where() API"', - (_) async { + () async { CollectionReference> collection = await initializeTest('multiple-disjunctive-where'); @@ -2558,8 +2548,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('"whereIn" query combined with "arrayContainsAny"', - (widgetTester) async { + test('"whereIn" query combined with "arrayContainsAny"', () async { CollectionReference> collection = await initializeTest('where-filter-arraycontainsany-in-combined'); await Future.wait([ @@ -2594,7 +2583,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc1')); }); - testWidgets('isEqualTo filter', (_) async { + test('isEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isequalto'); await Future.wait([ @@ -2614,7 +2603,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('isNotEqualTo filter', (_) async { + test('isNotEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isnotequalto'); await Future.wait([ @@ -2633,7 +2622,7 @@ void runQueryTests() { expect(results.docs[0].id, equals('doc3')); }); - testWidgets('isLessThan filter', (_) async { + test('isLessThan filter', () async { CollectionReference> collection = await initializeTest('where-filter-islessthan'); await Future.wait([ @@ -2652,7 +2641,7 @@ void runQueryTests() { expect(results.docs[0].id, equals('doc1')); }); - testWidgets('isLessThanOrEqualTo filter', (_) async { + test('isLessThanOrEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-islessthanequalto'); await Future.wait([ @@ -2672,7 +2661,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('isGreaterThan filter', (_) async { + test('isGreaterThan filter', () async { CollectionReference> collection = await initializeTest('where-filter-isgreaterthan'); await Future.wait([ @@ -2692,7 +2681,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('isGreaterThanOrEqualTo filter', (_) async { + test('isGreaterThanOrEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isgreaterthanequalto'); await Future.wait([ @@ -2712,7 +2701,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('arrayContains filter', (_) async { + test('arrayContains filter', () async { CollectionReference> collection = await initializeTest('where-filter-arraycontains'); await Future.wait([ @@ -2738,7 +2727,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('arrayContainsAny filter', (_) async { + test('arrayContainsAny filter', () async { CollectionReference> collection = await initializeTest('where-filter-arraycontainsany'); await Future.wait([ @@ -2762,7 +2751,7 @@ void runQueryTests() { expect(results.docs.length, equals(3)); }); - testWidgets('whereIn filter', (_) async { + test('whereIn filter', () async { CollectionReference> collection = await initializeTest('where-filter-wherein'); await Future.wait([ @@ -2782,7 +2771,7 @@ void runQueryTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('whereNotIn filter', (_) async { + test('whereNotIn filter', () async { CollectionReference> collection = await initializeTest('where-filter-wherenotin'); await Future.wait([ @@ -2801,7 +2790,7 @@ void runQueryTests() { expect(results.docs[0].id, equals('doc2')); }); - testWidgets('isNull filter', (_) async { + test('isNull filter', () async { CollectionReference> collection = await initializeTest('where-filter-isnull'); await Future.wait([ @@ -2820,7 +2809,7 @@ void runQueryTests() { expect(results.docs[0].id, equals('doc2')); }); - testWidgets('endAt filter', (_) async { + test('endAt filter', () async { CollectionReference> collection = await initializeTest('endat-filter'); await Future.wait([ @@ -2842,7 +2831,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('endBefore filter', (_) async { + test('endBefore filter', () async { CollectionReference> collection = await initializeTest('endbefore-filter'); await Future.wait([ @@ -2865,7 +2854,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('endBeforeDocument filter', (_) async { + test('endBeforeDocument filter', () async { CollectionReference> collection = await initializeTest('endbeforedocument-filter'); await Future.wait([ @@ -2891,7 +2880,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('limit filter', (_) async { + test('limit filter', () async { CollectionReference> collection = await initializeTest('limit-filter'); await Future.wait([ @@ -2915,7 +2904,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('limitToLast filter', (_) async { + test('limitToLast filter', () async { CollectionReference> collection = await initializeTest('limittolast-filter'); await Future.wait([ @@ -2939,7 +2928,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('E')); }); - testWidgets('orderBy filter', (_) async { + test('orderBy filter', () async { CollectionReference> collection = await initializeTest('orderby-filter'); await Future.wait([ @@ -2964,7 +2953,7 @@ void runQueryTests() { expect(results.docs[3].data()['title'], equals('B')); }); - testWidgets('startAfter filter', (_) async { + test('startAfter filter', () async { CollectionReference> collection = await initializeTest('startafter-filter'); await Future.wait([ @@ -2987,7 +2976,7 @@ void runQueryTests() { expect(results.docs[1].data()['title'], equals('E')); }); - testWidgets('startAfterDocument filter', (_) async { + test('startAfterDocument filter', () async { CollectionReference> collection = await initializeTest('startafterdocument-filter'); await Future.wait([ @@ -3014,7 +3003,7 @@ void runQueryTests() { expect(results.docs[2].data()['title'], equals('E')); }); - testWidgets('startAt filter', (_) async { + test('startAt filter', () async { CollectionReference> collection = await initializeTest('startat-filter'); await Future.wait([ @@ -3039,7 +3028,7 @@ void runQueryTests() { expect(results.docs[3].data()['title'], equals('E')); }); - testWidgets('startAtDocument filter', (_) async { + test('startAtDocument filter', () async { CollectionReference> collection = await initializeTest('startatdocument-filter'); await Future.wait([ @@ -3069,9 +3058,9 @@ void runQueryTests() { }); group('withConverter', () { - testWidgets( + test( 'from a query instead of collection', - (_) async { + () async { final collection = await initializeTest('foo'); final query = collection // @@ -3120,9 +3109,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'from a Filter query instead of collection', - (_) async { + () async { final collection = await initializeTest('foo'); final query = collection @@ -3171,9 +3160,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'snapshots', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3218,9 +3207,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'get', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3242,9 +3231,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'orderBy', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3266,9 +3255,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'limit', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3289,9 +3278,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'limitToLast', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3316,7 +3305,7 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets('endAt', (_) async { + test('endAt', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3337,7 +3326,7 @@ void runQueryTests() { ); }); - testWidgets('endAt with Iterable', (_) async { + test('endAt with Iterable', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3358,9 +3347,9 @@ void runQueryTests() { ); }); - testWidgets( + test( 'endAtDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3387,7 +3376,7 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets('endBefore', (_) async { + test('endBefore', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3409,7 +3398,7 @@ void runQueryTests() { ); }); - testWidgets('endBefore with Iterable', (_) async { + test('endBefore with Iterable', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3431,9 +3420,9 @@ void runQueryTests() { ); }); - testWidgets( + test( 'endBeforeDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3457,9 +3446,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAt', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3486,9 +3475,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAt with Iterable', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3515,9 +3504,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAtDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3544,9 +3533,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfter', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3570,9 +3559,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfter with Iterable', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3596,9 +3585,9 @@ void runQueryTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfterDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -3624,9 +3613,9 @@ void runQueryTests() { }); group('Aggregate Queries', () { - testWidgets( + test( 'count()', - (_) async { + () async { final collection = await initializeTest('count'); await Future.wait([ @@ -3645,9 +3634,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'count() with query', - (_) async { + () async { final collection = await initializeTest('count'); await Future.wait([ @@ -3667,9 +3656,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'sum()', - (_) async { + () async { final collection = await initializeTest('sum'); await Future.wait([ @@ -3688,9 +3677,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'sum() with query', - (_) async { + () async { final collection = await initializeTest('sum'); await Future.wait([ @@ -3710,9 +3699,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'average()', - (_) async { + () async { final collection = await initializeTest('avg'); await Future.wait([ @@ -3731,9 +3720,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'average() with query', - (_) async { + () async { final collection = await initializeTest('avg'); await Future.wait([ @@ -3753,9 +3742,9 @@ void runQueryTests() { }, ); - testWidgets( + test( 'chaining aggregate queries', - (_) async { + () async { final collection = await initializeTest('chaining'); await Future.wait([ @@ -3784,7 +3773,7 @@ void runQueryTests() { }, ); - testWidgets('chaining multiples aggregate queries', (_) async { + test('chaining multiples aggregate queries', () async { final collection = await initializeTest('chaining'); await Future.wait([ @@ -3814,9 +3803,9 @@ void runQueryTests() { ); }); - testWidgets( + test( 'count() with collectionGroup', - (_) async { + () async { const subCollection = 'aggregate-group-count'; final doc1 = FirebaseFirestore.instance .collection('flutter-tests') @@ -3854,8 +3843,7 @@ void runQueryTests() { }, ); - testWidgets('count(), average() & sum() on empty collection', - (widgetTester) async { + test('count(), average() & sum() on empty collection', () async { final collection = await initializeTest('empty-collection'); final snapshot = await collection @@ -3868,9 +3856,8 @@ void runQueryTests() { }); group('startAfterDocument', () { - testWidgets( - 'startAfterDocument() accept DocumentReference in query parameters', - (_) async { + test('startAfterDocument() accept DocumentReference in query parameters', + () async { final collection = await initializeTest('start-after-document'); final doc1 = collection.doc('1'); @@ -3893,8 +3880,8 @@ void runQueryTests() { }); group('WhereIn Filter', () { - testWidgets('Multiple whereIn filters should not trigger an assertion', - (_) async { + test('Multiple whereIn filters should not trigger an assertion', + () async { try { final collection = await initializeTest('multipe-whereIn-clause'); @@ -3917,9 +3904,9 @@ void runQueryTests() { } }); - testWidgets( + test( 'Multiple whereIn filters exceeding DNF 30 clause limit should trigger an assertion', - (_) async { + () async { try { final collection = await initializeTest('multipe-whereIn-clause'); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/second_database.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/second_database.dart index 44174f28a3a9..9bdf9fabd10e 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/second_database.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/second_database.dart @@ -66,7 +66,7 @@ void runSecondDatabaseTests() { group( 'queries for default database are banned for this collection: "$collectionForSecondDatabase"', () { - testWidgets('barred query', (_) async { + test('barred query', () async { final defaultFirestore = FirebaseFirestore.instance; try { await defaultFirestore @@ -82,7 +82,7 @@ void runSecondDatabaseTests() { group('equality', () { // testing == override using e2e tests as it is dependent on the platform - testWidgets('handles deeply compares query parameters', (_) async { + test('handles deeply compares query parameters', () async { final movies = firestore.collection('/movies'); final starWarsComments = firestore.collection('/movies/star-wars/comments'); @@ -101,8 +101,7 @@ void runSecondDatabaseTests() { ); }); - testWidgets('differentiate queries from a different app instance', - (_) async { + test('differentiate queries from a different app instance', () async { final fooApp = await Firebase.initializeApp( name: 'foo', options: Firebase.app().options, @@ -127,7 +126,7 @@ void runSecondDatabaseTests() { ); }); - testWidgets('differentiate collection group', (_) async { + test('differentiate collection group', () async { expect( firestore.collectionGroup('comments').limit(42), firestore.collectionGroup('comments').limit(42), @@ -142,14 +141,14 @@ void runSecondDatabaseTests() { * get */ group('Query.get()', () { - testWidgets('returns a [QuerySnapshot]', (_) async { + test('returns a [QuerySnapshot]', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get(); expect(qs, isA>>()); }); - testWidgets('uses [GetOptions] cache', (_) async { + test('uses [GetOptions] cache', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = @@ -158,7 +157,7 @@ void runSecondDatabaseTests() { expect(qs.metadata.isFromCache, isTrue); }); - testWidgets('uses [GetOptions] server', (_) async { + test('uses [GetOptions] server', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = @@ -167,8 +166,7 @@ void runSecondDatabaseTests() { expect(qs.metadata.isFromCache, isFalse); }); - testWidgets('uses [GetOptions] serverTimestampBehavior previous', - (_) async { + test('uses [GetOptions] serverTimestampBehavior previous', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get( @@ -179,8 +177,7 @@ void runSecondDatabaseTests() { expect(qs, isA>>()); }); - testWidgets('uses [GetOptions] serverTimestampBehavior estimate', - (_) async { + test('uses [GetOptions] serverTimestampBehavior estimate', () async { CollectionReference> collection = await initializeTest('get'); QuerySnapshot> qs = await collection.get( @@ -191,9 +188,9 @@ void runSecondDatabaseTests() { expect(qs, isA>>()); }); - testWidgets( + test( 'throws a [FirebaseException]', - (_) async { + () async { CollectionReference> collection = firestore.collection('not-allowed'); @@ -218,7 +215,7 @@ void runSecondDatabaseTests() { * snapshots */ group('Query.snapshots()', () { - testWidgets('returns a [Stream]', (_) async { + test('returns a [Stream]', () async { CollectionReference> collection = await initializeTest('get'); Stream>> stream = @@ -226,7 +223,7 @@ void runSecondDatabaseTests() { expect(stream, isA>>>()); }); - testWidgets('listens to a single response', (_) async { + test('listens to a single response', () async { CollectionReference> collection = await initializeTest('get-single'); await collection.add({'foo': 'bar'}); @@ -254,7 +251,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('listens to multiple queries', (_) async { + test('listens to multiple queries', () async { CollectionReference> collection1 = await initializeTest('document-snapshot-1'); CollectionReference> collection2 = @@ -276,7 +273,7 @@ void runSecondDatabaseTests() { await expectLater(value2, completion('value2')); }); - testWidgets('listens to a multiple changes response', (_) async { + test('listens to a multiple changes response', () async { CollectionReference> collection = await initializeTest('get-multiple'); await collection.add({'foo': 'bar'}); @@ -333,9 +330,9 @@ void runSecondDatabaseTests() { await subscription.cancel(); }); - testWidgets( + test( 'listeners throws a [FirebaseException]', - (_) async { + () async { CollectionReference> collection = firestore.collection('not-allowed'); Stream>> stream = @@ -366,7 +363,7 @@ void runSecondDatabaseTests() { */ group('Query.endAt{Document}()', () { - testWidgets('ends at string field paths', (_) async { + test('ends at string field paths', () async { CollectionReference> collection = await initializeTest('endAt-string'); await Future.wait([ @@ -400,7 +397,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends at string field paths with Iterable', (_) async { + test('ends at string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('endAt-string'); await Future.wait([ @@ -434,7 +431,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends at field paths', (_) async { + test('ends at field paths', () async { CollectionReference> collection = await initializeTest('endAt-field-path'); await Future.wait([ @@ -469,8 +466,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('endAtDocument() ends at a document field value', - (_) async { + test('endAtDocument() ends at a document field value', () async { CollectionReference> collection = await initializeTest('endAt-document'); await Future.wait([ @@ -497,7 +493,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets('endAtDocument() ends at a document', (_) async { + test('endAtDocument() ends at a document', () async { CollectionReference> collection = await initializeTest('endAt-document'); await Future.wait([ @@ -532,7 +528,7 @@ void runSecondDatabaseTests() { */ group('Query.startAt{Document}()', () { - testWidgets('starts at string field paths', (_) async { + test('starts at string field paths', () async { CollectionReference> collection = await initializeTest('startAt-string'); await Future.wait([ @@ -566,7 +562,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts at string field paths with Iterable', (_) async { + test('starts at string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('startAt-string'); await Future.wait([ @@ -600,7 +596,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts at field paths', (_) async { + test('starts at field paths', () async { CollectionReference> collection = await initializeTest('startAt-field-path'); await Future.wait([ @@ -635,8 +631,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('startAtDocument() starts at a document field value', - (_) async { + test('startAtDocument() starts at a document field value', () async { CollectionReference> collection = await initializeTest('startAt-document-field-value'); await Future.wait([ @@ -663,7 +658,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc1')); }); - testWidgets('startAtDocument() starts at a document', (_) async { + test('startAtDocument() starts at a document', () async { CollectionReference> collection = await initializeTest('startAt-document'); await Future.wait([ @@ -697,7 +692,7 @@ void runSecondDatabaseTests() { */ group('Query.endBefore{Document}()', () { - testWidgets('ends before string field paths', (_) async { + test('ends before string field paths', () async { CollectionReference> collection = await initializeTest('endBefore-string'); await Future.wait([ @@ -731,7 +726,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends before string field paths with Iterable', (_) async { + test('ends before string field paths with Iterable', () async { CollectionReference> collection = await initializeTest('endBefore-string'); await Future.wait([ @@ -765,7 +760,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('ends before field paths', (_) async { + test('ends before field paths', () async { CollectionReference> collection = await initializeTest('endBefore-field-path'); await Future.wait([ @@ -800,8 +795,8 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('endbeforeDocument() ends before a document field value', - (_) async { + test('endbeforeDocument() ends before a document field value', + () async { CollectionReference> collection = await initializeTest('endBefore-document-field-value'); await Future.wait([ @@ -828,7 +823,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets('endBeforeDocument() ends before a document', (_) async { + test('endBeforeDocument() ends before a document', () async { CollectionReference> collection = await initializeTest('endBefore-document'); await Future.wait([ @@ -862,7 +857,7 @@ void runSecondDatabaseTests() { * Start after */ group('Query.startAfter{Document}()', () { - testWidgets('starts after string field paths', (_) async { + test('starts after string field paths', () async { CollectionReference> collection = await initializeTest('startAfter-string'); await Future.wait([ @@ -896,7 +891,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('starts after field paths', (_) async { + test('starts after field paths', () async { CollectionReference> collection = await initializeTest('startAfter-field-path'); await Future.wait([ @@ -931,8 +926,8 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc3')); }); - testWidgets('startAfterDocument() starts after a document field value', - (_) async { + test('startAfterDocument() starts after a document field value', + () async { CollectionReference> collection = await initializeTest('startAfter-document-field-value'); await Future.wait([ @@ -960,7 +955,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc1')); }); - testWidgets('startAfterDocument() starts after a document', (_) async { + test('startAfterDocument() starts after a document', () async { CollectionReference> collection = await initializeTest('startAfter-document'); await Future.wait([ @@ -994,7 +989,7 @@ void runSecondDatabaseTests() { */ group('Query.startAt/endAt', () { - testWidgets('starts at & ends at a document', (_) async { + test('starts at & ends at a document', () async { CollectionReference> collection = await initializeTest('start-end-string'); await Future.wait([ @@ -1020,7 +1015,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts at & ends before a document', (_) async { + test('starts at & ends before a document', () async { CollectionReference> collection = await initializeTest('start-end-string'); await Future.wait([ @@ -1046,7 +1041,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts after & ends at a document', (_) async { + test('starts after & ends at a document', () async { CollectionReference> collection = await initializeTest('start-end-field-path'); await Future.wait([ @@ -1072,7 +1067,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc3')); }); - testWidgets('starts a document and ends before document', (_) async { + test('starts a document and ends before document', () async { CollectionReference> collection = await initializeTest('start-end-document'); await Future.wait([ @@ -1110,7 +1105,7 @@ void runSecondDatabaseTests() { */ group('Query.limit{toLast}()', () { - testWidgets('limits documents', (_) async { + test('limits documents', () async { CollectionReference> collection = await initializeTest('limit'); await Future.wait([ @@ -1140,7 +1135,7 @@ void runSecondDatabaseTests() { expect(snapshot2.docs[1].id, equals('doc2')); }); - testWidgets('limits to last documents', (_) async { + test('limits to last documents', () async { CollectionReference> collection = await initializeTest('limitToLast'); await Future.wait([ @@ -1177,7 +1172,7 @@ void runSecondDatabaseTests() { * Order */ group('Query.orderBy()', () { - testWidgets('allows ordering by documentId', (_) async { + test('allows ordering by documentId', () async { CollectionReference> collection = await initializeTest('order-document-id'); @@ -1207,7 +1202,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[2].id, equals('doc3')); }); - testWidgets('orders async by default', (_) async { + test('orders async by default', () async { CollectionReference> collection = await initializeTest('order-asc'); @@ -1232,7 +1227,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[2].id, equals('doc1')); }); - testWidgets('orders descending', (_) async { + test('orders descending', () async { CollectionReference> collection = await initializeTest('order-desc'); await Future.wait([ @@ -1262,9 +1257,8 @@ void runSecondDatabaseTests() { */ group('Query.where()', () { - testWidgets( - 'returns documents when querying for properties that are not null', - (_) async { + test('returns documents when querying for properties that are not null', + () async { CollectionReference> collection = await initializeTest('not-null'); await Future.wait([ @@ -1287,9 +1281,9 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].id, equals('doc2')); }); - testWidgets( + test( 'returns documents when querying properties that are equal to null', - (_) async { + () async { CollectionReference> collection = await initializeTest('not-null'); await Future.wait([ @@ -1311,7 +1305,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[0].id, equals('doc3')); }); - testWidgets('returns with equal checks', (_) async { + test('returns with equal checks', () async { CollectionReference> collection = await initializeTest('where-equal'); int rand = Random().nextInt(9999); @@ -1337,7 +1331,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with not equal checks', (_) async { + test('returns with not equal checks', () async { CollectionReference> collection = await initializeTest('where-not-equal'); int rand = Random().nextInt(9999); @@ -1363,7 +1357,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with greater than checks', (_) async { + test('returns with greater than checks', () async { CollectionReference> collection = await initializeTest('where-greater-than'); int rand = Random().nextInt(9999); @@ -1392,7 +1386,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with greater than or equal to checks', (_) async { + test('returns with greater than or equal to checks', () async { CollectionReference> collection = await initializeTest('where-greater-than-equal'); int rand = Random().nextInt(9999); @@ -1421,7 +1415,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with less than checks', (_) async { + test('returns with less than checks', () async { CollectionReference> collection = await initializeTest('where-less-than'); int rand = Random().nextInt(9999); @@ -1447,7 +1441,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with less than equal checks', (_) async { + test('returns with less than equal checks', () async { CollectionReference> collection = await initializeTest('where-less-than'); int rand = Random().nextInt(9999); @@ -1476,7 +1470,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with array-contains filter', (_) async { + test('returns with array-contains filter', () async { CollectionReference> collection = await initializeTest('where-array-contains'); int rand = Random().nextInt(9999); @@ -1502,7 +1496,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with in filter', (_) async { + test('returns with in filter', () async { CollectionReference> collection = await initializeTest('where-in'); @@ -1531,7 +1525,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with in filter using Iterable', (_) async { + test('returns with in filter using Iterable', () async { CollectionReference> collection = await initializeTest('where-in-iterable'); @@ -1565,7 +1559,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with in filter using Set', (_) async { + test('returns with in filter using Set', () async { CollectionReference> collection = await initializeTest('where-in'); @@ -1594,7 +1588,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with not-in filter', (_) async { + test('returns with not-in filter', () async { CollectionReference> collection = await initializeTest('where-not-in'); @@ -1623,7 +1617,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with not-in filter with Iterable', (_) async { + test('returns with not-in filter with Iterable', () async { CollectionReference> collection = await initializeTest('where-not-in'); @@ -1652,7 +1646,7 @@ void runSecondDatabaseTests() { }); }); - testWidgets('returns with array-contains-any filter', (_) async { + test('returns with array-contains-any filter', () async { CollectionReference> collection = await initializeTest('where-array-contains-any'); @@ -1680,8 +1674,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs.length, equals(3)); }); - testWidgets('returns with array-contains-any filter using Set', - (_) async { + test('returns with array-contains-any filter using Set', () async { CollectionReference> collection = await initializeTest('where-array-contains-any'); @@ -1711,7 +1704,7 @@ void runSecondDatabaseTests() { // When documents have a key with a '.' in them, only a [FieldPath] // can access the value, rather than a raw string - testWidgets('returns where FieldPath', (_) async { + test('returns where FieldPath', () async { CollectionReference> collection = await initializeTest('where-field-path'); @@ -1746,7 +1739,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[1].get('foo'), equals('bar')); }); - testWidgets('returns results using FieldPath.documentId', (_) async { + test('returns results using FieldPath.documentId', () async { CollectionReference> collection = await initializeTest('where-field-path-document-id'); @@ -1768,7 +1761,7 @@ void runSecondDatabaseTests() { expect(snapshot.docs[0].get('foo'), equals('bar')); }); - testWidgets('returns an encoded DocumentReference', (_) async { + test('returns an encoded DocumentReference', () async { CollectionReference> collection = await initializeTest('where-document-reference'); @@ -1797,9 +1790,9 @@ void runSecondDatabaseTests() { }); group('Query.where() with Filter class', () { - testWidgets( + test( 'Can combine `arrayContainsAny` & `isNotEqualTo` in multiple disjunctive queries', - (_) async { + () async { CollectionReference> collection = await initializeTest('multiple-disjunctive-queries'); @@ -1837,9 +1830,9 @@ void runSecondDatabaseTests() { skip: true, ); - testWidgets( + test( 'Can combine `arrayContainsAny` & `isNotEqualTo` in multiple conjunctive queries', - (_) async { + () async { CollectionReference> collection = await initializeTest( 'array-contain-not-equal-conjunctive-queries', @@ -1878,7 +1871,7 @@ void runSecondDatabaseTests() { skip: true, ); - testWidgets('isEqualTo filter', (_) async { + test('isEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isequalto'); await Future.wait([ @@ -1898,7 +1891,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('isNotEqualTo filter', (_) async { + test('isNotEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isnotequalto'); await Future.wait([ @@ -1917,7 +1910,7 @@ void runSecondDatabaseTests() { expect(results.docs[0].id, equals('doc3')); }); - testWidgets('isLessThan filter', (_) async { + test('isLessThan filter', () async { CollectionReference> collection = await initializeTest('where-filter-islessthan'); await Future.wait([ @@ -1936,7 +1929,7 @@ void runSecondDatabaseTests() { expect(results.docs[0].id, equals('doc1')); }); - testWidgets('isLessThanOrEqualTo filter', (_) async { + test('isLessThanOrEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-islessthanequalto'); await Future.wait([ @@ -1956,7 +1949,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('isGreaterThan filter', (_) async { + test('isGreaterThan filter', () async { CollectionReference> collection = await initializeTest('where-filter-isgreaterthan'); await Future.wait([ @@ -1976,7 +1969,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('isGreaterThanOrEqualTo filter', (_) async { + test('isGreaterThanOrEqualTo filter', () async { CollectionReference> collection = await initializeTest('where-filter-isgreaterthanequalto'); await Future.wait([ @@ -1996,7 +1989,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('arrayContains filter', (_) async { + test('arrayContains filter', () async { CollectionReference> collection = await initializeTest('where-filter-arraycontains'); await Future.wait([ @@ -2022,7 +2015,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc2')); }); - testWidgets('arrayContainsAny filter', (_) async { + test('arrayContainsAny filter', () async { CollectionReference> collection = await initializeTest('where-filter-arraycontainsany'); await Future.wait([ @@ -2046,7 +2039,7 @@ void runSecondDatabaseTests() { expect(results.docs.length, equals(3)); }); - testWidgets('whereIn filter', (_) async { + test('whereIn filter', () async { CollectionReference> collection = await initializeTest('where-filter-wherein'); await Future.wait([ @@ -2066,7 +2059,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].id, equals('doc3')); }); - testWidgets('whereNotIn filter', (_) async { + test('whereNotIn filter', () async { CollectionReference> collection = await initializeTest('where-filter-wherenotin'); await Future.wait([ @@ -2085,7 +2078,7 @@ void runSecondDatabaseTests() { expect(results.docs[0].id, equals('doc2')); }); - testWidgets('isNull filter', (_) async { + test('isNull filter', () async { CollectionReference> collection = await initializeTest('where-filter-isnull'); await Future.wait([ @@ -2104,7 +2097,7 @@ void runSecondDatabaseTests() { expect(results.docs[0].id, equals('doc2')); }); - testWidgets('endAt filter', (_) async { + test('endAt filter', () async { CollectionReference> collection = await initializeTest('endat-filter'); await Future.wait([ @@ -2126,7 +2119,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('endBefore filter', (_) async { + test('endBefore filter', () async { CollectionReference> collection = await initializeTest('endbefore-filter'); await Future.wait([ @@ -2149,7 +2142,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('endBeforeDocument filter', (_) async { + test('endBeforeDocument filter', () async { CollectionReference> collection = await initializeTest('endbeforedocument-filter'); await Future.wait([ @@ -2175,7 +2168,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('limit filter', (_) async { + test('limit filter', () async { CollectionReference> collection = await initializeTest('limit-filter'); await Future.wait([ @@ -2199,7 +2192,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('C')); }); - testWidgets('limitToLast filter', (_) async { + test('limitToLast filter', () async { CollectionReference> collection = await initializeTest('limittolast-filter'); await Future.wait([ @@ -2223,7 +2216,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('E')); }); - testWidgets('orderBy filter', (_) async { + test('orderBy filter', () async { CollectionReference> collection = await initializeTest('orderby-filter'); await Future.wait([ @@ -2248,7 +2241,7 @@ void runSecondDatabaseTests() { expect(results.docs[3].data()['title'], equals('B')); }); - testWidgets('startAfter filter', (_) async { + test('startAfter filter', () async { CollectionReference> collection = await initializeTest('startafter-filter'); await Future.wait([ @@ -2271,7 +2264,7 @@ void runSecondDatabaseTests() { expect(results.docs[1].data()['title'], equals('E')); }); - testWidgets('startAfterDocument filter', (_) async { + test('startAfterDocument filter', () async { CollectionReference> collection = await initializeTest('startafterdocument-filter'); await Future.wait([ @@ -2298,7 +2291,7 @@ void runSecondDatabaseTests() { expect(results.docs[2].data()['title'], equals('E')); }); - testWidgets('startAt filter', (_) async { + test('startAt filter', () async { CollectionReference> collection = await initializeTest('startat-filter'); await Future.wait([ @@ -2323,7 +2316,7 @@ void runSecondDatabaseTests() { expect(results.docs[3].data()['title'], equals('E')); }); - testWidgets('startAtDocument filter', (_) async { + test('startAtDocument filter', () async { CollectionReference> collection = await initializeTest('startatdocument-filter'); await Future.wait([ @@ -2353,9 +2346,9 @@ void runSecondDatabaseTests() { }); group('withConverter', () { - testWidgets( + test( 'from a query instead of collection', - (_) async { + () async { final collection = await initializeTest('foo'); final query = collection // @@ -2404,9 +2397,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'from a Filter query instead of collection', - (_) async { + () async { final collection = await initializeTest('foo'); final query = collection // @@ -2455,9 +2448,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'snapshots', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2503,9 +2496,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'get', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2531,9 +2524,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'orderBy', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2558,9 +2551,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'limit', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2587,9 +2580,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'limitToLast', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2616,7 +2609,7 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets('endAt', (_) async { + test('endAt', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2641,7 +2634,7 @@ void runSecondDatabaseTests() { ); }); - testWidgets('endAt with Iterable', (_) async { + test('endAt with Iterable', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2666,9 +2659,9 @@ void runSecondDatabaseTests() { ); }); - testWidgets( + test( 'endAtDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2696,7 +2689,7 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets('endBefore', (_) async { + test('endBefore', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2718,7 +2711,7 @@ void runSecondDatabaseTests() { ); }); - testWidgets('endBefore with Iterable', (_) async { + test('endBefore with Iterable', () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2740,9 +2733,9 @@ void runSecondDatabaseTests() { ); }); - testWidgets( + test( 'endBeforeDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2767,9 +2760,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAt', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2797,9 +2790,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAt with Iterable', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2827,9 +2820,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAtDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2857,9 +2850,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfter', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2884,9 +2877,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfter with Iterable', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2911,9 +2904,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'startAfterDocument', - (_) async { + () async { final collection = await initializeTest('foo'); final converted = collection.withConverter( @@ -2938,9 +2931,9 @@ void runSecondDatabaseTests() { timeout: const Timeout.factor(3), ); - testWidgets( + test( 'count()', - (_) async { + () async { final collection = await initializeTest('count'); await Future.wait([ @@ -2959,9 +2952,9 @@ void runSecondDatabaseTests() { }, ); - testWidgets( + test( 'count() with query', - (_) async { + () async { final collection = await initializeTest('count'); await Future.wait([ @@ -2983,9 +2976,9 @@ void runSecondDatabaseTests() { }); group('startAfterDocument', () { - testWidgets( + test( 'startAfterDocument() accept DocumentReference in query parameters', - (_) async { + () async { final collection = await initializeTest('start-after-document'); final doc1 = collection.doc('1'); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/settings_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/settings_e2e.dart index b31a32b8f082..c6d0014d0270 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/settings_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/settings_e2e.dart @@ -28,7 +28,7 @@ void runSettingsTest() { return firestore.settings = firestoreSettings; } - testWidgets('checks if long polling settings were applied', (_) async { + test('checks if long polling settings were applied', () async { Settings settings = await initializeTest(); expect(settings.webExperimentalForceLongPolling, true); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/snapshot_metadata_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/snapshot_metadata_e2e.dart index 04c640ec43ca..a6bb69e5a0ca 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/snapshot_metadata_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/snapshot_metadata_e2e.dart @@ -27,8 +27,7 @@ void runSnapshotMetadataTests() { return collection; } - testWidgets('a snapshot returns the correct [isFromCache] value', - (_) async { + test('a snapshot returns the correct [isFromCache] value', () async { CollectionReference collection = await initializeTest('snapshot-metadata-is-from-cache'); QuerySnapshot qs = diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/timestamp_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/timestamp_e2e.dart index 2ba49105e876..c72564cf5d45 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/timestamp_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/timestamp_e2e.dart @@ -21,7 +21,7 @@ void runTimestampTests() { return firestore.doc(prefixedPath); } - testWidgets('sets a $Timestamp & returns one', (_) async { + test('sets a $Timestamp & returns one', () async { DocumentReference> doc = await initializeTest('timestamp'); DateTime date = DateTime.utc(3000); @@ -37,7 +37,7 @@ void runTimestampTests() { ); }); - testWidgets('updates a $Timestamp & returns', (_) async { + test('updates a $Timestamp & returns', () async { DocumentReference> doc = await initializeTest('geo-point-update'); DateTime date = DateTime.utc(3000, 01, 02); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/transaction_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/transaction_e2e.dart index 7a0abdefae44..6db5fb6efdc6 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/transaction_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/transaction_e2e.dart @@ -26,7 +26,7 @@ void runTransactionTests() { return firestore.doc(prefixedPath); } - testWidgets('works with withConverter', (_) async { + test('works with withConverter', () async { DocumentReference> rawDoc = await initializeTest('with-converter-batch'); @@ -60,7 +60,7 @@ void runTransactionTests() { expect(await doc.get().then((s) => s.data()), 0); }); - testWidgets('should resolve with user value', (_) async { + test('should resolve with user value', () async { int randomValue = Random().nextInt(9999); int response = await firestore .runTransaction((Transaction transaction) async { @@ -69,7 +69,7 @@ void runTransactionTests() { expect(response, equals(randomValue)); }); - testWidgets('should abort if thrown and not continue', (_) async { + test('should abort if thrown and not continue', () async { DocumentReference> documentReference = await initializeTest('transaction-abort'); @@ -91,9 +91,9 @@ void runTransactionTests() { } }); - testWidgets( + test( 'should not collide if number of maxAttempts is enough', - (_) async { + () async { DocumentReference> doc1 = await initializeTest('transaction-maxAttempts-1'); @@ -126,8 +126,7 @@ void runTransactionTests() { retry: 2, ); - testWidgets('should collide if number of maxAttempts is too low', - (_) async { + test('should collide if number of maxAttempts is too low', () async { DocumentReference> doc1 = await initializeTest('transaction-maxAttempts-2'); @@ -161,7 +160,7 @@ void runTransactionTests() { ); }); - testWidgets('runs multiple transactions in parallel', (_) async { + test('runs multiple transactions in parallel', () async { DocumentReference> doc1 = await initializeTest('transaction-multi-1'); DocumentReference> doc2 = @@ -189,7 +188,7 @@ void runTransactionTests() { expect(snapshot2.data()!['test'], equals('value4')); }); - testWidgets('should abort if timeout is exceeded', (_) async { + test('should abort if timeout is exceeded', () async { await expectLater( firestore.runTransaction( (Transaction transaction) => @@ -203,7 +202,7 @@ void runTransactionTests() { ); }); - testWidgets('should throw with exception', (_) async { + test('should throw with exception', () async { try { await firestore.runTransaction((Transaction transaction) async { throw StateError('foo'); @@ -218,9 +217,8 @@ void runTransactionTests() { } }); - testWidgets( - 'should throw a native error, and convert to a [FirebaseException]', - (_) async { + test('should throw a native error, and convert to a [FirebaseException]', + () async { DocumentReference> documentReference = firestore.doc('not-allowed/document'); @@ -238,7 +236,7 @@ void runTransactionTests() { }); group('Transaction.get()', () { - testWidgets('should throw if get is called after a command', (_) async { + test('should throw if get is called after a command', () async { DocumentReference> documentReference = firestore.doc('flutter-tests/foo'); @@ -252,9 +250,9 @@ void runTransactionTests() { ); }); - testWidgets( + test( 'should throw a native error, and convert to a [FirebaseException]', - (_) async { + () async { DocumentReference> documentReference = firestore.doc('not-allowed/document'); @@ -273,7 +271,7 @@ void runTransactionTests() { // ignore: todo // TODO(Salakar): Test seems to fail sometimes. Will look at in a future PR. - // testWidgets('support returning any value, e.g. a [DocumentSnapshot]', (_) async { + // test('support returning any value, e.g. a [DocumentSnapshot]', () async { // DocumentReference> documentReference = // await initializeTest('transaction-get'); @@ -291,7 +289,7 @@ void runTransactionTests() { }); group('Transaction.delete()', () { - testWidgets('should delete a document', (_) async { + test('should delete a document', () async { DocumentReference> documentReference = await initializeTest('transaction-delete'); @@ -308,7 +306,7 @@ void runTransactionTests() { }); group('Transaction.update()', () { - testWidgets('should update a document', (_) async { + test('should update a document', () async { DocumentReference> documentReference = await initializeTest('transaction-update'); @@ -331,7 +329,7 @@ void runTransactionTests() { }); group('Transaction.set()', () { - testWidgets('sets a document', (_) async { + test('sets a document', () async { DocumentReference> documentReference = await initializeTest('transaction-set'); @@ -354,7 +352,7 @@ void runTransactionTests() { ); }); - testWidgets('merges a document with set', (_) async { + test('merges a document with set', () async { DocumentReference> documentReference = await initializeTest('transaction-set-merge'); @@ -377,7 +375,7 @@ void runTransactionTests() { expect(snapshot.data()!['foo'], equals('bar')); }); - testWidgets('merges fields a document with set', (_) async { + test('merges fields a document with set', () async { DocumentReference> documentReference = await initializeTest('transaction-set-merge-fields'); @@ -406,7 +404,7 @@ void runTransactionTests() { }); }); - testWidgets('runs all commands in a single transaction', (_) async { + test('runs all commands in a single transaction', () async { DocumentReference> documentReference = await initializeTest('transaction-all'); @@ -448,9 +446,9 @@ void runTransactionTests() { }); // TODO(Lyokone): adding auth make some tests fails in macOS - // testWidgets( + // test( // 'should not fail to complete transaction if user is authenticated', - // (_) async { + // () async { // DocumentReference> doc1 = // await initializeTest('transaction-authentified-1'); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/web_snapshot_listeners.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/web_snapshot_listeners.dart index b47a596fc60f..db74e8a7d626 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/web_snapshot_listeners.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/web_snapshot_listeners.dart @@ -30,9 +30,9 @@ void runWebSnapshotListenersTests() { ]); }); - testWidgets( + test( 'document snapshot listeners in debug', - (_) async { + () async { Completer completer = Completer(); Completer completer2 = Completer(); Completer completer3 = Completer(); @@ -68,9 +68,9 @@ void runWebSnapshotListenersTests() { skip: !kIsWeb, ); - testWidgets( + test( 'document snapshot listeners with different doc refs in debug', - (_) async { + () async { Completer completer = Completer(); Completer completer2 = Completer(); Completer completer3 = Completer(); @@ -116,9 +116,9 @@ void runWebSnapshotListenersTests() { skip: !kIsWeb, ); - testWidgets( + test( 'query snapshot listeners in debug', - (_) async { + () async { Completer completer = Completer(); Completer completer2 = Completer(); Completer completer3 = Completer(); @@ -153,9 +153,9 @@ void runWebSnapshotListenersTests() { skip: !kIsWeb, ); - testWidgets( + test( 'snapshot in sync listeners in debug', - (_) async { + () async { Completer completer = Completer(); Completer completer2 = Completer(); Completer completer3 = Completer(); diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/write_batch_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/write_batch_e2e.dart index 49abaaa407a7..fdb931dabb6d 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/write_batch_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/write_batch_e2e.dart @@ -28,7 +28,7 @@ void runWriteBatchTests() { return collection; } - testWidgets('works with withConverter', (_) async { + test('works with withConverter', () async { CollectionReference> collection = await initializeTest('with-converter-batch'); WriteBatch batch = firestore.batch(); @@ -70,7 +70,7 @@ void runWriteBatchTests() { expect(snapshot.exists, false); }); - testWidgets('performs batch operations', (_) async { + test('performs batch operations', () async { CollectionReference> collection = await initializeTest('write-batch-ops'); WriteBatch batch = firestore.batch(); From 1ef2044a7a9f2004f933147a8494fb82fa4c3c26 Mon Sep 17 00:00:00 2001 From: Maneesh Tewani Date: Tue, 19 Nov 2024 08:53:15 -0800 Subject: [PATCH 7/7] fix(fdc): Don't throw when FirebaseAuth is unable to get an ID Token (#16711) --- .../lib/src/core/ref.dart | 23 +++++++---- .../test/src/core/ref_test.dart | 38 +++++++++++-------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/packages/firebase_data_connect/firebase_data_connect/lib/src/core/ref.dart b/packages/firebase_data_connect/firebase_data_connect/lib/src/core/ref.dart index 68f528ceff78..e5a021d0c75b 100644 --- a/packages/firebase_data_connect/firebase_data_connect/lib/src/core/ref.dart +++ b/packages/firebase_data_connect/firebase_data_connect/lib/src/core/ref.dart @@ -48,8 +48,13 @@ abstract class OperationRef { Future> execute(); Future _shouldRetry() async { - String? newToken = - await this.dataConnect.auth?.currentUser?.getIdToken(false); + String? newToken; + try { + newToken = await this.dataConnect.auth?.currentUser?.getIdToken(false); + } catch (e) { + // Don't retry if there was an issue getting the ID Token. + log("There was an error attempting to retrieve the ID Token: ${e.toString()}"); + } bool shouldRetry = newToken != null && _lastToken != newToken; _lastToken = newToken; return shouldRetry; @@ -97,12 +102,14 @@ class QueryManager { return; } StreamController stream = trackedQueries[operationName]![key]!; - // TODO(mtewani): Prevent this from getting called multiple times. - stream.onCancel = () => stream.close(); - if (error != null) { - stream.addError(error); - } else { - stream.add(QueryResult(dataConnect, data as Data, ref)); + + if (!stream.isClosed) { + if (error != null) { + stream.addError(error); + } else { + stream + .add(QueryResult(dataConnect, data as Data, ref)); + } } } } diff --git a/packages/firebase_data_connect/firebase_data_connect/test/src/core/ref_test.dart b/packages/firebase_data_connect/firebase_data_connect/test/src/core/ref_test.dart index d6a66907499d..206f76668c25 100644 --- a/packages/firebase_data_connect/firebase_data_connect/test/src/core/ref_test.dart +++ b/packages/firebase_data_connect/firebase_data_connect/test/src/core/ref_test.dart @@ -32,20 +32,7 @@ class MockDataConnectTransport extends Mock implements DataConnectTransport {} class MockFirebaseDataConnect extends Mock implements FirebaseDataConnect {} -class DCMockUser extends Mock implements User { - int count = 0; - List tokens = ['invalid-token', 'valid-token']; - @override - Future getIdToken([bool forceRefresh = false]) { - // First return an invalid token, then return a valid token - return Future.value(tokens[count++]); - } -} - -class MockFirebaseAuth extends Mock implements FirebaseAuth { - @override - User? get currentUser => DCMockUser(); -} +class MockFirebaseAuth extends Mock implements FirebaseAuth {} class MockQueryManager extends Mock implements QueryManager {} @@ -122,10 +109,15 @@ void main() { late Serializer serializer; late MockClient mockHttpClient; late Deserializer deserializer; + late MockFirebaseAuth auth; + late MockUser mockUser; setUp(() { mockDataConnect = MockFirebaseDataConnect(); - when(mockDataConnect.auth).thenReturn(MockFirebaseAuth()); + auth = MockFirebaseAuth(); + mockUser = MockUser(); + when(mockDataConnect.auth).thenReturn(auth); + when(auth.currentUser).thenReturn(mockUser); mockHttpClient = MockClient(); transport = RestTransport( TransportOptions('testhost', 443, true), @@ -142,6 +134,17 @@ void main() { transport.setHttp(mockHttpClient); mockDataConnect.transport = transport; }); + test('executeQuery should gracefully handle getIdToken failures', () async { + final deserializer = (String data) => 'Deserialized Data'; + final mockResponseSuccess = http.Response('{"success": true}', 200); + when(mockUser.getIdToken()).thenThrow(Exception('Auth error')); + QueryRef ref = QueryRef(mockDataConnect, 'operation', transport, + deserializer, QueryManager(mockDataConnect), emptySerializer, null); + when(mockHttpClient.post(any, + headers: anyNamed('headers'), body: anyNamed('body'))) + .thenAnswer((_) async => mockResponseSuccess); + await ref.execute(); + }); test( 'query should forceRefresh on ID token if the first request is unauthorized', () async { @@ -149,8 +152,13 @@ void main() { final mockResponseSuccess = http.Response('{"success": true}', 200); final deserializer = (String data) => 'Deserialized Data'; int count = 0; + int idTokenCount = 0; QueryRef ref = QueryRef(mockDataConnect, 'operation', transport, deserializer, QueryManager(mockDataConnect), emptySerializer, null); + when(mockUser.getIdToken()).thenAnswer((invocation) => [ + Future.value('invalid-token'), + Future.value('valid-token') + ][idTokenCount++]); when(mockHttpClient.post(any, headers: anyNamed('headers'), body: anyNamed('body')))