diff --git a/lib/views/after_auth_screens/profile/edit_profile_page.dart b/lib/views/after_auth_screens/profile/edit_profile_page.dart index c11d0199d..c34bfa9d2 100644 --- a/lib/views/after_auth_screens/profile/edit_profile_page.dart +++ b/lib/views/after_auth_screens/profile/edit_profile_page.dart @@ -230,6 +230,7 @@ class _EditProfilePageState extends State { const Divider(), // button to update the profile. TextButton( + key: const Key('updatebtn'), onPressed: () { model.updateUserProfile( firstName: model.firstNameTextController.text, diff --git a/test/widget_tests/after_auth_screens/profile/edit_profile_page_test.dart b/test/widget_tests/after_auth_screens/profile/edit_profile_page_test.dart index 24698a81a..40700b3e1 100644 --- a/test/widget_tests/after_auth_screens/profile/edit_profile_page_test.dart +++ b/test/widget_tests/after_auth_screens/profile/edit_profile_page_test.dart @@ -27,6 +27,9 @@ import '../../../helpers/test_locator.dart'; class MockBuildContext extends Mock implements BuildContext {} +class MockEditProfilePageViewModel extends Mock + implements EditProfilePageViewModel {} + class MockCallbackFunction extends Mock { void call(); } @@ -295,6 +298,32 @@ Future main() async { tester.tap(imageAvatar); }); }); + testWidgets("Testing Update butoon", (tester) async { + await mockNetworkImages(() async { + final mockctx = MockBuildContext(); + userConfig.updateUser(User()); + userConfig.updateUser( + User(firstName: 'Test', lastName: 'Test', email: 'test@test.com'), + ); + await tester.pumpWidget(createChangePassScreenDark()); + await tester.pumpAndSettle(); + final screenScaffoldWidget = find.byKey( + const Key('EditProfileScreenScaffold'), + ); + expect(screenScaffoldWidget, findsOneWidget); + expect( + (tester.firstWidget(find.byKey(const Key('Root'))) as MaterialApp) + .theme! + .scaffoldBackgroundColor, + TalawaTheme.darkTheme.scaffoldBackgroundColor, + ); + final updateButtonFinder = find.byKey(const Key('updatebtn')); + expect(updateButtonFinder, findsOneWidget); + await tester.tap(updateButtonFinder); + await tester.pumpAndSettle(); + // verify(FocusScope.of(mockctx).unfocus()).called(1); + }); + }); }); group('Testing image selection and removal in Edit Profile Screen', () { setUp(() {