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

Fixes #1242 Create tests for create_event_page.dart #1472

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class CreateEventViewModel extends BaseModel {
variables: variables,
);
navigationService.pop();
print('Result is : $result');
if (result != null) {
navigationService.pop();

Expand Down Expand Up @@ -153,7 +152,6 @@ class CreateEventViewModel extends BaseModel {

void buildUserList({required bool isAdmin}) {
isAdmin ? _selectedAdmins.clear() : _selectedMembers.clear();

orgMembersList.forEach((orgMember) {
if (_adminCheckedMap[orgMember.id] == true && isAdmin) {
_selectedAdmins.add(orgMember);
Expand Down
4 changes: 4 additions & 0 deletions lib/views/after_auth_screens/events/create_event_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class _CreateEventPageState extends State<CreateEventPage> {
width: SizeConfig.screenWidth! * 0.036,
),
TextButton(
key: const Key('txt_btn_cep'),
onPressed: () => model.getImageFromGallery(),
child: Text(
AppLocalizations.of(context)!
Expand Down Expand Up @@ -162,6 +163,7 @@ class _CreateEventPageState extends State<CreateEventPage> {
height: SizeConfig.screenHeight! * 0.013,
),
DateTimeTile(
key: const Key('key for test cep'),
date: "${model.eventEndDate.toLocal()}".split(' ')[0],
time: model.eventEndTime.format(context),
setDate: () async {
Expand Down Expand Up @@ -259,6 +261,7 @@ class _CreateEventPageState extends State<CreateEventPage> {
SizedBox(height: SizeConfig.screenHeight! * 0.026),
const Divider(),
InkWell(
key: const Key('inwell_cep1'),
onTap: () {
EventBottomSheet().addUserBottomSheet(
context: context,
Expand Down Expand Up @@ -297,6 +300,7 @@ class _CreateEventPageState extends State<CreateEventPage> {
SizedBox(height: SizeConfig.screenHeight! * 0.026),
const Divider(),
InkWell(
key: const Key('inwell_cep2'),
onTap: () {
EventBottomSheet().addUserBottomSheet(
context: context,
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/add_members_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class EventBottomSheet {
style: const TextStyle(fontSize: 16),
),
TextButton(
key: const Key('text_btn_ambs1'),
onPressed: () {
model.buildUserList(isAdmin: isAdmin);
Navigator.pop(context);
Expand Down
17 changes: 17 additions & 0 deletions test/helpers/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ OrganizationService getAndRegisterOrganizationService() {
_removeRegistrationIfExists<OrganizationService>();
final service = MockOrganizationService();
locator.registerSingleton<OrganizationService>(service);

final User user1 = User(
id: "fakeUser1",
firstName: 'ayush',
lastName: 'chaudhary',
image: 'www.image.com',
);
final User user2 = User(
id: "fakeUser2",
firstName: 'ayush',
lastName: 'chaudhary',
image: 'www.image.com',
);
final List<User> users = [user1, user2];
when(service.getOrgMembersList('XYZ')).thenAnswer((realInvocation) async {
return users;
});
return service;
}

Expand Down
11 changes: 11 additions & 0 deletions test/helpers/test_helpers.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ class MockNavigationService extends _i2.Mock implements _i7.NavigationService {
Invocation.method(#showSnackBar, [message], {#duration: duration}),
returnValueForMissingStub: null);
@override
void showTalawaErrorWidget(String? errorMessage,
{Duration? duration = const Duration(seconds: 2)}) =>
super.noSuchMethod(
Invocation.method(
#showTalawaErrorWidget, [errorMessage], {#duration: duration}),
returnValueForMissingStub: null);
@override
void showTalawaErrorDialog(String? errorMessage) => super.noSuchMethod(
Invocation.method(#showTalawaErrorDialog, [errorMessage]),
returnValueForMissingStub: null);
@override
void pop() => super.noSuchMethod(Invocation.method(#pop, []),
returnValueForMissingStub: null);
}
Expand Down
Loading