From 7db1889b2d6d9dd7d6c30b832247646eee33b7bf Mon Sep 17 00:00:00 2001
From: Abhishek Saini <78199221+Abhisheksainii@users.noreply.github.com>
Date: Mon, 8 Jan 2024 04:26:06 +0530
Subject: [PATCH] fix: Removed all references to Google firebase (#2257)
* feature: Removed all references to Google firebase
* formatted firebase_mocks.dart
* removed ignore directive for custom lint rule
* formatted login_view_model file
* removal of commented code
* removed fcmToken test
* avoid dynamic calls check passed
* format check
* fixed linting issue
* added documentation for event_queries file
* format check
---
android/app/src/main/AndroidManifest.xml | 3 -
lib/firebase_options.dart | 93 ----
lib/main.dart | 156 -------
lib/services/database_mutation_functions.dart | 12 -
lib/utils/event_queries.dart | 1 +
lib/utils/queries.dart | 32 +-
.../login_view_model.dart | 38 +-
pubspec.lock | 82 +---
pubspec.yaml | 4 -
test/helpers/setup_firebase_mocks.dart | 402 +++++++++---------
test/utils_tests/queries_test.dart | 10 -
.../login_view_model_test.dart | 23 -
.../events/edit_event_page_test.dart | 5 -
.../pre_auth_screens/splash_screen_test.dart | 6 -
14 files changed, 218 insertions(+), 649 deletions(-)
delete mode 100644 lib/firebase_options.dart
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 6a17167af6..937b311922 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -64,9 +64,6 @@
-
androidFirebaseOptions,
- Map iosFirebaseOptions,
- ) {
- if (kIsWeb) {
- throw UnsupportedError(
- 'DefaultFirebaseOptions have not been configured for web - '
- 'you can reconfigure this by running the FlutterFire CLI again.',
- );
- }
- switch (defaultTargetPlatform) {
- case TargetPlatform.android:
- return android(androidFirebaseOptions);
- case TargetPlatform.iOS:
- return ios(iosFirebaseOptions);
- case TargetPlatform.macOS:
- throw UnsupportedError(
- 'DefaultFirebaseOptions have not been configured for macos - '
- 'you can reconfigure this by running the FlutterFire CLI again.',
- );
- default:
- throw UnsupportedError(
- 'DefaultFirebaseOptions are not supported for this platform.',
- );
- }
- }
-
- /// Scaffolds androidFirebaseOptions around FirebaseOptions.
- ///
- /// **params**:
- /// * `androidFirebaseOptions`: The options which we want to scaffold
- ///
- /// **returns**:
- /// * `FirebaseOptions`: Scaffolded FirebaseOptions
- static FirebaseOptions android(Map androidFirebaseOptions) =>
- FirebaseOptions(
- apiKey: androidFirebaseOptions['apiKey'] as String,
- appId: androidFirebaseOptions['appId'] as String,
- messagingSenderId:
- androidFirebaseOptions['messagingSenderId'] as String,
- projectId: androidFirebaseOptions['projectId'] as String,
- storageBucket: androidFirebaseOptions['storageBucket'] as String,
- );
-
- /// Scaffolds iosFirebaseOptions around FirebaseOptions.
- ///
- /// more_info_if_required
- ///
- /// **params**:
- /// * `iosFirebaseOptions`: The options which we want to scaffold
- ///
- /// **returns**:
- /// * `FirebaseOptions`: Scaffolded FirebaseOptions
- static FirebaseOptions ios(Map iosFirebaseOptions) =>
- FirebaseOptions(
- apiKey: iosFirebaseOptions['apiKey'] as String,
- appId: iosFirebaseOptions['appId'] as String,
- messagingSenderId: iosFirebaseOptions['messagingSenderId'] as String,
- projectId: iosFirebaseOptions['projectId'] as String,
- storageBucket: iosFirebaseOptions['storageBucket'] as String,
- iosClientId: iosFirebaseOptions['iosClientId'] as String,
- iosBundleId: iosFirebaseOptions['iosBundleId'] as String,
- );
-}
diff --git a/lib/main.dart b/lib/main.dart
index 4ed80df749..f0e11a8d39 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,11 +1,7 @@
import 'dart:io';
-import 'package:firebase_core/firebase_core.dart';
-import 'package:firebase_messaging/firebase_messaging.dart';
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' as fs;
-import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart' as path;
@@ -13,7 +9,6 @@ import 'package:provider/provider.dart';
import 'package:quick_actions/quick_actions.dart';
import 'package:talawa/constants/custom_theme.dart';
import 'package:talawa/constants/quick_actions.dart';
-import 'package:talawa/firebase_options.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/models/asymetric_keys/asymetric_keys.dart';
import 'package:talawa/models/organization/org_info.dart';
@@ -26,51 +21,6 @@ import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/view_model/theme_view_model.dart';
import 'package:talawa/views/base_view.dart';
-/// Define a top-level named handler which background/terminated messages will call.
-///
-/// To verify things are working, check out the native platform logs.
-/// **params**:
-/// * `message`: incoming messsage.
-///
-/// **returns**:
-/// * `Future`: promise that will be fulfilled message background activities are successful.
-Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
- // If you're going to use other Firebase services in the background, such as Firestore,
- // make sure you call `initializeApp` before using other Firebase services.
- final Directory dir = await path.getApplicationDocumentsDirectory();
- Hive.init(dir.path);
- await setUpFirebaseKeys();
- await setUpFirebase();
-}
-
-/// Initializes the firebase in the app according to the userplatform (android/iOS).
-///
-/// **params**:
-/// None
-///
-/// **returns**:
-/// * `Future`: promise that will be fulfilled Firebase is setted up in app.
-Future setUpFirebase() async {
- await Firebase.initializeApp(
- options: DefaultFirebaseOptions.currentPlatform(
- androidFirebaseOptions,
- iosFirebaseOptions,
- ),
- );
-}
-
-/// HashMap of Firebase options for android.
-late Map androidFirebaseOptions;
-
-/// HashMap of Firebase options for android.
-late Map iosFirebaseOptions;
-
-/// Create a [AndroidNotificationChannel] for heads up notifications.
-late AndroidNotificationChannel channel;
-
-/// Initialize the [FlutterLocalNotificationsPlugin] package.
-late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
-
/// First function to initialize the application, invoked automatically.
///
/// **params**:
@@ -82,26 +32,6 @@ Future main() async {
// Returns an instance of the binding that implements WidgetsBinding.
WidgetsFlutterBinding.ensureInitialized();
- if (!kIsWeb) {
- channel = const AndroidNotificationChannel(
- 'high_importance_channel', // id
- 'High Importance Notifications', // title
- description:
- 'This channel is used for important notifications.', // description
- importance: Importance.high,
- );
-
- flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
-
- // Create an Android Notification Channel.
- // We use this channel in the `AndroidManifest.xml` file to override the
- // default FCM channel to enable heads up notifications.
- await flutterLocalNotificationsPlugin
- .resolvePlatformSpecificImplementation<
- AndroidFlutterLocalNotificationsPlugin>()
- ?.createNotificationChannel(channel);
- }
-
final Directory dir = await path.getApplicationDocumentsDirectory();
Hive
..init(dir.path)
@@ -115,52 +45,11 @@ Future main() async {
await Hive.openBox('pluginBox');
await Hive.openBox('url');
- final urlBox = await Hive.openBox('url');
-
- try {
- if (urlBox.get('url') != null) {
- await setUpFirebaseKeys();
-
- await setUpFirebase();
- await setUpFirebaseMessaging();
- }
- } catch (e) {
- print("Firebase not working");
- }
-
setupLocator();
// The runApp() function takes the given Widget and makes it the root of the widget tree.
runApp(MyApp());
}
-/// Initializes the firebase keys in the app according to the userplatform (android/iOS).
-///
-/// **params**:
-/// None
-///
-/// **returns**:
-/// * `Future`: promise that will be fulfilled Firebase keys are setted up.
-Future setUpFirebaseKeys() async {
- final androidFirebaseOptionsBox =
- await Hive.openBox('androidFirebaseOptions');
- final androidFirebaseOptionsMap = androidFirebaseOptionsBox
- .get('androidFirebaseOptions') as Map?;
-
- final iosFirebaseOptionsBox = await Hive.openBox('iosFirebaseOptions');
- final iosFirebaseOptionsMap =
- iosFirebaseOptionsBox.get('iosFirebaseOptions') as Map?;
- if (androidFirebaseOptionsMap != null) {
- androidFirebaseOptions = androidFirebaseOptionsMap.map((key, value) {
- return MapEntry(key.toString(), value);
- });
- }
- if (iosFirebaseOptionsMap != null) {
- iosFirebaseOptions = iosFirebaseOptionsMap.map((key, value) {
- return MapEntry(key.toString(), value);
- });
- }
-}
-
/// Main widget that sets up the quick actions, internationalization, routing , notifications.
class MyApp extends StatefulWidget {
// This widget is the root of your application.
@@ -332,48 +221,3 @@ class DemoViewModel extends BaseModel {
/// * `String`: title of the model
String get title => _title;
}
-
-/// Set up firebase instance, enbables messaging,listens to icoming messages.
-///
-/// **params**:
-/// None
-///
-/// **returns**:
-/// * `Future`: promise that will be fulfilled Firebase is setted up.
-Future setUpFirebaseMessaging() async {
- /// Set the background messaging handler early on, as a named top-level function
- FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
-
- // Update the iOS foreground notification presentation options to allow heads up notifications.
- await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
- alert: true,
- badge: true,
- sound: true,
- );
-
- FirebaseMessaging.instance
- .getInitialMessage()
- .then((RemoteMessage? message) {});
-
- FirebaseMessaging.onMessage.listen((RemoteMessage message) {
- final RemoteNotification? notification = message.notification;
- final AndroidNotification? android = message.notification?.android;
- if (notification != null && android != null && !kIsWeb) {
- flutterLocalNotificationsPlugin.show(
- notification.hashCode,
- notification.title,
- notification.body,
- NotificationDetails(
- android: AndroidNotificationDetails(
- channel.id,
- channel.name,
- channelDescription: channel.description,
- icon: 'launch_background',
- ),
- ),
- );
- }
- });
-
- FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {});
-}
diff --git a/lib/services/database_mutation_functions.dart b/lib/services/database_mutation_functions.dart
index 03d6b1d95a..d9aeec90e4 100644
--- a/lib/services/database_mutation_functions.dart
+++ b/lib/services/database_mutation_functions.dart
@@ -191,18 +191,6 @@ class DataBaseMutationFunctions {
}
return false;
}
- if (exception.graphqlErrors[i].message ==
- notifFeatureNotInstalled.message) {
- if (showSnackBar) {
- WidgetsBinding.instance.addPostFrameCallback(
- (_) => navigationService.showTalawaErrorDialog(
- "Notification Feature is not installed",
- MessageType.error,
- ),
- );
- }
- return false;
- }
}
// if the error is unknown
diff --git a/lib/utils/event_queries.dart b/lib/utils/event_queries.dart
index 14c9e82e52..6944de83fa 100644
--- a/lib/utils/event_queries.dart
+++ b/lib/utils/event_queries.dart
@@ -10,6 +10,7 @@ class EventQueries {
///
/// This function generates a GraphQL query string to retrieve events
/// based on the provided organization ID.
+
String fetchOrgEvents(String orgId) {
return """
query {
diff --git a/lib/utils/queries.dart b/lib/utils/queries.dart
index 8a91298f44..446c66880f 100644
--- a/lib/utils/queries.dart
+++ b/lib/utils/queries.dart
@@ -147,22 +147,7 @@ class Queries {
}
}
refreshToken
- androidFirebaseOptions {
- apiKey
- appId
- messagingSenderId
- projectId
- storageBucket
- }
- iosFirebaseOptions {
- apiKey
- appId
- messagingSenderId
- projectId
- storageBucket
- iosClientId
- iosBundleId
- }
+
}
}
""";
@@ -193,21 +178,6 @@ class Queries {
""";
}
- /// To save fcm token the backend fro notification.
- ///
- /// **params**:
- /// * `token`: fcm token, read firebase docs for more info
- ///
- /// **returns**:
- /// * `String`: return the mutation
- String saveFcmToken(String? token) {
- return """
- mutation {
- saveFcmToken(token: "$token")
- }
- """;
- }
-
/// logout muiation.
///
/// **params**:
diff --git a/lib/view_model/pre_auth_view_models/login_view_model.dart b/lib/view_model/pre_auth_view_models/login_view_model.dart
index 0f909bfdbb..3a8b637a6c 100644
--- a/lib/view_model/pre_auth_view_models/login_view_model.dart
+++ b/lib/view_model/pre_auth_view_models/login_view_model.dart
@@ -1,12 +1,10 @@
-// ignore_for_file: talawa_api_doc, avoid_dynamic_calls
-// ignore_for_file: talawa_good_doc_comments
+// ignore_for_file: avoid_dynamic_calls
-import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
-import 'package:hive/hive.dart';
+// import 'package:hive/hive.dart';
import 'package:talawa/constants/routing_constants.dart';
import 'package:talawa/locator.dart';
-import 'package:talawa/main.dart';
+// import 'package:talawa/main.dart';
import 'package:talawa/models/mainscreen_navigation_args.dart';
import 'package:talawa/models/user/user_info.dart';
import 'package:talawa/utils/encryptor.dart';
@@ -105,36 +103,6 @@ class LoginViewModel extends BaseModel {
arguments: MainScreenArgs(mainScreenIndex: 0, fromSignUp: false),
);
}
- final loginResult = result.data['login'] as Map;
- androidFirebaseOptions =
- loginResult['androidFirebaseOptions'] as Map;
- iosFirebaseOptions =
- loginResult['iosFirebaseOptions'] as Map;
- if (androidFirebaseOptions['apiKey'] != null ||
- iosFirebaseOptions['apiKey'] != null) {
- await setUpFirebase();
-
- final token = await FirebaseMessaging.instance.getToken();
- await databaseFunctions.gqlAuthMutation(
- queries.saveFcmToken(token),
- );
-
- await setUpFirebaseMessaging();
-
- final androidFirebaseOptionsBox =
- await Hive.openBox('androidFirebaseOptions');
- androidFirebaseOptionsBox.put(
- 'androidFirebaseOptions',
- androidFirebaseOptions,
- );
-
- final iosFirebaseOptionsBox =
- await Hive.openBox('iosFirebaseOptions');
- iosFirebaseOptionsBox.put(
- 'iosFirebaseOptions',
- iosFirebaseOptions,
- );
- }
}
} on Exception catch (e) {
print('here');
diff --git a/pubspec.lock b/pubspec.lock
index 93758e7cbf..fffb2018e5 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -17,14 +17,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "61.0.0"
- _flutterfire_internals:
- dependency: transitive
- description:
- name: _flutterfire_internals
- sha256: f5628cd9c92ed11083f425fd1f8f1bc60ecdda458c81d73b143aeda036c35fe7
- url: "https://pub.dev"
- source: hosted
- version: "1.3.16"
analyzer:
dependency: transitive
description:
@@ -213,10 +205,10 @@ packages:
dependency: transitive
description:
name: collection
- sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
+ sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
- version: "1.18.0"
+ version: "1.17.2"
connectivity_plus:
dependency: "direct main"
description:
@@ -409,54 +401,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.3+1"
- firebase_core:
- dependency: "direct main"
- description:
- name: firebase_core
- sha256: "96607c0e829a581c2a483c658f04e8b159964c3bae2730f73297070bc85d40bb"
- url: "https://pub.dev"
- source: hosted
- version: "2.24.2"
- firebase_core_platform_interface:
- dependency: "direct main"
- description:
- name: firebase_core_platform_interface
- sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63
- url: "https://pub.dev"
- source: hosted
- version: "5.0.0"
- firebase_core_web:
- dependency: transitive
- description:
- name: firebase_core_web
- sha256: d585bdf3c656c3f7821ba1bd44da5f13365d22fcecaf5eb75c4295246aaa83c0
- url: "https://pub.dev"
- source: hosted
- version: "2.10.0"
- firebase_messaging:
- dependency: "direct main"
- description:
- name: firebase_messaging
- sha256: "199fe8186a5370d1cf5ce0819191079afc305914e8f38715f5e23943940dfe2d"
- url: "https://pub.dev"
- source: hosted
- version: "14.7.9"
- firebase_messaging_platform_interface:
- dependency: "direct main"
- description:
- name: firebase_messaging_platform_interface
- sha256: "54e283a0e41d81d854636ad0dad73066adc53407a60a7c3189c9656e2f1b6107"
- url: "https://pub.dev"
- source: hosted
- version: "4.5.18"
- firebase_messaging_web:
- dependency: transitive
- description:
- name: firebase_messaging_web
- sha256: "90dc7ed885e90a24bb0e56d661d4d2b5f84429697fd2cbb9e5890a0ca370e6f4"
- url: "https://pub.dev"
- source: hosted
- version: "3.5.18"
fixnum:
dependency: transitive
description:
@@ -1049,10 +993,10 @@ packages:
dependency: transitive
description:
name: meta
- sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
+ sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
- version: "1.10.0"
+ version: "1.9.1"
mime:
dependency: transitive
description:
@@ -1518,18 +1462,18 @@ packages:
dependency: transitive
description:
name: stack_trace
- sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
+ sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
- version: "1.11.1"
+ version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
- sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
+ sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
- version: "2.1.2"
+ version: "2.1.1"
stream_transform:
dependency: transitive
description:
@@ -1597,10 +1541,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
+ sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
- version: "0.6.1"
+ version: "0.6.0"
timelines:
dependency: "direct main"
description:
@@ -1845,10 +1789,10 @@ packages:
dependency: transitive
description:
name: web
- sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
+ sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
- version: "0.3.0"
+ version: "0.1.4-beta"
web_socket_channel:
dependency: transitive
description:
@@ -1899,4 +1843,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.2.0 <3.13.0"
- flutter: ">=3.16.0"
+ flutter: ">=3.16.0"
\ No newline at end of file
diff --git a/pubspec.yaml b/pubspec.yaml
index af6ac2916c..58fece18e3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -32,10 +32,6 @@ dependencies:
# custom_lint_builder: ^0.4.0
################################
file: ^7.0.0
- firebase_core: ^2.24.2
- firebase_core_platform_interface: ^5.0.0
- firebase_messaging: ^14.7.9
- firebase_messaging_platform_interface: ^4.5.17
flutter:
sdk: flutter
diff --git a/test/helpers/setup_firebase_mocks.dart b/test/helpers/setup_firebase_mocks.dart
index 622f975ac6..ec30646740 100644
--- a/test/helpers/setup_firebase_mocks.dart
+++ b/test/helpers/setup_firebase_mocks.dart
@@ -3,206 +3,204 @@
// ignore_for_file: return_of_invalid_type
-import 'package:firebase_core/firebase_core.dart';
+// import 'package:firebase_core/firebase_core.dart';
// import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
-import 'package:firebase_messaging_platform_interface/firebase_messaging_platform_interface.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:mockito/mockito.dart';
-import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-
-final kMockMessagingPlatform = MockFirebaseMessaging();
-
-Future neverEndingFuture() async {
- // ignore: literal_only_boolean_expressions
- while (true) {
- await Future.delayed(const Duration(minutes: 5));
- }
-}
-
-void setupFirebaseMocks() {
- TestWidgetsFlutterBinding.ensureInitialized();
-
- const firebaseChannel = MethodChannel(
- 'plugins.flutter.io/firebase_core',
- );
-
- // ignore: deprecated_member_use
- firebaseChannel.setMockMethodCallHandler((call) async {
- if (call.method == 'Firebase#initializeCore') {
- return [
- {
- 'name': defaultFirebaseAppName,
- 'options': {
- 'apiKey': '123',
- 'appId': '123',
- 'messagingSenderId': '123',
- 'projectId': '123',
- },
- 'pluginConstants': {},
- }
- ];
- }
-
- if (call.method == 'Firebase#initializeApp') {
- return {
- 'name': call.arguments['appName'],
- 'options': call.arguments['options'],
- 'pluginConstants': {},
- };
- }
-
- return null;
- });
-
- when(kMockMessagingPlatform.delegateFor(app: anyNamed('app')))
- .thenReturn(kMockMessagingPlatform);
- when(
- kMockMessagingPlatform.setInitialValues(
- isAutoInitEnabled: anyNamed('isAutoInitEnabled'),
- ),
- ).thenReturn(kMockMessagingPlatform);
-}
-
-class MockFirebaseMessaging extends Mock
- with MockPlatformInterfaceMixin
- implements FirebaseMessagingPlatform {
- MockFirebaseMessaging() {
- TestFirebaseMessagingPlatform();
- }
-
- @override
- bool get isAutoInitEnabled {
- return super.noSuchMethod(
- Invocation.getter(#isAutoInitEnabled),
- returnValue: true,
- returnValueForMissingStub: true,
- );
- }
-
- @override
- FirebaseMessagingPlatform delegateFor({FirebaseApp? app}) {
- return super.noSuchMethod(
- Invocation.method(#delegateFor, [], {#app: app}),
- returnValue: TestFirebaseMessagingPlatform(),
- returnValueForMissingStub: TestFirebaseMessagingPlatform(),
- );
- }
-
- @override
- FirebaseMessagingPlatform setInitialValues({bool? isAutoInitEnabled}) {
- return super.noSuchMethod(
- Invocation.method(
- #setInitialValues,
- [],
- {#isAutoInitEnabled: isAutoInitEnabled},
- ),
- returnValue: TestFirebaseMessagingPlatform(),
- returnValueForMissingStub: TestFirebaseMessagingPlatform(),
- );
- }
-
- @override
- Future getInitialMessage() {
- return super.noSuchMethod(
- Invocation.method(#getInitialMessage, []),
- returnValue: neverEndingFuture(),
- returnValueForMissingStub: neverEndingFuture(),
- );
- }
-
- @override
- Future deleteToken() {
- return super.noSuchMethod(
- Invocation.method(#deleteToken, []),
- returnValue: Future.value(),
- returnValueForMissingStub: Future.value(),
- );
- }
-
- @override
- Future getAPNSToken() {
- return super.noSuchMethod(
- Invocation.method(#getAPNSToken, []),
- returnValue: Future.value(''),
- returnValueForMissingStub: Future.value(''),
- );
- }
-
- @override
- Future getToken({String? vapidKey}) {
- return super.noSuchMethod(
- Invocation.method(#getToken, [], {#vapidKey: vapidKey}),
- returnValue: Future.value(''),
- returnValueForMissingStub: Future.value(''),
- );
- }
-
- @override
- Future setAutoInitEnabled(bool? enabled) {
- return super.noSuchMethod(
- Invocation.method(#setAutoInitEnabled, [enabled]),
- returnValue: Future.value(),
- returnValueForMissingStub: Future.value(),
- );
- }
-
- @override
- Stream get onTokenRefresh {
- return super.noSuchMethod(
- Invocation.getter(#onTokenRefresh),
- returnValue: const Stream.empty(),
- returnValueForMissingStub: const Stream.empty(),
- );
- }
-
-// Comment out the notification logic for the MVP
-// TODO: Re-enable notifications when needed for the final release.
-
- // @override
- // Future requestPermission({
- // bool? alert = true,
- // bool? announcement = false,
- // bool? badge = true,
- // bool? carPlay = false,
- // bool? criticalAlert = false,
- // bool? provisional = false,
- // bool? sound = true,
- // }) {
- // return super.noSuchMethod(
- // Invocation.method(#requestPermission, [], {
- // #alert: alert,
- // #announcement: announcement,
- // #badge: badge,
- // #carPlay: carPlay,
- // #criticalAlert: criticalAlert,
- // #provisional: provisional,
- // #sound: sound,
- // }),
- // returnValue: neverEndingFuture(),
- // returnValueForMissingStub: neverEndingFuture(),
- // );
- // }
-
- @override
- Future subscribeToTopic(String? topic) {
- return super.noSuchMethod(
- Invocation.method(#subscribeToTopic, [topic]),
- returnValue: Future.value(),
- returnValueForMissingStub: Future.value(),
- );
- }
-
- @override
- Future unsubscribeFromTopic(String? topic) {
- return super.noSuchMethod(
- Invocation.method(#unsubscribeFromTopic, [topic]),
- returnValue: Future.value(),
- returnValueForMissingStub: Future.value(),
- );
- }
-}
-
-class TestFirebaseMessagingPlatform extends FirebaseMessagingPlatform {
- TestFirebaseMessagingPlatform() : super();
-}
+// import 'package:firebase_messaging_platform_interface/firebase_messaging_platform_interface.dart';
+// import 'package:flutter/services.dart';
+// import 'package:flutter_test/flutter_test.dart';
+// import 'package:mockito/mockito.dart';
+// import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+
+// final kMockMessagingPlatform = MockFirebaseMessaging();
+
+// Future neverEndingFuture() async {
+// // ignore: literal_only_boolean_expressions
+// while (true) {
+// await Future.delayed(const Duration(minutes: 5));
+// }
+// }
+
+// void setupFirebaseMocks() {
+// TestWidgetsFlutterBinding.ensureInitialized();
+
+// const firebaseChannel = MethodChannel(
+// 'plugins.flutter.io/firebase_core',
+// );
+
+// // ignore: deprecated_member_use
+// firebaseChannel.setMockMethodCallHandler((call) async {
+// if (call.method == 'Firebase#initializeCore') {
+// return [
+// {
+// 'name': defaultFirebaseAppName,
+// 'options': {
+// 'apiKey': '123',
+// 'appId': '123',
+// 'messagingSenderId': '123',
+// 'projectId': '123',
+// },
+// 'pluginConstants': {},
+// }
+// ];
+// }
+
+// if (call.method == 'Firebase#initializeApp') {
+// return {
+// 'name': call.arguments['appName'],
+// 'options': call.arguments['options'],
+// 'pluginConstants': {},
+// };
+// }
+
+// return null;
+// });
+
+// when(kMockMessagingPlatform.delegateFor(app: anyNamed('app')))
+// .thenReturn(kMockMessagingPlatform);
+// when(
+// kMockMessagingPlatform.setInitialValues(
+// isAutoInitEnabled: anyNamed('isAutoInitEnabled'),
+// ),
+// ).thenReturn(kMockMessagingPlatform);
+// }
+
+// class MockFirebaseMessaging extends Mock with MockPlatformInterfaceMixin {
+// MockFirebaseMessaging() {
+// // TestFirebaseMessagingPlatform();
+// }
+
+// @override
+// bool get isAutoInitEnabled {
+// return super.noSuchMethod(
+// Invocation.getter(#isAutoInitEnabled),
+// returnValue: true,
+// returnValueForMissingStub: true,
+// );
+// }
+
+// // @override
+// // FirebaseMessagingPlatform delegateFor({FirebaseApp? app}) {
+// // return super.noSuchMethod(
+// // Invocation.method(#delegateFor, [], {#app: app}),
+// // returnValue: TestFirebaseMessagingPlatform(),
+// // returnValueForMissingStub: TestFirebaseMessagingPlatform(),
+// // );
+// // }
+
+// // @override
+// // FirebaseMessagingPlatform setInitialValues({bool? isAutoInitEnabled}) {
+// // return super.noSuchMethod(
+// // Invocation.method(
+// // #setInitialValues,
+// // [],
+// // {#isAutoInitEnabled: isAutoInitEnabled},
+// // ),
+// // returnValue: TestFirebaseMessagingPlatform(),
+// // returnValueForMissingStub: TestFirebaseMessagingPlatform(),
+// // );
+// // }
+
+// // @override
+// // Future getInitialMessage() {
+// // return super.noSuchMethod(
+// // Invocation.method(#getInitialMessage, []),
+// // returnValue: neverEndingFuture(),
+// // returnValueForMissingStub: neverEndingFuture(),
+// // );
+// // }
+
+// @override
+// Future deleteToken() {
+// return super.noSuchMethod(
+// Invocation.method(#deleteToken, []),
+// returnValue: Future.value(),
+// returnValueForMissingStub: Future.value(),
+// );
+// }
+
+// @override
+// Future getAPNSToken() {
+// return super.noSuchMethod(
+// Invocation.method(#getAPNSToken, []),
+// returnValue: Future.value(''),
+// returnValueForMissingStub: Future.value(''),
+// );
+// }
+
+// @override
+// Future getToken({String? vapidKey}) {
+// return super.noSuchMethod(
+// Invocation.method(#getToken, [], {#vapidKey: vapidKey}),
+// returnValue: Future.value(''),
+// returnValueForMissingStub: Future.value(''),
+// );
+// }
+
+// @override
+// Future setAutoInitEnabled(bool? enabled) {
+// return super.noSuchMethod(
+// Invocation.method(#setAutoInitEnabled, [enabled]),
+// returnValue: Future.value(),
+// returnValueForMissingStub: Future.value(),
+// );
+// }
+
+// @override
+// Stream get onTokenRefresh {
+// return super.noSuchMethod(
+// Invocation.getter(#onTokenRefresh),
+// returnValue: const Stream.empty(),
+// returnValueForMissingStub: const Stream.empty(),
+// );
+// }
+
+// // Comment out the notification logic for the MVP
+// // TODO: Re-enable notifications when needed for the final release.
+
+// // @override
+// // Future requestPermission({
+// // bool? alert = true,
+// // bool? announcement = false,
+// // bool? badge = true,
+// // bool? carPlay = false,
+// // bool? criticalAlert = false,
+// // bool? provisional = false,
+// // bool? sound = true,
+// // }) {
+// // return super.noSuchMethod(
+// // Invocation.method(#requestPermission, [], {
+// // #alert: alert,
+// // #announcement: announcement,
+// // #badge: badge,
+// // #carPlay: carPlay,
+// // #criticalAlert: criticalAlert,
+// // #provisional: provisional,
+// // #sound: sound,
+// // }),
+// // returnValue: neverEndingFuture(),
+// // returnValueForMissingStub: neverEndingFuture(),
+// // );
+// // }
+
+// @override
+// Future subscribeToTopic(String? topic) {
+// return super.noSuchMethod(
+// Invocation.method(#subscribeToTopic, [topic]),
+// returnValue: Future.value(),
+// returnValueForMissingStub: Future.value(),
+// );
+// }
+
+// @override
+// Future unsubscribeFromTopic(String? topic) {
+// return super.noSuchMethod(
+// Invocation.method(#unsubscribeFromTopic, [topic]),
+// returnValue: Future.value(),
+// returnValueForMissingStub: Future.value(),
+// );
+// }
+// }
+
+// // class TestFirebaseMessagingPlatform extends FirebaseMessagingPlatform {
+// // TestFirebaseMessagingPlatform() : super();
+// // }
diff --git a/test/utils_tests/queries_test.dart b/test/utils_tests/queries_test.dart
index 610147ca2b..6fffa67398 100644
--- a/test/utils_tests/queries_test.dart
+++ b/test/utils_tests/queries_test.dart
@@ -27,16 +27,6 @@ void main() {
}
expect(mutation, true);
});
- test("Check if saveFcmToken works correctly", () {
- var mutation = false;
- expect(mutation, false);
-
- final fnData = Queries().saveFcmToken('token123');
- if (fnData.contains('token123')) {
- mutation = true;
- }
- expect(mutation, true);
- });
test("Check if logout works correctly", () {
const mutation = false;
expect(mutation, false);
diff --git a/test/view_model_tests/pre_auth_view_models/login_view_model_test.dart b/test/view_model_tests/pre_auth_view_models/login_view_model_test.dart
index 41360dbe71..7f9af6d627 100644
--- a/test/view_model_tests/pre_auth_view_models/login_view_model_test.dart
+++ b/test/view_model_tests/pre_auth_view_models/login_view_model_test.dart
@@ -1,8 +1,6 @@
// ignore_for_file: talawa_api_doc
// ignore_for_file: talawa_good_doc_comments
-// import 'package:firebase_core/firebase_core.dart';
-// import 'package:firebase_messaging_platform_interface/firebase_messaging_platform_interface.dart';
// import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
// import 'package:graphql_flutter/graphql_flutter.dart';
@@ -15,7 +13,6 @@ import 'package:talawa/services/user_config.dart';
// import 'package:talawa/utils/queries.dart';
// import 'package:talawa/view_model/pre_auth_view_models/login_view_model.dart';
-// import '../../helpers/setup_firebase_mocks.dart';
// import '../../helpers/test_helpers.dart';
final data = {
@@ -28,32 +25,12 @@ final data = {
},
'accessToken': 'testtoken',
'refreshToken': 'testtoken',
- 'androidFirebaseOptions': {
- 'apiKey': 'test',
- 'appId': 'test',
- 'messagingSenderId': 'test',
- 'projectId': 'test',
- 'storageBucket': 'test',
- },
- 'iosFirebaseOptions': {
- 'apiKey': 'test',
- 'appId': 'test',
- 'messagingSenderId': 'test',
- 'projectId': 'test',
- 'storageBucket': 'test',
- 'iosClientId': 'test',
- 'iosBundleId': 'test',
- },
},
};
bool empty = false;
Future main() async {
- // setupFirebaseMocks();
- // await Firebase.initializeApp();
- // FirebaseMessagingPlatform.instance = kMockMessagingPlatform;
-
// setUp(() async {
// locator.registerSingleton(Queries());
// registerServices();
diff --git a/test/widget_tests/after_auth_screens/events/edit_event_page_test.dart b/test/widget_tests/after_auth_screens/events/edit_event_page_test.dart
index c2eb5df009..821cad5313 100644
--- a/test/widget_tests/after_auth_screens/events/edit_event_page_test.dart
+++ b/test/widget_tests/after_auth_screens/events/edit_event_page_test.dart
@@ -3,7 +3,6 @@
// ignore_for_file: unused_import
-import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -22,7 +21,6 @@ import 'package:talawa/views/after_auth_screens/events/edit_events_form.dart';
import 'package:talawa/views/base_view.dart';
import 'package:talawa/widgets/event_date_time_tile.dart';
-import '../../../helpers/setup_firebase_mocks.dart';
import '../../../helpers/test_helpers.dart';
import '../../../helpers/test_helpers.mocks.dart';
@@ -75,9 +73,6 @@ void main() {
setupLocator();
graphqlConfig.test();
- setupFirebaseMocks();
- // await Firebase.initializeApp();
-
group("Edit Event Screen Widget Test in dark mode", () {
testWidgets("Testing if dark mode is applied", (tester) async {
await tester.pumpWidget(
diff --git a/test/widget_tests/pre_auth_screens/splash_screen_test.dart b/test/widget_tests/pre_auth_screens/splash_screen_test.dart
index d8d4909419..84c3c4856a 100644
--- a/test/widget_tests/pre_auth_screens/splash_screen_test.dart
+++ b/test/widget_tests/pre_auth_screens/splash_screen_test.dart
@@ -3,7 +3,6 @@
// ignore_for_file: unused_import
-import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -16,8 +15,6 @@ import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/views/base_view.dart';
-import '../../helpers/setup_firebase_mocks.dart';
-
Widget createSplashScreenLight({ThemeMode themeMode = ThemeMode.light}) =>
BaseView(
onModelReady: (model) => model.initialize(),
@@ -68,9 +65,6 @@ Future main() async {
setupLocator();
graphqlConfig.test();
- // setupFirebaseMocks();
- // await Firebase.initializeApp();
-
group('Splash Screen Widget Test in light mode', () {
testWidgets("Testing if Splash Screen shows up", (tester) async {
await tester.pumpWidget(createSplashScreenLight());