Skip to content

Commit

Permalink
feat: pick required fields from tpa context (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-amir authored Jan 17, 2023
1 parent 49c9126 commit 8ad2678
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/register/RegistrationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { sendPageEvent } from '@edx/frontend-platform/analytics';
import {
getCountryList, getLocale, injectIntl,
} from '@edx/frontend-platform/i18n';
import { logError } from '@edx/frontend-platform/logging';
import { Form, StatefulButton } from '@edx/paragon';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
Expand Down Expand Up @@ -105,7 +104,10 @@ const RegistrationPage = (props) => {
if (!userPipelineDataLoaded) {
const { pipelineUserDetails } = thirdPartyAuthContext;
if (pipelineUserDetails && Object.keys(pipelineUserDetails).length !== 0) {
setFormFields(prevState => ({ ...prevState, ...pipelineUserDetails }));
const { name = '', username = '', email = '' } = pipelineUserDetails;
setFormFields(prevState => ({
...prevState, name, username, email,
}));
setUserPipelineDetailsLoaded(true);
}
}
Expand Down Expand Up @@ -295,9 +297,6 @@ const RegistrationPage = (props) => {
const fieldErrors = { ...errors };
let isValid = !focusedFieldError;
Object.keys(payload).forEach(key => {
if (!['name', 'email', 'username', 'password', 'country'].includes(key)) {
logError(`Key ${key} found in the payload`);
}
if (!payload[key]) {
fieldErrors[key] = intl.formatMessage(messages[`empty.${key}.field.error`]);
}
Expand Down
4 changes: 0 additions & 4 deletions src/register/tests/RegistrationPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';

import { AUTHN_PROGRESSIVE_PROFILING, COMPLETE_STATE, PENDING_STATE } from '../../data/constants';
import initializeMockLogging from '../../setupTest';
import {
backupRegistrationFormBegin,
clearUsernameSuggestions,
Expand All @@ -28,8 +27,6 @@ import {
import RegistrationFailureMessage from '../RegistrationFailure';
import RegistrationPage from '../RegistrationPage';

const { loggingService } = initializeMockLogging();

jest.mock('@edx/frontend-platform/analytics');
jest.mock('@edx/frontend-platform/i18n', () => ({
...jest.requireActual('@edx/frontend-platform/i18n'),
Expand Down Expand Up @@ -98,7 +95,6 @@ describe('RegistrationPage', () => {

beforeEach(() => {
store = mockStore(initialState);
loggingService.logError.mockReset();
configure({
loggingService: { logError: jest.fn() },
config: {
Expand Down

0 comments on commit 8ad2678

Please sign in to comment.