-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unittest for lib/views/after_auth_screens/profile/edit_profile_page.d…
…art (#2686) * added * adding const in it * fixing linting issue * fixing this issue * inc code coverage * revert some changes * adding remove image coverage * increasing recursive dialog test * revert package.lock * test change * Revert pubspec.lock to match upstream/develop-postgres * code coverga inc * add lastname in edit_profile * added trailing comma * cahnge last name focus way * testing image selection * revert some change * revert image modal fix * increase coverage for firstName --------- Co-authored-by: Mayankpulse333 <[email protected]>
- Loading branch information
1 parent
bb59156
commit 1e0e627
Showing
3 changed files
with
111 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,22 +448,75 @@ Future<void> main() async { | |
}); | ||
|
||
// Testing onPressed for firstName | ||
testWidgets("Testing if firstName text field gets focus", (tester) async { | ||
testWidgets("Testing if firstName text field gets focus on onPressed", | ||
(tester) async { | ||
userConfig.updateUser( | ||
User(firstName: 'Test', lastName: 'Test', email: '[email protected]'), | ||
); | ||
|
||
// Render the widget | ||
await tester.pumpWidget(createEditProfilePage(themeMode: ThemeMode.dark)); | ||
await tester.pumpAndSettle(); | ||
await tester.tap(find.byKey(const Key('FirstNameTextField'))); | ||
|
||
// Find the 'First Name' text field and its suffix icon | ||
final firstNameTextField = find.byKey(const Key('FirstNameTextField')); | ||
final editIconButton = find.descendant( | ||
of: firstNameTextField, | ||
matching: find.byIcon(Icons.edit), | ||
); | ||
|
||
// Ensure the text field and icon exist | ||
expect(firstNameTextField, findsOneWidget); | ||
expect(editIconButton, findsOneWidget); | ||
|
||
// Tap on the edit icon button to trigger focus | ||
await tester.tap(editIconButton); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify the focus | ||
// Verify that the lastNameFocus is focused | ||
final focusedElement = | ||
FocusScope.of(tester.element(firstNameTextField)).focusedChild; | ||
expect(focusedElement, isNotNull); // Ensure there is a focused child | ||
expect( | ||
FocusScope.of(tester.element(find.byType(EditProfilePage))) | ||
.focusedChild! | ||
.hasPrimaryFocus, | ||
true, | ||
focusedElement!.hasPrimaryFocus, | ||
isTrue, | ||
); // Ensure it h | ||
}); | ||
|
||
testWidgets("Testing if lastName text field gets focus on onPressed", | ||
(tester) async { | ||
// Mock or set up user data | ||
userConfig.updateUser( | ||
User(firstName: 'Test', lastName: 'Test', email: '[email protected]'), | ||
); | ||
|
||
// Render the widget | ||
await tester.pumpWidget(createEditProfilePage(themeMode: ThemeMode.dark)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Find the 'Last Name' text field and its suffix icon | ||
final lastNameTextField = find.byKey(const Key('LastNameTextField')); | ||
final editIconButton = find.descendant( | ||
of: lastNameTextField, | ||
matching: find.byIcon(Icons.edit), | ||
); | ||
|
||
// Ensure the text field and icon exist | ||
expect(lastNameTextField, findsOneWidget); | ||
expect(editIconButton, findsOneWidget); | ||
|
||
// Tap on the edit icon button to trigger focus | ||
await tester.tap(editIconButton); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify that the lastNameFocus is focused | ||
final focusedElement = | ||
FocusScope.of(tester.element(lastNameTextField)).focusedChild; | ||
expect(focusedElement, isNotNull); // Ensure there is a focused child | ||
expect( | ||
focusedElement!.hasPrimaryFocus, | ||
isTrue, | ||
); // Ensure it has primary focus | ||
}); | ||
}); | ||
} |