-
Notifications
You must be signed in to change notification settings - Fork 370
feat(LoginPage): added isPasswordRequired prop #11673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(LoginPage): added isPasswordRequired prop #11673
Conversation
Preview: https://patternfly-react-pr-11673.surge.sh A11y report: https://patternfly-react-pr-11673-a11y.surge.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Would you want to try writing a couple tests for this prop? One to check that the password field is required by default, and another to check that it is not required when isPasswordRequired is false.
I'll work on writing the tests. Should I include the changes in this PR or open a followup? Also we don't have any examples showcasing the false state of the prop. |
You can include it in this PR. @andrew-ronaldson would we want to include an example for such a simple difference? |
Not sure if it needs an example. We can document the new prop with the existing example as a start |
@thatblindgeye I did some research and found out that passing the prop in
I am currently trying to find the component which handles the input state of password field. |
48e3c69
to
27cfe4d
Compare
patternfly-react/packages/react-core/src/components/LoginPage/LoginForm.tsx Lines 86 to 96 in 54e11ce
Needed to pass down the prop here too. |
I have added test case to ensure |
Currently I have not explicitly mentioned |
@Mash707 thanks for catching and looking into that. For the test, we'd actually want to add a unit test for LoginForm specifically (in the We could add some verbiage to the MD file for the examples before the actual code between lines 32 and 34 in the MD). @edonehoo wdyt of something like "While the username field will always be required, you can make the password field optional by passing the |
@thatblindgeye how do you feel about swapping things around a little: "By default, a login page requires users to enter both a username and a password into their respective fields. The username must always be a required field, but you can can make the password optional by passing the |
I have added the test cases and also the explanatory text for the |
b00a23b
to
23d75ae
Compare
@@ -48,4 +48,16 @@ describe('LoginForm', () => { | |||
const { asFragment } = render(<LoginForm isShowPasswordEnabled />); | |||
expect(asFragment()).toMatchSnapshot(); | |||
}); | |||
|
|||
test('LoginForm with isPasswordRequired', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the test descriptions, typically we try to keep a format of "Renders...."
So for these 2, maybe something like "Renders LoginForm with password field required by default" and "Renders LoginForm with password field not required when isPasswordRequired set to false"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the test description.
23d75ae
to
49b904a
Compare
expect(passwordField).toHaveAttribute('required'); | ||
}); | ||
|
||
test('Renders LoginForm with password field not required when isPasswordRequired set to false', () => { | ||
render(<LoginForm isPasswordRequired={false} />); | ||
const passwordField = screen.getByLabelText(/password/i); | ||
expect(passwordField).not.toHaveAttribute('required'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last change request I swear 😆 Rather than using the toHaveAttribute
, we should be able to use toBeRequired()
instead for these tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes more sense, will make the changes.
49b904a
to
99c09c9
Compare
Your changes have been released in:
Thanks for your contribution! 🎉 |
* feat(LoginPage): added isPasswordRequired prop * updated test names * mades changes to test file
Closes #11123