diff --git a/src/logistration/RegistrationPage.jsx b/src/logistration/RegistrationPage.jsx index ec29f864..8aa86440 100644 --- a/src/logistration/RegistrationPage.jsx +++ b/src/logistration/RegistrationPage.jsx @@ -251,9 +251,12 @@ class RegistrationPage extends React.Component { } }); - this.setState({ - formValid: emailValid && nameValid && usernameValid && passwordValid && extraFieldsValid, - }); + let formValid = emailValid && nameValid && usernameValid && extraFieldsValid; + if (!this.props.thirdPartyAuthContext.currentProvider) { + formValid = formValid && passwordValid; + } + + this.setState({ formValid }); } addExtraRequiredFields() { @@ -499,25 +502,27 @@ class RegistrationPage extends React.Component { required /> - - - this.handleOnChange(e)} - onBlur={e => this.handleOnBlur(e)} - required - /> - + {!currentProvider && ( + + + this.handleOnChange(e)} + onBlur={e => this.handleOnBlur(e)} + required + /> + + )} { this.addExtraRequiredFields() } { logistration: { registrationResult: { success: false, redirectUrl: '' }, thirdPartyAuthContext: { + platformName: 'openedX', currentProvider: null, finishAuthUrl: null, providers: [], @@ -288,6 +289,22 @@ describe('./RegistrationPage.js', () => { expect(tree).toMatchSnapshot(); }); + it('should display no password field when current provider is present', () => { + store = mockStore({ + ...initialState, + logistration: { + ...initialState.logistration, + thirdPartyAuthContext: { + ...initialState.logistration.thirdPartyAuthContext, + currentProvider: 'Google', + }, + }, + }); + + const tree = renderer.create(reduxWrapper()).toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('should match url after redirection', () => { const dasboardUrl = 'http://test.com/testing-dashboard/'; store = mockStore({ @@ -403,13 +420,12 @@ describe('./RegistrationPage.js', () => { thirdPartyAuthContext: { ...initialState.logistration.thirdPartyAuthContext, currentProvider: 'Apple', - platformName: 'edX', }, }, }); const expectedMessage = 'You\'ve successfully signed into Apple. We just need a little more information before ' - + 'you start learning with edX.'; + + 'you start learning with openedX.'; const loginPage = mount(reduxWrapper()); expect(loginPage.find('#tpa-alert').find('span').text()).toEqual(expectedMessage); diff --git a/src/logistration/tests/__snapshots__/RegistrationPage.test.jsx.snap b/src/logistration/tests/__snapshots__/RegistrationPage.test.jsx.snap index e6ffac48..63cec7d2 100644 --- a/src/logistration/tests/__snapshots__/RegistrationPage.test.jsx.snap +++ b/src/logistration/tests/__snapshots__/RegistrationPage.test.jsx.snap @@ -1,5 +1,169 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`./RegistrationPage.js should display no password field when current provider is present 1`] = ` +
+ +
+ + Already have an edX account? + + + Sign in. + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + I agree to the Your Platform Name Here + + Honor Code + + + + You must agree to the Your Platform Name Here Honor Code + +
+
+ + +
+ +
+
+`; + exports[`./RegistrationPage.js should match TPA provider snapshot 1`] = `