generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Registration with password that doesn't meet the requirements (#…
…1184) * fix: Registration with password that doesn't meet the requirements --------- Co-authored-by: Dima Alipov <[email protected]> Co-authored-by: Syed Sajjad Hussain Shah <[email protected]>
- Loading branch information
1 parent
3635476
commit dc90cf9
Showing
11 changed files
with
187 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,14 @@ describe('EmailField', () => { | |
); | ||
|
||
const initialState = { | ||
register: {}, | ||
register: { | ||
registrationFormData: { | ||
emailSuggestion: { | ||
suggestion: '[email protected]', | ||
type: 'warning', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
beforeEach(() => { | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,6 +221,54 @@ describe('RegistrationPage', () => { | |
expect(store.dispatch).toHaveBeenCalledWith(registerNewUser({ ...formPayload, country: 'PK' })); | ||
}); | ||
|
||
it('should display an error when form is submitted with an invalid email', () => { | ||
jest.spyOn(global.Date, 'now').mockImplementation(() => 0); | ||
const emailError = "We couldn't create your account.Please check your responses and try again."; | ||
|
||
const formPayload = { | ||
name: 'Petro', | ||
username: 'petro_qa', | ||
email: 'petro @example.com', | ||
password: 'password1', | ||
country: 'Ukraine', | ||
honor_code: true, | ||
totalRegistrationTime: 0, | ||
}; | ||
|
||
store.dispatch = jest.fn(store.dispatch); | ||
const { getByLabelText, container } = render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />))); | ||
populateRequiredFields(getByLabelText, formPayload, true); | ||
|
||
const button = container.querySelector('button.btn-brand'); | ||
fireEvent.click(button); | ||
|
||
const validationErrors = container.querySelector('#validation-errors'); | ||
expect(validationErrors.textContent).toContain(emailError); | ||
}); | ||
|
||
it('should display an error when form is submitted with an invalid username', () => { | ||
jest.spyOn(global.Date, 'now').mockImplementation(() => 0); | ||
const usernameError = "We couldn't create your account.Please check your responses and try again."; | ||
|
||
const formPayload = { | ||
name: 'Petro', | ||
username: 'petro qa', | ||
email: '[email protected]', | ||
password: 'password1', | ||
country: 'Ukraine', | ||
honor_code: true, | ||
totalRegistrationTime: 0, | ||
}; | ||
|
||
store.dispatch = jest.fn(store.dispatch); | ||
const { getByLabelText, container } = render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />))); | ||
populateRequiredFields(getByLabelText, formPayload, true); | ||
const button = container.querySelector('button.btn-brand'); | ||
fireEvent.click(button); | ||
const validationErrors = container.querySelector('#validation-errors'); | ||
expect(validationErrors.textContent).toContain(usernameError); | ||
}); | ||
|
||
it('should submit form with marketing email opt in value', () => { | ||
mergeConfig({ | ||
MARKETING_EMAILS_OPT_IN: 'true', | ||
|
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 |
---|---|---|
|
@@ -348,6 +348,49 @@ describe('ConfigurableRegistrationForm', () => { | |
expect(confirmEmailErrorElement.textContent).toEqual('The email addresses do not match.'); | ||
}); | ||
|
||
it('should show error if email and confirm email fields do not match on submit click', () => { | ||
const formPayload = { | ||
name: 'Petro', | ||
username: 'petro_qa', | ||
email: '[email protected]', | ||
password: 'password1', | ||
country: 'Ukraine', | ||
honor_code: true, | ||
totalRegistrationTime: 0, | ||
}; | ||
|
||
store = mockStore({ | ||
...initialState, | ||
commonComponents: { | ||
...initialState.commonComponents, | ||
fieldDescriptions: { | ||
confirm_email: { | ||
name: 'confirm_email', type: 'text', label: 'Confirm Email', | ||
}, | ||
country: { name: 'country' }, | ||
}, | ||
}, | ||
}); | ||
const { getByLabelText, container } = render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />))); | ||
|
||
populateRequiredFields(getByLabelText, formPayload, true); | ||
fireEvent.change( | ||
getByLabelText('Confirm Email'), | ||
{ target: { value: '[email protected]', name: 'confirm_email' } }, | ||
); | ||
|
||
const button = container.querySelector('button.btn-brand'); | ||
fireEvent.click(button); | ||
|
||
const confirmEmailErrorElement = container.querySelector('div#confirm_email-error'); | ||
expect(confirmEmailErrorElement.textContent).toEqual('The email addresses do not match.'); | ||
|
||
const validationErrors = container.querySelector('#validation-errors'); | ||
expect(validationErrors.textContent).toContain( | ||
"We couldn't create your account.Please check your responses and try again.", | ||
); | ||
}); | ||
|
||
it('should run validations for configurable focused field on form submission', () => { | ||
const professionError = 'Enter your profession'; | ||
store = mockStore({ | ||
|
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
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