From 49c91262fdf6674dd20f5821e3627277af263190 Mon Sep 17 00:00:00 2001 From: Syed Sajjad Hussain Shah <52817156+syedsajjadkazmii@users.noreply.github.com> Date: Mon, 16 Jan 2023 18:36:49 +0500 Subject: [PATCH] fix: update MFE context (#731) VAN-1231 --- src/common-components/data/reducers.js | 13 +------------ src/common-components/data/selectors.js | 5 ----- src/common-components/data/tests/reducer.test.js | 7 ++----- src/register/RegistrationPage.jsx | 5 +---- src/register/registrationFields/HonorCode.jsx | 2 +- src/register/registrationFields/TermsOfService.jsx | 2 +- src/register/tests/HonorCode.test.jsx | 2 +- src/register/tests/TermsOfService.test.jsx | 2 +- 8 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/common-components/data/reducers.js b/src/common-components/data/reducers.js index 58c1f97119..f2d32e704b 100644 --- a/src/common-components/data/reducers.js +++ b/src/common-components/data/reducers.js @@ -2,7 +2,6 @@ import { COMPLETE_STATE, PENDING_STATE } from '../../data/constants'; import { THIRD_PARTY_AUTH_CONTEXT } from './actions'; export const defaultState = { - extendedProfile: [], fieldDescriptions: {}, optionalFields: {}, thirdPartyAuthApiStatus: null, @@ -24,20 +23,10 @@ const reducer = (state = defaultState, action) => { thirdPartyAuthApiStatus: PENDING_STATE, }; case THIRD_PARTY_AUTH_CONTEXT.SUCCESS: { - const extendedProfile = action.payload.optionalFields.extended_profile; - let extendedProfileArray = []; - if (extendedProfile && Object.keys(extendedProfile).length !== 0) { - extendedProfileArray = extendedProfile; - } - return { ...state, - extendedProfile: extendedProfileArray, fieldDescriptions: action.payload.fieldDescriptions.fields, - optionalFields: { - ...action.payload.optionalFields, - extended_profile: extendedProfileArray, - }, + optionalFields: action.payload.optionalFields, thirdPartyAuthContext: action.payload.thirdPartyAuthContext, thirdPartyAuthApiStatus: COMPLETE_STATE, }; diff --git a/src/common-components/data/selectors.js b/src/common-components/data/selectors.js index d1b32aa4bf..2faa24ce07 100644 --- a/src/common-components/data/selectors.js +++ b/src/common-components/data/selectors.js @@ -14,11 +14,6 @@ export const fieldDescriptionSelector = createSelector( commonComponents => commonComponents.fieldDescriptions, ); -export const extendedProfileSelector = createSelector( - commonComponentsSelector, - commonComponents => commonComponents.extendedProfile, -); - export const optionalFieldsSelector = createSelector( commonComponentsSelector, commonComponents => commonComponents.optionalFields, diff --git a/src/common-components/data/tests/reducer.test.js b/src/common-components/data/tests/reducer.test.js index a712ff69a9..986c83f87a 100644 --- a/src/common-components/data/tests/reducer.test.js +++ b/src/common-components/data/tests/reducer.test.js @@ -2,9 +2,8 @@ import { THIRD_PARTY_AUTH_CONTEXT } from '../actions'; import reducer from '../reducers'; describe('common components reducer', () => { - it('should convert empty extended profile object to array', () => { + it('test mfe context response', () => { const state = { - extendedProfile: [], fieldDescriptions: {}, optionalFields: {}, thirdPartyAuthApiStatus: null, @@ -19,7 +18,6 @@ describe('common components reducer', () => { }; const fieldDescriptions = { fields: [], - extended_profile: {}, }; const optionalFields = { fields: [], @@ -36,11 +34,10 @@ describe('common components reducer', () => { ).toEqual( { ...state, - extendedProfile: [], fieldDescriptions: [], optionalFields: { fields: [], - extended_profile: [], + extended_profile: {}, }, thirdPartyAuthApiStatus: 'complete', }, diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index 039ec099a3..a90b6a369d 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -19,7 +19,7 @@ import { } from '../common-components'; import { getThirdPartyAuthContext } from '../common-components/data/actions'; import { - extendedProfileSelector, fieldDescriptionSelector, optionalFieldsSelector, thirdPartyAuthContextSelector, + fieldDescriptionSelector, optionalFieldsSelector, thirdPartyAuthContextSelector, } from '../common-components/data/selectors'; import EnterpriseSSO from '../common-components/EnterpriseSSO'; import { @@ -595,7 +595,6 @@ const mapStateToProps = state => { backendCountryCode: registerPageState.backendCountryCode, backendValidations: validationsSelector(state), fieldDescriptions: fieldDescriptionSelector(state), - extendedProfile: extendedProfileSelector(state), optionalFields: optionalFieldsSelector(state), registrationErrorCode: registrationErrorSelector(state), registrationResult: registerPageState.registrationResult, @@ -623,7 +622,6 @@ RegistrationPage.propTypes = { username: PropTypes.string, password: PropTypes.string, }), - extendedProfile: PropTypes.arrayOf(PropTypes.string), fieldDescriptions: PropTypes.shape({}), institutionLogin: PropTypes.bool.isRequired, intl: PropTypes.objectOf(PropTypes.object).isRequired, @@ -681,7 +679,6 @@ RegistrationPage.defaultProps = { }, backendCountryCode: '', backendValidations: null, - extendedProfile: [], fieldDescriptions: {}, optionalFields: {}, registrationErrorCode: '', diff --git a/src/register/registrationFields/HonorCode.jsx b/src/register/registrationFields/HonorCode.jsx index 3046ae651d..3a906e1bd3 100644 --- a/src/register/registrationFields/HonorCode.jsx +++ b/src/register/registrationFields/HonorCode.jsx @@ -56,7 +56,7 @@ const HonorCode = (props) => { > { > { }); it('should render Honor code field', () => { - const expectedMsg = 'I agree to the Your Platform Name Here Honor Codein a new tab'; + const expectedMsg = 'I agree to the Your Platform Name Here\u00a0Honor Codein a new tab'; const honorCode = mount( diff --git a/src/register/tests/TermsOfService.test.jsx b/src/register/tests/TermsOfService.test.jsx index a1bd6d3745..b0c7b83230 100644 --- a/src/register/tests/TermsOfService.test.jsx +++ b/src/register/tests/TermsOfService.test.jsx @@ -35,7 +35,7 @@ describe('TermsOfServiceTest', () => { , ); - const expectedMsg = 'I agree to the Your Platform Name Here Terms of Servicein a new tab'; + const expectedMsg = 'I agree to the Your Platform Name Here\u00a0Terms of Servicein a new tab'; expect(termsOfService.find('#terms-of-service').find('label').text()).toEqual(expectedMsg); expect(value).toEqual(false); });