From e0485db0f5b6987e31d2fe092a499f338283706d Mon Sep 17 00:00:00 2001 From: uzairr Date: Mon, 28 Dec 2020 18:38:19 +0500 Subject: [PATCH] add enterprise login link --- src/data/constants.js | 6 ++-- .../tests/ForgotPasswordPage.test.jsx | 2 +- src/logistration/LoginHelpLinks.jsx | 6 +++- src/logistration/LoginPage.jsx | 10 ++++++- src/logistration/messages.jsx | 5 ++++ .../tests/LoginHelpLinks.test.jsx | 6 ++-- src/logistration/tests/LoginPage.test.jsx | 2 +- .../__snapshots__/LoginPage.test.jsx.snap | 30 +++++++++++++++++++ 8 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/data/constants.js b/src/data/constants.js index 969d2edd..f8ed2adb 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -5,13 +5,15 @@ export const RESET_PAGE = '/reset'; export const DEFAULT_REDIRECT_URL = '/dashboard'; export const PASSWORD_RESET_CONFIRM = '/password_reset_confirm/:token/'; export const PAGE_NOT_FOUND = '/notfound'; +export const ENTERPRISE_LOGIN_URL = '/enterprise/login'; + +// Constants +export const SUPPORTED_ICON_CLASSES = ['apple', 'facebook', 'google', 'microsoft']; // Stateful Submit Button States export const DEFAULT_STATE = 'default'; export const PENDING_STATE = 'pending'; -// Constants -export const SUPPORTED_ICON_CLASSES = ['apple', 'facebook', 'google', 'microsoft']; export const REGISTRATION_VALIDITY_MAP = {}; export const REGISTRATION_OPTIONAL_MAP = {}; export const REGISTRATION_EXTRA_FIELDS = [ diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index 38e9bb09..178f266c 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -77,7 +77,7 @@ describe('ForgotPasswordPage', () => { it('should display need other help signing in button', () => { const wrapper = mount(reduxWrapper()); - expect(wrapper.find('button.field-link').text()).toEqual('Need other help signing in?'); + expect(wrapper.find('button.field-link').first().text()).toEqual('Need other help signing in?'); }); it('should display email validation error message', async () => { diff --git a/src/logistration/LoginHelpLinks.jsx b/src/logistration/LoginHelpLinks.jsx index 7b01affc..6f90d8f7 100644 --- a/src/logistration/LoginHelpLinks.jsx +++ b/src/logistration/LoginHelpLinks.jsx @@ -5,7 +5,11 @@ import { faCaretDown, faCaretRight } from '@fortawesome/free-solid-svg-icons'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import SwitchContent from './SwitchContent'; -import { LOGIN_PAGE, REGISTER_PAGE, RESET_PAGE } from '../data/constants'; +import { + LOGIN_PAGE, + REGISTER_PAGE, + RESET_PAGE, +} from '../data/constants'; import messages from './messages'; const LoginHelpLinks = (props) => { diff --git a/src/logistration/LoginPage.jsx b/src/logistration/LoginPage.jsx index b6626e65..74c7b07e 100644 --- a/src/logistration/LoginPage.jsx +++ b/src/logistration/LoginPage.jsx @@ -5,6 +5,7 @@ import { Input, StatefulButton, ValidationFormGroup } from '@edx/paragon'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { getConfig } from '@edx/frontend-platform'; import ConfirmationAlert from './ConfirmationAlert'; import { getThirdPartyAuthContext, loginRequest } from './data/actions'; import { loginErrorSelector, loginRequestSelector, thirdPartyAuthContextSelector } from './data/selectors'; @@ -17,7 +18,7 @@ import SocialAuthProviders from './SocialAuthProviders'; import ThirdPartyAuthAlert from './ThirdPartyAuthAlert'; import { - DEFAULT_REDIRECT_URL, DEFAULT_STATE, LOGIN_PAGE, REGISTER_PAGE, + DEFAULT_REDIRECT_URL, DEFAULT_STATE, LOGIN_PAGE, REGISTER_PAGE, ENTERPRISE_LOGIN_URL, } from '../data/constants'; import { forgotPasswordResultSelector } from '../forgot-password'; @@ -47,6 +48,10 @@ class LoginPage extends React.Component { this.props.getThirdPartyAuthContext(payload); } + getEnterPriseLoginURL() { + return getConfig().LMS_BASE_URL + ENTERPRISE_LOGIN_URL; + } + handleInstitutionLogin = () => { this.setState(prevState => ({ institutionLogin: !prevState.institutionLogin })); } @@ -211,6 +216,9 @@ class LoginPage extends React.Component { + + {intl.formatMessage(messages['logistration.enterprise.login.help.message'])} + { const loginHelpLinks = mount(reduxWrapper()); expect(loginHelpLinks.find('.login-help').length).toBe(0); - loginHelpLinks.find('button').simulate('click'); + loginHelpLinks.find('button').first().simulate('click'); expect(loginHelpLinks.find('.login-help').length).toBe(1); }); @@ -34,7 +34,7 @@ describe('LoginHelpLinks', () => { }; const wrapper = mount(reduxWrapper()); - wrapper.find('button').simulate('click'); + wrapper.find('button').first().simulate('click'); const loginHelpLinks = wrapper.find('a'); @@ -49,7 +49,7 @@ describe('LoginHelpLinks', () => { }; const wrapper = mount(reduxWrapper()); - wrapper.find('button').simulate('click'); + wrapper.find('button').first().simulate('click'); const loginHelpLinks = wrapper.find('a'); diff --git a/src/logistration/tests/LoginPage.test.jsx b/src/logistration/tests/LoginPage.test.jsx index 118ebd50..3df38d32 100644 --- a/src/logistration/tests/LoginPage.test.jsx +++ b/src/logistration/tests/LoginPage.test.jsx @@ -119,7 +119,7 @@ describe('LoginPage', () => { it('should display login help button', () => { const root = mount(reduxWrapper()); - expect(root.find('button.field-link').text()).toEqual('Need help signing in?'); + expect(root.find('button.field-link').first().text()).toEqual('Need help signing in?'); }); it('updates the error state for invalid email', () => { diff --git a/src/logistration/tests/__snapshots__/LoginPage.test.jsx.snap b/src/logistration/tests/__snapshots__/LoginPage.test.jsx.snap index 8b3ee6c1..d565cde8 100644 --- a/src/logistration/tests/__snapshots__/LoginPage.test.jsx.snap +++ b/src/logistration/tests/__snapshots__/LoginPage.test.jsx.snap @@ -151,6 +151,12 @@ exports[`LoginPage should match TPA provider snapshot 1`] = ` } /> + + !!! Missing message supplied to intl.formatMessage !!! +