From 71ce80a27f8afb553eceee357551b04392b997ec Mon Sep 17 00:00:00 2001 From: Insiya <114379635+Insiyaya@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:46:58 +0530 Subject: [PATCH] added additional test cases to edit profile page test file (#2331) * added additional test cases to edit profile page test file * updates the code * fixed failing tests * fixed * Done some corrections in previous code * Update edit_profile_page_test.dart * Update edit_profile_page_test.dart * Made some changes to run the tests Made some changes to run the tests --- .../profile/edit_profile_page.dart | 1 + .../profile/edit_profile_page_test.dart | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) 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 32de5599d..6704aea7b 100644 --- a/lib/views/after_auth_screens/profile/edit_profile_page.dart +++ b/lib/views/after_auth_screens/profile/edit_profile_page.dart @@ -150,6 +150,7 @@ class _EditProfilePageState extends State { Flexible( // Text field for first name with value text of user's first name. child: TextFormField( + key: const Key('FirstNameTextField'), controller: model.firstNameTextController ..text = model.user.firstName!, focusNode: model.firstNameFocus, 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 fb3284606..f0e29ac44 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 @@ -452,5 +452,24 @@ Future main() async { expect(model.imageFile, null); verify(notifyListenerCallback()); }); + + // Testing onPressed for firstName + testWidgets("Testing if firstName text field gets focus", (tester) async { + userConfig.updateUser( + User(firstName: 'Test', lastName: 'Test', email: 'test@test.com'), + ); + await tester.pumpWidget(createChangePassScreenDark()); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('FirstNameTextField'))); + await tester.pumpAndSettle(); + + // Verify the focus + expect( + FocusScope.of(tester.element(find.byType(EditProfilePage))) + .focusedChild! + .hasPrimaryFocus, + true, + ); + }); }); }