Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write tests for access_request_screen_test.dart #2222

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/models/chats/chat_list_tile_data_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions lib/models/chats/chat_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions lib/models/chats/chat_user.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions lib/models/organization/org_info.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions lib/models/user/user_info.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,74 +26,77 @@ class SendAccessRequest extends StatelessWidget {
backgroundColor: Colors.transparent,
),
resizeToAvoidBottomInset: false,
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset('assets/images/Group 8948.png'),
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"You need access",
style: AppTheme.title.copyWith(color: AppTheme.white),
),
const SizedBox(
height: 5,
),
const Text(
"Request access, or switch to an account with access",
),
const SizedBox(
height: 20,
),
Container(
child: TextField(
style: const TextStyle(color: AppTheme.blackPrimary),
minLines: 15,
maxLines: 20,
decoration: InputDecoration(
constraints: const BoxConstraints(
maxWidth: 400,
minWidth: 100,
),
enabledBorder: UnderlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
width: 3,
color: Colors.white,
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset('assets/images/Group 8948.png'),
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"You need access",
style: AppTheme.title.copyWith(color: AppTheme.white),
),
const SizedBox(
height: 5,
),
const Text(
"Request access, or switch to an account with access",
),
const SizedBox(
height: 20,
),
Container(
child: TextField(
style: const TextStyle(color: AppTheme.blackPrimary),
minLines: 15,
maxLines: 20,
decoration: InputDecoration(
constraints: const BoxConstraints(
maxWidth: 400,
minWidth: 100,
),
enabledBorder: UnderlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
width: 3,
color: Colors.white,
),
),
hintText: "Message (optional)",
hintStyle: const TextStyle(
color: AppTheme.blackSecondary,
),
filled: true,
fillColor: AppTheme.white,
),
hintText: "Message (optional)",
hintStyle: const TextStyle(
color: AppTheme.blackSecondary,
),
filled: true,
fillColor: AppTheme.white,
),
),
),
],
],
),
),
),
Center(
child: TextButton(
onPressed: () {
model.sendMembershipRequest();
},
style:
TextButton.styleFrom(backgroundColor: AppTheme.green),
child: const Text(
"Request Access",
style: TextStyle(
color: AppTheme.white,
Center(
child: TextButton(
onPressed: () {
model.sendMembershipRequest();
},
style:
TextButton.styleFrom(backgroundColor: AppTheme.green),
child: const Text(
"Request Access",
style: TextStyle(
color: AppTheme.white,
),
),
),
),
),
],
],
),
),
),
);
Expand Down
22 changes: 11 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ packages:
dependency: transitive
description:
name: cross_file
sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5"
sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e
url: "https://pub.dev"
source: hosted
version: "0.3.3+7"
version: "0.3.3+8"
crypto:
dependency: "direct main"
description:
Expand Down Expand Up @@ -705,18 +705,18 @@ packages:
dependency: transitive
description:
name: google_maps_flutter_android
sha256: "4023e79184c762e63efe04da629d876085e0c296a7ca26745fb5750d4acd0aa2"
sha256: "4279a338b79288fad5c8b03e5ae6ec30888bff210e0bab10b1f31f31e5a90558"
url: "https://pub.dev"
source: hosted
version: "2.5.3"
version: "2.6.0"
google_maps_flutter_ios:
dependency: transitive
description:
name: google_maps_flutter_ios
sha256: "2aa28eb9b9d5dfdce6932a7b7f096430bf83a1a09b4e21e81939351f407c787f"
sha256: "6ad65362aeeeda44b7c2c807e36bf578ef4b1c163882e085bdb040bf2934b246"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.3"
google_maps_flutter_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1070,7 +1070,7 @@ packages:
source: hosted
version: "5.4.3"
mocktail:
dependency: transitive
dependency: "direct main"
description:
name: mocktail
sha256: bac151b31e4ed78bd59ab89aa4c0928f297b1180186d5daf03734519e5f596c1
Expand Down Expand Up @@ -1249,10 +1249,10 @@ packages:
dependency: transitive
description:
name: petitparser
sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
url: "https://pub.dev"
source: hosted
version: "6.0.1"
version: "6.0.2"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -1797,10 +1797,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "7c99c0e1e2fa190b48d25c81ca5e42036d5cac81430ef249027d97b0935c553f"
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574
url: "https://pub.dev"
source: hosted
version: "5.1.0"
version: "5.1.1"
win32_registry:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage: https://github.com/PalisadoesFoundation/talawa

repository: https://github.com/PalisadoesFoundation/talawa
environment:
sdk: ">=2.17.0 <3.13.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
############# Remove ###########
Expand Down Expand Up @@ -61,6 +61,7 @@ dependencies:
intl: ^0.18.0
json_annotation: ^4.7.0
mockito: ^5.4.3
mocktail: ^1.0.1
network_image_mock: ^2.1.1
path_provider: ^2.1.1
permission_handler: ^11.1.0
Expand Down
32 changes: 32 additions & 0 deletions test/helpers/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import 'package:talawa/services/third_party_service/multi_media_pick_service.dar
import 'package:talawa/services/user_config.dart';
import 'package:talawa/utils/event_queries.dart';
import 'package:talawa/utils/validators.dart';
import 'package:talawa/view_model/access_request_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/add_post_view_models/add_post_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/chat_view_models/direct_chat_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/chat_view_models/select_contact_view_model.dart';
Expand All @@ -58,6 +59,7 @@ import 'test_helpers.mocks.dart';
@GenerateMocks(
[],
customMocks: [
MockSpec<AccessScreenViewModel>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<NavigationService>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<GraphqlConfig>(onMissingStub: OnMissingStub.returnDefault),
MockSpec<GraphQLClient>(onMissingStub: OnMissingStub.returnDefault),
Expand Down Expand Up @@ -117,6 +119,36 @@ void _removeRegistrationIfExists<T extends Object>() {
}
}

void registerationForAccessRequestScreenTest(){
if(!locator.isRegistered<AccessScreenViewModel>()){
locator.registerFactory<AccessScreenViewModel>(() => AccessScreenViewModel());
}
if(!locator.isRegistered<GraphqlConfig>()){
locator.registerFactory<GraphqlConfig>(() => GraphqlConfig());
}
if(!locator.isRegistered<Connectivity>()){
locator.registerFactory<Connectivity>(() => Connectivity());
}
if(!locator.isRegistered<DataBaseMutationFunctions>()){
locator.registerFactory<DataBaseMutationFunctions>(() => DataBaseMutationFunctions());
}
}

void unregisterationForAccessRequestScreenTest(){
if(locator.isRegistered<AccessScreenViewModel>()){
locator.unregister<AccessScreenViewModel>();
}
if(locator.isRegistered<Connectivity>()){
locator.unregister<Connectivity>();
}
if(locator.isRegistered<GraphqlConfig>()){
locator.unregister<GraphqlConfig>();
}
if(locator.isRegistered<DataBaseMutationFunctions>()){
locator.unregister<DataBaseMutationFunctions>();
}
}

NavigationService getAndRegisterNavigationService() {
_removeRegistrationIfExists<NavigationService>();
final service = MockNavigationService();
Expand Down
Loading
Loading