Skip to content

Commit

Permalink
Merge branch 'develop' into updated/firebase_messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
SamarS1ngh authored Nov 21, 2023
2 parents 6410da9 + a16f982 commit aeeb36b
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
21 changes: 11 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,10 @@ packages:
dependency: "direct main"
description:
name: mockito
sha256: "7d5b53bcd556c1bc7ffbe4e4d5a19c3e112b7e925e9e172dd7c6ad0630812616"
sha256: "4b693867cee1853c9d1d7ecc1871f27f39b2ef2c13c0d8d8507dfe5bebd8aaf1"
url: "https://pub.dev"
source: hosted
version: "5.4.2"
version: "5.4.3"
mocktail:
dependency: transitive
description:
Expand Down Expand Up @@ -1281,10 +1281,10 @@ packages:
dependency: "direct main"
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
url: "https://pub.dev"
source: hosted
version: "6.0.5"
version: "6.1.1"
pub_semver:
dependency: transitive
description:
Expand Down Expand Up @@ -1542,10 +1542,10 @@ packages:
dependency: "direct main"
description:
name: syncfusion_flutter_calendar
sha256: ebfbfc0a5cb842aac82e02dcab109ba4746abd8562ed00df98e57627e69c7c41
sha256: cc8dcd9269fc836067d106a3985f8f4f0c71e397d995e074f02fa34f6d30c330
url: "https://pub.dev"
source: hosted
version: "23.1.43"
version: "23.1.44"
syncfusion_flutter_core:
dependency: transitive
description:
Expand Down Expand Up @@ -1709,10 +1709,10 @@ packages:
dependency: "direct main"
description:
name: video_player
sha256: "74b86e63529cf5885130c639d74cd2f9232e7c8a66cbecbddd1dcb9dbd060d1e"
sha256: e16f0a83601a78d165dabc17e4dac50997604eb9e4cc76e10fa219046b70cef3
url: "https://pub.dev"
source: hosted
version: "2.7.2"
version: "2.8.1"
video_player_android:
dependency: transitive
description:
Expand All @@ -1725,10 +1725,10 @@ packages:
dependency: transitive
description:
name: video_player_avfoundation
sha256: bf1a1322bf68bccd349982ba1f5a41314a3880861fb9a93d25d6d0a2345845f0
sha256: bc923884640d6dc403050586eb40713cdb8d1d84e6886d8aca50ab04c59124c2
url: "https://pub.dev"
source: hosted
version: "2.4.11"
version: "2.5.2"
video_player_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1828,3 +1828,4 @@ packages:
sdks:
dart: ">=3.2.0-194.0.dev <3.13.0"
flutter: ">=3.10.0"

11 changes: 4 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description: Welcome to the Talawa Project for the Palisadoes Foundation

publish_to: "none" # Remove this line if you wish to publish to pub.dev


version: 1.0.0+1

homepage: https://github.com/PalisadoesFoundation/talawa
Expand Down Expand Up @@ -38,7 +37,6 @@ dependencies:
firebase_messaging: ^14.7.4
firebase_messaging_platform_interface: ^4.5.13


flutter:
sdk: flutter
flutter_braintree: ^3.0.0
Expand All @@ -62,29 +60,28 @@ dependencies:
image_picker: ^1.0.4
intl: ^0.18.0
json_annotation: ^4.7.0
mockito: ^5.4.2
mockito: ^5.4.3
network_image_mock: ^2.1.1
path_provider: ^2.1.1
permission_handler: ^11.0.1
plugin_platform_interface: ^2.1.7
pointycastle: ^3.7.3
provider: ^6.0.3
provider: ^6.1.1
qr_code_scanner: ^1.0.0
qr_flutter: 4.0.0
quick_actions: ^1.0.6
shared_preferences: ^2.2.2
shimmer: ^3.0.0
social_share: ^2.2.1
syncfusion_flutter_calendar: 23.1.43
syncfusion_flutter_calendar: 23.1.44
syncfusion_flutter_datepicker: 23.1.44
timelines: ^0.1.0
tutorial_coach_mark: ^1.2.9
uni_links: ^0.5.1
vibration: ^1.8.3
video_player: ^2.7.2
video_player: ^2.8.1
visibility_detector: ^0.4.0+2


dev_dependencies:
build_runner: ^2.4.6
custom_lint: 0.5.6
Expand Down
40 changes: 27 additions & 13 deletions test/helpers/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,33 @@ GraphQLClient getAndRegisterGraphQLClient() {
// Either fill this with mock data or override this stub
// and return null

// when(service.query(QueryOptions(
// document: gql(queries.getPluginsList()),
// ))).thenAnswer(
// (realInvocation) async {
// return QueryResult.internal(
// source: QueryResultSource.network,
// parserFn: (data) => {},
// data: {
// "getPlugins": [],
// },
// );
// },
// );
when(service.query(any)).thenAnswer(
(realInvocation) async {
if (locator.isRegistered<GraphQLClient>()) {
return Future.value(
QueryResult<Map<String, dynamic>>(
source: QueryResultSource.network,
data: {
"getPlugins": null,
},
options: QueryOptions(
document: gql(queries.getPluginsList()),
),
),
);
} else {
return Future.value(
QueryResult<Map<String, dynamic>>(
source: QueryResultSource.network,
data: null,
options: QueryOptions(
document: gql(queries.getPluginsList()),
),
),
);
}
},
);

when(service.defaultPolicies).thenAnswer(
(realInvocation) => DefaultPolicies(),
Expand Down
86 changes: 86 additions & 0 deletions test/plugins/fetch_plugin_list_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:hive/hive.dart';
import 'package:mockito/mockito.dart';
import 'package:talawa/plugins/fetch_plugin_list.dart';
import 'package:talawa/services/graphql_config.dart';

import '../helpers/test_helpers.dart';
import '../helpers/test_locator.dart';

/// Tests fetch_plugin_list.dart.
///
/// more_info_if_required
///
/// **params**:
/// None
///
/// **returns**:
/// None
void main() async {
testSetupLocator();
locator<GraphqlConfig>().test();
late FetchPluginList fetchPluginList;

final Directory dir = await Directory.systemTemp.createTemp('talawa_test');
Hive.init(dir.path);
await Hive.openBox('pluginBox');

setUp(() {
registerServices();
locator.allowReassignment = true;

locator.registerLazySingleton<FetchPluginList>(() => FetchPluginList());
fetchPluginList = locator<FetchPluginList>();
});
group('FetchPluginList', () {
test('fetchList should fetch plugins and store them in Hive', () async {
final queryResult = QueryResult(
data: {
'getPlugins': [
{
'_id': '1',
'pluginName': 'Plugin 1',
'pluginCreatedBy': 'User A',
'pluginDesc': 'Description A',
'pluginInstallStatus': true,
'installedOrgs': ['Org A'],
},
],
},
options: QueryOptions(
document: gql(queries.getPluginsList()),
),
source: QueryResultSource.network,
);

when(locator<GraphqlConfig>().clientToQuery()).thenAnswer(
(_) => locator<GraphQLClient>(),
);
when(
locator<GraphQLClient>().query(
QueryOptions(
document: gql(queries.getPluginsList()),
),
),
).thenAnswer((_) async => queryResult);
await fetchPluginList.fetchList();

verify(locator<GraphqlConfig>().clientToQuery()).called(2);
verify(
locator<GraphQLClient>().query(
QueryOptions(
document: gql(queries.getPluginsList()),
),
),
).called(2);

expect(fetchPluginList.box, isNotNull);
expect(
fetchPluginList.box.get('plugins'),
equals(queryResult.data!["getPlugins"]),
);
});
});
}

0 comments on commit aeeb36b

Please sign in to comment.