Skip to content

Commit

Permalink
feat: Remove simplify registration experiment code (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque authored Mar 15, 2024
1 parent f53add8 commit 3635476
Show file tree
Hide file tree
Showing 20 changed files with 122 additions and 611 deletions.
6 changes: 0 additions & 6 deletions src/common-components/messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ const messages = defineMessages({
defaultMessage: 'Company or school credentials',
description: 'Company or school login link text.',
},
// simplify registration experiment messages
'tab.back.btn.text': {
id: 'tab.back.btn.text',
defaultMessage: 'Back',
description: 'Tab back button text',
},
});

export default messages;
2 changes: 0 additions & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const configuration = {
ZENDESK_LOGO_URL: process.env.ZENDESK_LOGO_URL,
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID || '',
ALGOLIA_SEARCH_API_KEY: process.env.ALGOLIA_SEARCH_API_KEY || '',
// Simplify Registration Experiment
SIMPLIFY_REGISTRATION_EXPERIMENT_ID: process.env.SIMPLIFY_REGISTRATION_EXPERIMENT_ID || '',
};

export default configuration;
51 changes: 10 additions & 41 deletions src/logistration/Logistration.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { useEffect, useState } from 'react';
import { connect, useDispatch, useSelector } from 'react-redux';
import { connect } from 'react-redux';

import { getConfig } from '@edx/frontend-platform';
import { sendPageEvent, sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getAuthService } from '@edx/frontend-platform/auth';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Icon, IconButton,
Icon,
Tab,
Tabs,
} from '@openedx/paragon';
import { ArrowBackIos, ChevronLeft } from '@openedx/paragon/icons';
import { ChevronLeft } from '@openedx/paragon/icons';
import PropTypes from 'prop-types';
import { Navigate, useNavigate } from 'react-router-dom';

Expand All @@ -27,8 +27,7 @@ import {
import { LoginPage } from '../login';
import { backupLoginForm } from '../login/data/actions';
import { RegistrationPage } from '../register';
import { backupRegistrationForm, setSimplifyRegExperimentData } from '../register/data/actions';
import { FIRST_STEP, SECOND_STEP } from '../register/data/optimizelyExperiment/helper';
import { backupRegistrationForm } from '../register/data/actions';

const Logistration = (props) => {
const { selectedPage, tpaProviders } = props;
Expand All @@ -43,9 +42,6 @@ const Logistration = (props) => {
const disablePublicAccountCreation = getConfig().ALLOW_PUBLIC_ACCOUNT_CREATION === false;
const hideRegistrationLink = getConfig().SHOW_REGISTRATION_LINKS === false;

const dispatch = useDispatch();
const { simplifyRegExpVariation, simplifiedRegisterPageStep } = useSelector(state => state.register);

useEffect(() => {
const authService = getAuthService();
if (authService) {
Expand Down Expand Up @@ -100,38 +96,6 @@ const Logistration = (props) => {
return !!provider;
};

/**
* Temporary function created to resolve the complexity in tabs conditioning for simplify
* registration experiment
*/
const getTabs = () => {
if (simplifiedRegisterPageStep === SECOND_STEP) {
return (
<div>
<IconButton
key="primary"
src={ArrowBackIos}
iconAs={Icon}
alt="Back"
onClick={() => {
dispatch(setSimplifyRegExperimentData(simplifyRegExpVariation, FIRST_STEP));
}}
variant="primary"
size="inline"
className="mr-1"
/>
{formatMessage(messages['tab.back.btn.text'])}
</div>
);
}
return (
<Tabs defaultActiveKey={selectedPage} id="controlled-tab" onSelect={(tabKey) => handleOnSelect(tabKey, selectedPage)}>
<Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} />
<Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} />
</Tabs>
);
};

return (
<BaseContainer>
<div>
Expand Down Expand Up @@ -159,7 +123,12 @@ const Logistration = (props) => {
<Tab title={tabTitle} eventKey={selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE} />
</Tabs>
)
: (!isValidTpaHint() && !hideRegistrationLink && getTabs())}
: (!isValidTpaHint() && !hideRegistrationLink && (
<Tabs defaultActiveKey={selectedPage} id="controlled-tab" onSelect={(tabKey) => handleOnSelect(tabKey, selectedPage)}>
<Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} />
<Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} />
</Tabs>
))}
{ key && (
<Navigate to={updatePathWithQueryParams(key)} replace />
)}
Expand Down
4 changes: 0 additions & 4 deletions src/logistration/Logistration.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ import {
} from '../data/constants';
import { backupLoginForm } from '../login/data/actions';
import { backupRegistrationForm } from '../register/data/actions';
import useSimplifyRegistrationExperimentVariation
from '../register/data/optimizelyExperiment/useSimplifyRegistrationExperimentVariation';

jest.mock('@edx/frontend-platform/analytics', () => ({
sendPageEvent: jest.fn(),
sendTrackEvent: jest.fn(),
}));
jest.mock('@edx/frontend-platform/auth');
jest.mock('../register/data/optimizelyExperiment/useSimplifyRegistrationExperimentVariation', () => jest.fn());

const mockStore = configureStore();
const IntlLogistration = injectIntl(Logistration);
Expand Down Expand Up @@ -86,7 +83,6 @@ describe('Logistration', () => {
username: 'test-user',
})),
}));
useSimplifyRegistrationExperimentVariation.mockReturnValue('default-register-page');

configure({
loggingService: { logError: jest.fn() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const UsernameField = (props) => {
event.preventDefault();
handleErrorChange('username', ''); // clear error
handleChange({ target: { name: 'username', value: suggestion } }); // to set suggestion as value
dispatch(clearUsernameSuggestions(true));
dispatch(clearUsernameSuggestions());
};

const handleUsernameSuggestionClose = () => {
Expand Down
Loading

0 comments on commit 3635476

Please sign in to comment.