Skip to content

Commit

Permalink
increase coverage for firstName
Browse files Browse the repository at this point in the history
  • Loading branch information
MayankJha014 committed Jan 4, 2025
1 parent 21c5427 commit 0bb46ea
Showing 1 changed file with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0bb46ea

Please sign in to comment.