Skip to content

Commit

Permalink
fix: update versions
Browse files Browse the repository at this point in the history
  • Loading branch information
HYACCCINT committed Sep 21, 2023
1 parent c8a1193 commit ef3a476
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 6 deletions.
3 changes: 3 additions & 0 deletions firestore/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
3 changes: 3 additions & 0 deletions firestore/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand Down
3 changes: 3 additions & 0 deletions firestore/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.10'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
18 changes: 18 additions & 0 deletions firestore/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"emulators": {
"auth": {
"port": 9099
},
"firestore": {
"port": 8080
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
42 changes: 42 additions & 0 deletions firestore/integration_test/friendly_eats_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firestore/firebase_options.dart';
import 'package:firestore/src/app.dart';
import 'package:firestore/src/widgets/restaurant_card.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

bool USE_FIRESTORE_EMULATOR = true;

Future<void> main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
final hostUrl = defaultTargetPlatform == TargetPlatform.android ? "10.0.2.2" : "localhost";
if (USE_FIRESTORE_EMULATOR) {
FirebaseFirestore.instance.useFirestoreEmulator(hostUrl, 8080);
await FirebaseAuth.instance.useAuthEmulator(hostUrl, 9099);
await FirebaseAuth.instance.signInAnonymously();
}
group('Integration Tests', () {
testWidgets('Test empty home page', (tester) async {
await tester.pumpWidget(FriendlyEatsApp());
expect(find.text('FriendlyEats has no restaurants yet!'), findsOneWidget);
expect(find.text('ADD SOME'), findsOneWidget);
await tester.tap(find.text('ADD SOME').first);
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byIcon(Icons.star), findsWidgets);
});
testWidgets('view restaurant page', (tester) async {
await tester.pumpWidget(FriendlyEatsApp());
await tester.tap(find.byType(RestaurantCard));
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Add Random Reviews'), findsOneWidget);
await tester.tap(find.text('Add Random Reviews'));
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Anonymous User'), findsWidgets);
});
});
}
11 changes: 11 additions & 0 deletions firestore/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

import 'package:flutter/foundation.dart';
import 'firebase_options.dart';
import 'src/app.dart';

Expand All @@ -11,6 +13,15 @@ void main() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
if (kDebugMode) {
try {
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
} catch (e) {
// ignore: avoid_print
print(e);
}
}

// required to interact with Firestore due to security Rules
await FirebaseAuth.instance.signInAnonymously();
Expand Down
6 changes: 3 additions & 3 deletions firestore/lib/src/data/restaurant_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';

import '../model/filter.dart';
import '../model/filter.dart' as SearchFilter;
import '../model/restaurant.dart';
import '../model/review.dart';

Expand All @@ -29,7 +29,7 @@ abstract class RestaurantProvider {
{required String restaurantId, required Review review});
void addRestaurantsBatch(List<Restaurant> restaurants);
void loadAllRestaurants();
void loadFilteredRestaurants(Filter filter);
void loadFilteredRestaurants(SearchFilter.Filter filter);
Future<Restaurant> getRestaurantById(String restaurantId);
void dispose();
}
Expand Down Expand Up @@ -116,7 +116,7 @@ class FirestoreRestaurantProvider implements RestaurantProvider {
}

@override
void loadFilteredRestaurants(Filter filter) {
void loadFilteredRestaurants(SearchFilter.Filter filter) {
Query collection = FirebaseFirestore.instance.collection('restaurants');
if (filter.category != null) {
collection = collection.where('category', isEqualTo: filter.category);
Expand Down
17 changes: 14 additions & 3 deletions firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_core: ^1.15.0
firebase_auth: ^3.3.15
cloud_firestore: ^3.1.13
firebase_core: ^2.16.0
firebase_auth: ^4.10.0
cloud_firestore: ^4.9.2
provider: ^6.0.5
go_router: ^10.2.0
http: ^1.1.0
fake_cloud_firestore: ^2.4.1+1

dev_dependencies:
pedantic: ^1.9.0
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: ^1.24.3
mockito: ^5.4.2
build_runner: ^2.4.6

# The following section is specific to Flutter.
flutter:
Expand Down
3 changes: 3 additions & 0 deletions firestore/test_driver/integration_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
6 changes: 6 additions & 0 deletions firestore/windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

#include "generated_plugin_registrant.h"

#include <firebase_auth/firebase_auth_plugin_c_api.h>
#include <firebase_core/firebase_core_plugin_c_api.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
FirebaseAuthPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
}

0 comments on commit ef3a476

Please sign in to comment.