Skip to content

Commit

Permalink
fix: update MFE context (#731)
Browse files Browse the repository at this point in the history
VAN-1231
  • Loading branch information
syedsajjadkazmii authored Jan 16, 2023
1 parent 1537868 commit 49c9126
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 30 deletions.
13 changes: 1 addition & 12 deletions src/common-components/data/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
Expand Down
5 changes: 0 additions & 5 deletions src/common-components/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions src/common-components/data/tests/reducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,7 +18,6 @@ describe('common components reducer', () => {
};
const fieldDescriptions = {
fields: [],
extended_profile: {},
};
const optionalFields = {
fields: [],
Expand All @@ -36,11 +34,10 @@ describe('common components reducer', () => {
).toEqual(
{
...state,
extendedProfile: [],
fieldDescriptions: [],
optionalFields: {
fields: [],
extended_profile: [],
extended_profile: {},
},
thirdPartyAuthApiStatus: 'complete',
},
Expand Down
5 changes: 1 addition & 4 deletions src/register/RegistrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -681,7 +679,6 @@ RegistrationPage.defaultProps = {
},
backendCountryCode: '',
backendValidations: null,
extendedProfile: [],
fieldDescriptions: {},
optionalFields: {},
registrationErrorCode: '',
Expand Down
2 changes: 1 addition & 1 deletion src/register/registrationFields/HonorCode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const HonorCode = (props) => {
>
<FormattedMessage
id="register.page.honor.code"
defaultMessage="I agree to the {platformName} {tosAndHonorCode}"
defaultMessage="I agree to the {platformName}&nbsp;{tosAndHonorCode}"
description="Text that appears on registration form stating honor code"
values={{
platformName: getConfig().SITE_NAME,
Expand Down
2 changes: 1 addition & 1 deletion src/register/registrationFields/TermsOfService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TermsOfService = (props) => {
>
<FormattedMessage
id="register.page.terms.of.service"
defaultMessage="I agree to the {platformName} {termsOfService}"
defaultMessage="I agree to the {platformName}&nbsp;{termsOfService}"
description="Text that appears on registration form stating terms of service.
It is a legal document that users must agree to."
values={{
Expand Down
2 changes: 1 addition & 1 deletion src/register/tests/HonorCode.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('HonorCodeTest', () => {
});

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(
<IntlProvider locale="en">
<IntlHonorCode onChangeHandler={changeHandler} />
Expand Down
2 changes: 1 addition & 1 deletion src/register/tests/TermsOfService.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('TermsOfServiceTest', () => {
<IntlTermsOfService onChangeHandler={changeHandler} />
</IntlProvider>,
);
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);
});
Expand Down

0 comments on commit 49c9126

Please sign in to comment.