-
Notifications
You must be signed in to change notification settings - Fork 212
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
task(settings): Display password requirements inline #17605
Open
dschom
wants to merge
3
commits into
main
Choose a base branch
from
FXA-7896
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,179
−49
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
20 changes: 20 additions & 0 deletions
20
packages/fxa-settings/src/components/FormPasswordWithInlineCriteria/en.ftl
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## FormPasswordInline | ||
|
||
form-password-with-inline-criteria-signup-new-password-label = | ||
.label = Password | ||
form-password-with-inline-criteria-signup-confirm-password-label = | ||
.label = Repeat password | ||
form-password-with-inline-criteria-signup-submit-button = Create account | ||
|
||
form-password-with-inline-criteria-reset-new-password = | ||
.label = New password | ||
form-password-with-inline-criteria-confirm-password = | ||
.label = Re-enter password | ||
form-password-with-inline-criteria-reset-submit-button = Reset password | ||
|
||
form-password-with-inline-criteria-match-error = Passwords do not match | ||
form-password-with-inline-criteria-sr-too-short-message = Password must contain at least 8 characters. | ||
form-password-with-inline-criteria-sr-not-email-message = Password must not contain your email address. | ||
form-password-with-inline-criteria-sr-not-common-message = Password must not be a commonly used password. | ||
form-password-with-inline-criteria-sr-requirements-met = The entered password respects all password requirements. | ||
form-password-with-inline-criteria-sr-passwords-match = Entered passwords match. |
32 changes: 32 additions & 0 deletions
32
packages/fxa-settings/src/components/FormPasswordWithInlineCriteria/index.stories.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import React from 'react'; | ||
import { Subject } from './mocks'; | ||
import AppLayout from '../AppLayout'; | ||
import FormPasswordInline from '.'; | ||
import { Meta } from '@storybook/react'; | ||
import { withLocalization } from 'fxa-react/lib/storybooks'; | ||
|
||
export default { | ||
title: 'Components/FormPasswordWithInlineCriteria', | ||
component: FormPasswordInline, | ||
decorators: [withLocalization], | ||
} as Meta; | ||
|
||
export const ResetPassword = () => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to show the error state of passwords not matching in storybook? |
||
<AppLayout> | ||
<div className="max-w-lg mx-auto"> | ||
<Subject passwordFormType="reset" /> | ||
</div> | ||
</AppLayout> | ||
); | ||
|
||
export const Signup = () => ( | ||
<AppLayout> | ||
<div className="max-w-lg mx-auto"> | ||
<Subject passwordFormType="signup" /> | ||
</div> | ||
</AppLayout> | ||
); |
83 changes: 83 additions & 0 deletions
83
packages/fxa-settings/src/components/FormPasswordWithInlineCriteria/index.test.tsx
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import React from 'react'; | ||
import { screen, fireEvent, waitFor, within } from '@testing-library/react'; | ||
import { UserEvent, userEvent } from '@testing-library/user-event'; | ||
import { renderWithLocalizationProvider } from 'fxa-react/lib/test-utils/localizationProvider'; | ||
import { getFtlBundle, testAllL10n } from 'fxa-react/lib/test-utils'; | ||
import { FluentBundle } from '@fluent/bundle'; | ||
import { Subject } from './mocks'; | ||
|
||
describe('FormPasswordWithInlineCriteria component', () => { | ||
let bundle: FluentBundle; | ||
let user: UserEvent; | ||
|
||
beforeEach(() => { | ||
user = userEvent.setup(); | ||
}); | ||
beforeAll(async () => { | ||
bundle = await getFtlBundle('settings'); | ||
}); | ||
it('renders as expected for the reset form type', async () => { | ||
renderWithLocalizationProvider(<Subject passwordFormType="reset" />); | ||
testAllL10n(screen, bundle); | ||
|
||
await waitFor(() => { | ||
screen.getByLabelText('New password'); | ||
}); | ||
screen.getByLabelText('Re-enter password'); | ||
screen.getByRole('button', { name: 'Reset password' }); | ||
}); | ||
|
||
it('renders as expected for the signup form type', async () => { | ||
renderWithLocalizationProvider(<Subject passwordFormType="signup" />); | ||
|
||
await waitFor(() => { | ||
screen.getByLabelText('Password'); | ||
}); | ||
screen.getByLabelText('Repeat password'); | ||
screen.getByRole('button', { name: 'Create account' }); | ||
}); | ||
|
||
it('displays the Password Strength Criteria when the new password field is in focus', async () => { | ||
renderWithLocalizationProvider(<Subject passwordFormType="reset" />); | ||
const newPasswordField = screen.getByLabelText('New password'); | ||
|
||
fireEvent.focus(newPasswordField); | ||
|
||
await waitFor(() => screen.getByText('At least 8 characters')); | ||
await waitFor(() => screen.getByText('Not your email address')); | ||
await waitFor(() => screen.getByText('Not a commonly used password')); | ||
}); | ||
|
||
// TODO in FXA-7482, review our password requirements and best way to display them | ||
it('disallows space-only passwords', async () => { | ||
renderWithLocalizationProvider(<Subject passwordFormType="signup" />); | ||
const passwordField = screen.getByLabelText('Password'); | ||
user.type(passwordField, ' '); | ||
|
||
await waitFor(() => screen.getByText('At least 8 characters')); | ||
expect(screen.queryAllByText('icon-check.svg')).toHaveLength(2); | ||
const passwordMinCharRequirement = screen.getByTestId( | ||
'password-min-char-req' | ||
); | ||
const imageElement = within(passwordMinCharRequirement).getByRole('img'); | ||
expect(imageElement).toHaveTextContent('icon-x.svg'); | ||
}); | ||
|
||
it('disallows common passwords', async () => { | ||
renderWithLocalizationProvider(<Subject passwordFormType="signup" />); | ||
const passwordField = screen.getByLabelText('Password'); | ||
user.type(passwordField, 'mozilla accounts'); | ||
await waitFor(() => screen.getByText('At least 8 characters')); | ||
expect(screen.queryAllByText('icon-check.svg')).toHaveLength(2); | ||
|
||
const passwordNotCommonRequirement = screen.getByTestId( | ||
'password-not-common-req' | ||
); | ||
const imageElement = within(passwordNotCommonRequirement).getByRole('img'); | ||
expect(imageElement).toHaveTextContent('icon-x.svg'); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this be
FormPasswordInlineCriteria
?