Skip to content
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

Accessibility improvement in Choose New Password page #7665

Merged
merged 17 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
## Bug fixes

- Fix health facilities missing from dropdown after correcting a record address [#7528](https://github.com/opencrvs/opencrvs-core/issues/7528)
- "Choose a new password" form now allows the user to submit the form using the "Enter/Return" key [#5502](https://github.com/opencrvs/opencrvs-core/issues/5502)

## 1.6.0 Release candidate

Expand Down
62 changes: 60 additions & 2 deletions packages/client/src/views/UserSetup/CreatePassword.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CreatePassword page tests', () => {
component = testComponent
})

it('it shows passwords missmatch error when Continue button is pressed', async () => {
it('it shows passwords missmatch error when Continue button is clicked', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
Expand All @@ -40,14 +40,72 @@ describe('CreatePassword page tests', () => {
'Passwords do not match'
)
})
it('it passes validations', () => {
it('it shows passwords mismatch error when Enter/Return key is pressed on ConfirmPassword field', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: 'missmatch' }
})
component.find('input#ConfirmPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text()).toEqual(
'Passwords do not match'
)
})
it('it shows passwords mismatch error when Enter/Return key is pressed on NewPassword field', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#NewPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text()).toEqual(
'Passwords do not match'
)
})
it('it passes validations when Continue button is clicked', () => {
HabibSentongo marked this conversation as resolved.
Show resolved Hide resolved
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: '0crvsPassword' }
})
component.find('button#Continue').simulate('click')
expect(component.find('#GlobalError').hostNodes().text().length).toBe(0)
})
it('it passes validations when Enter/Return key is pressed on ConfirmPassword field', () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text().length).toBe(0)
})
it('it passes validations when Enter/Return key is pressed on NewPassword field', () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: '0crvsPassword' }
})
component.find('input#NewPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text().length).toBe(0)
})
it('it shows disabled continue button when no password is given', () => {
expect(
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/views/UserSetup/CreatePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
})
}
}
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
event.preventDefault()
whatNext()
}
}

const continueActionButton = (
<PrimaryButton
Expand Down Expand Up @@ -169,6 +175,7 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
touched={true}
value={newPassword}
onChange={checkPasswordStrength}
onKeyDown={handleKeyDown}
error={continuePressed && newPassword.length === 0}
/>
</InputField>
Expand Down Expand Up @@ -207,6 +214,7 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
error={continuePressed && passwordMismatched}
value={confirmPassword}
onChange={matchPassword}
onKeyDown={handleKeyDown}
/>
</InputField>
{passwordMismatched && (
Expand Down
Loading