-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21c5427
commit 0bb46ea
Showing
1 changed file
with
25 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,22 +448,39 @@ 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", | ||
|