Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.

This commit is contained in:
picklesrus 2019-11-05 11:54:20 -05:00
parent e4b79c1bd2
commit 30967a3056
8 changed files with 30 additions and 4 deletions

View file

@ -167,7 +167,7 @@ class BirthDateStep extends React.Component {
BirthDateStep.propTypes = { BirthDateStep.propTypes = {
intl: intlShape, intl: intlShape,
onNextStep: PropTypes.func, onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func sendAnalytics: PropTypes.func.isRequired
}; };
const IntlBirthDateStep = injectIntl(BirthDateStep); const IntlBirthDateStep = injectIntl(BirthDateStep);

View file

@ -122,7 +122,7 @@ class CountryStep extends React.Component {
CountryStep.propTypes = { CountryStep.propTypes = {
intl: intlShape, intl: intlShape,
onNextStep: PropTypes.func, onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func sendAnalytics: PropTypes.func.isRequired
}; };
const IntlCountryStep = injectIntl(CountryStep); const IntlCountryStep = injectIntl(CountryStep);

View file

@ -235,8 +235,12 @@ EmailStep.propTypes = {
<<<<<<< HEAD <<<<<<< HEAD
======= =======
onRegistrationError: PropTypes.func, onRegistrationError: PropTypes.func,
<<<<<<< HEAD
sendAnalytics: PropTypes.func, sendAnalytics: PropTypes.func,
>>>>>>> Add analytics logging to join flow. Adding page views for each step in the flow. >>>>>>> Add analytics logging to join flow. Adding page views for each step in the flow.
=======
sendAnalytics: PropTypes.func.isRequired,
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
waiting: PropTypes.bool waiting: PropTypes.bool
}; };

View file

@ -184,7 +184,7 @@ class GenderStep extends React.Component {
GenderStep.propTypes = { GenderStep.propTypes = {
intl: intlShape, intl: intlShape,
onNextStep: PropTypes.func, onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func sendAnalytics: PropTypes.func.isRequired
}; };
module.exports = injectIntl(GenderStep); module.exports = injectIntl(GenderStep);

View file

@ -233,7 +233,12 @@ class JoinFlow extends React.Component {
{this.state.registrationError ? ( {this.state.registrationError ? (
<RegistrationErrorStep <RegistrationErrorStep
canTryAgain={this.canTryAgain()} canTryAgain={this.canTryAgain()}
<<<<<<< HEAD
errorMsg={this.state.registrationError.errorMsg} errorMsg={this.state.registrationError.errorMsg}
=======
errorMsg={this.state.registrationError}
sendAnalytics={this.sendAnalytics}
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
/* eslint-disable react/jsx-no-bind */ /* eslint-disable react/jsx-no-bind */
onSubmit={this.handleErrorNext} onSubmit={this.handleErrorNext}
/* eslint-enable react/jsx-no-bind */ /* eslint-enable react/jsx-no-bind */

View file

@ -63,12 +63,17 @@ RegistrationErrorStep.propTypes = {
canTryAgain: PropTypes.bool.isRequired, canTryAgain: PropTypes.bool.isRequired,
errorMsg: PropTypes.string, errorMsg: PropTypes.string,
intl: intlShape, intl: intlShape,
<<<<<<< HEAD
onSubmit: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired,
sendAnalytics: PropTypes.func.isRequired sendAnalytics: PropTypes.func.isRequired
}; };
RegistrationErrorStep.defaultProps = { RegistrationErrorStep.defaultProps = {
canTryAgain: false canTryAgain: false
=======
onSubmit: PropTypes.func,
sendAnalytics: PropTypes.func.isRequired
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
}; };
const IntlRegistrationErrorStep = injectIntl(RegistrationErrorStep); const IntlRegistrationErrorStep = injectIntl(RegistrationErrorStep);

View file

@ -289,7 +289,7 @@ class UsernameStep extends React.Component {
UsernameStep.propTypes = { UsernameStep.propTypes = {
intl: intlShape, intl: intlShape,
onNextStep: PropTypes.func, onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func sendAnalytics: PropTypes.func.isRequired
}; };
const IntlUsernameStep = injectIntl(UsernameStep); const IntlUsernameStep = injectIntl(UsernameStep);

View file

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import {shallowWithIntl} from '../../helpers/intl-helpers.jsx'; import {shallowWithIntl} from '../../helpers/intl-helpers.jsx';
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
import JoinFlowStep from '../../../src/components/join-flow/join-flow-step'; import JoinFlowStep from '../../../src/components/join-flow/join-flow-step';
import RegistrationErrorStep from '../../../src/components/join-flow/registration-error-step'; import RegistrationErrorStep from '../../../src/components/join-flow/registration-error-step';
@ -21,6 +22,7 @@ describe('RegistrationErrorStep', () => {
return wrapper return wrapper
.dive(); // unwrap injectIntl() .dive(); // unwrap injectIntl()
}; };
<<<<<<< HEAD
test('registrationError has JoinFlowStep', () => { test('registrationError has JoinFlowStep', () => {
const props = { const props = {
@ -67,6 +69,16 @@ describe('RegistrationErrorStep', () => {
expect(errMsgElement).toHaveLength(0); expect(errMsgElement).toHaveLength(0);
}); });
=======
test('logs to analytics', () => {
const analyticsFn = jest.fn();
mountWithIntl(
<RegistrationErrorStep
sendAnalytics={analyticsFn}
/>);
expect(analyticsFn).toHaveBeenCalledWith('join-error');
});
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
test('when canTryAgain is true, show tryAgain message', () => { test('when canTryAgain is true, show tryAgain message', () => {
const props = { const props = {
canTryAgain: true, canTryAgain: true,