-
Notifications
You must be signed in to change notification settings - Fork 26
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
fix(PasswordFiled): fix password readonly visibility #2677
fix(PasswordFiled): fix password readonly visibility #2677
Conversation
🦋 Changeset detectedLatest commit: 363653c The changes in this PR will be included in the next version bump. This PR includes changesets to release 93 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@serge-dynamic is attempting to deploy a commit to the commercetools Team on Vercel. A member of the Team first needs to authorize it. |
Hello @serge-st I will be happy to help if you have any further questions 🙂 |
Hello @ddouglasz! Thanks for the prompt reply. I added changeset and updated the tests in my latest commit. |
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.
Thank you for the tests 🙌🏾.
I just have some few observation to make it uniform with the other test.
@@ -141,13 +141,27 @@ describe('when disabled', () => { | |||
const { getByLabelText } = renderPasswordField({ isDisabled: true }); | |||
expect(getByLabelText('PasswordField')).toBeDisabled(); | |||
}); | |||
it('should set the input type to password', () => { | |||
const { container } = renderPasswordField({ isDisabled: true }); |
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.
We still need to give it some value, otherwise, the test will pass just all cases since we are testing a particular scenario:
- when there is value
- when readOnly and disabled
- when input type is text
const { container } = renderPasswordField({ isDisabled: true }); | |
const { getByLabelText } = renderPasswordField({ value: 'foo', isDisabled: true }); |
@@ -141,13 +141,27 @@ describe('when disabled', () => { | |||
const { getByLabelText } = renderPasswordField({ isDisabled: true }); | |||
expect(getByLabelText('PasswordField')).toBeDisabled(); | |||
}); | |||
it('should set the input type to password', () => { | |||
const { container } = renderPasswordField({ isDisabled: true }); | |||
expect(container.querySelector('input')).toHaveAttribute( |
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.
expect(container.querySelector('input')).toHaveAttribute( | |
expect(getByLabelText('PasswordField')).toHaveAttribute( |
}); | ||
|
||
describe('when readOnly', () => { | ||
it('should disable the input', () => { | ||
const { getByLabelText } = renderPasswordField({ isReadOnly: true }); | ||
expect(getByLabelText('PasswordField')).toHaveAttribute('readonly'); | ||
}); | ||
it('should set the input type to password', () => { | ||
const { container } = renderPasswordField({ isReadOnly: true }); |
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.
const { container } = renderPasswordField({ isReadOnly: true }); | |
const { getByLabelText } = renderPasswordField({value: 'foo', isReadOnly: true }); |
}); | ||
|
||
describe('when readOnly', () => { | ||
it('should disable the input', () => { | ||
const { getByLabelText } = renderPasswordField({ isReadOnly: true }); | ||
expect(getByLabelText('PasswordField')).toHaveAttribute('readonly'); | ||
}); | ||
it('should set the input type to password', () => { | ||
const { container } = renderPasswordField({ isReadOnly: true }); | ||
expect(container.querySelector('input')).toHaveAttribute( |
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.
expect(container.querySelector('input')).toHaveAttribute( | |
expect(getByLabelText('PasswordField')).toHaveAttribute( |
@ddouglasz Hello! Thank you for your patience. I followed your suggestion and made the test more uniform. I also covered:
about "when input type is text", since it is not possible to force input type via props, do you think it is needed to cover this as well, and how? |
Thank you for the changes. Honestly, I think these scenarios covered are enough. |
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.
@serge-st please we have some tiny last typos to fix 👌🏽
'password' | ||
); | ||
}); | ||
descrbe('when has value', () => { |
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.
descrbe('when has value', () => { | |
describe('when has value', () => { |
'password' | ||
); | ||
}); | ||
descrbe('when has value', () => { |
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.
descrbe('when has value', () => { | |
describe('when has value', () => { |
@ddouglasz my bad, I didn't setup the working environment correctly. Now I ran the format and lint scripts, checks should pass. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Summary
This change can resolve #2676 by disabling password visibility every time the password field is set to readonly and or disabled