diff --git a/src/applications/static-pages/cta-widget/components/messages/RegisterFailed.jsx b/src/applications/static-pages/cta-widget/components/messages/RegisterFailed.jsx index f2f172d03310..817de3f1b39a 100644 --- a/src/applications/static-pages/cta-widget/components/messages/RegisterFailed.jsx +++ b/src/applications/static-pages/cta-widget/components/messages/RegisterFailed.jsx @@ -1,12 +1,11 @@ import React from 'react'; -import PropTypes from 'prop-types'; import AdditionalInfo from '@department-of-veterans-affairs/component-library/AdditionalInfo'; import Telephone, { CONTACTS, } from '@department-of-veterans-affairs/component-library/Telephone'; import CallToActionAlert from '../CallToActionAlert'; -const RegisterFailed = ({ createAndUpgradeMHVAccount }) => { +const RegisterFailed = () => { const content = { heading: 'We couldn’t create a MyHealtheVet account for you', alertText: ( @@ -16,24 +15,11 @@ const RegisterFailed = ({ createAndUpgradeMHVAccount }) => { use our online health tools, you’ll need to create an account.

What you can do
-

Please try again.

- -

- - If you try again and continue to see this error, you can create a My - HealtheVet account in one of these ways: - -

- Call us at 877-327-0022. We’re here - Monday through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have - hearing loss, call TTY: . + Call us at . We’re here Monday + through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have hearing loss, + call TTY: .

Tell the representative that you tried to sign in to use the online @@ -92,8 +78,4 @@ const RegisterFailed = ({ createAndUpgradeMHVAccount }) => { return ; }; -RegisterFailed.propTypes = { - createAndUpgradeMHVAccount: PropTypes.func.isRequired, -}; - export default RegisterFailed; diff --git a/src/applications/static-pages/cta-widget/components/messages/UpgradeFailed.jsx b/src/applications/static-pages/cta-widget/components/messages/UpgradeFailed.jsx index eff5a5c99b28..c7dc8619d493 100644 --- a/src/applications/static-pages/cta-widget/components/messages/UpgradeFailed.jsx +++ b/src/applications/static-pages/cta-widget/components/messages/UpgradeFailed.jsx @@ -1,12 +1,11 @@ import React from 'react'; -import PropTypes from 'prop-types'; import AdditionalInfo from '@department-of-veterans-affairs/component-library/AdditionalInfo'; import Telephone, { CONTACTS, } from '@department-of-veterans-affairs/component-library/Telephone'; import CallToActionAlert from '../CallToActionAlert'; -const UpgradeFailed = ({ upgradeMHVAccount }) => { +const UpgradeFailed = () => { const content = { heading: 'We couldn’t upgrade your My HealtheVet account', alertText: ( @@ -17,21 +16,11 @@ const UpgradeFailed = ({ upgradeMHVAccount }) => { until we can fix the problem.

What you can do
-

Please try again.

- -

- - If you try again and continue to see this error, you can upgrade - your My HealtheVet account in one of these ways: - -

- Call us at 877-327-0022. We’re here - Monday through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have - hearing loss, call TTY: . + Call us at . We’re here Monday + through Friday, 8:00 a.m. to 8:00 p.m. ET. If you have hearing loss, + call TTY: .

Tell the representative that you tried to sign in to use the online @@ -90,8 +79,4 @@ const UpgradeFailed = ({ upgradeMHVAccount }) => { return ; }; -UpgradeFailed.propTypes = { - upgradeMHVAccount: PropTypes.func.isRequired, -}; - export default UpgradeFailed; diff --git a/src/applications/static-pages/cta-widget/index.js b/src/applications/static-pages/cta-widget/index.js index ed8d4ce6fc51..b2c5658ec5b4 100644 --- a/src/applications/static-pages/cta-widget/index.js +++ b/src/applications/static-pages/cta-widget/index.js @@ -8,11 +8,8 @@ import { connect } from 'react-redux'; // Relative imports. import LoadingIndicator from '@department-of-veterans-affairs/component-library/LoadingIndicator'; import recordEvent from 'platform/monitoring/record-event'; -import { - createAndUpgradeMHVAccount, - fetchMHVAccount, - upgradeMHVAccount, -} from 'platform/user/profile/actions'; +import { fetchMHVAccount } from 'platform/user/profile/actions'; +import { mhvUrl } from 'platform/site-wide/mhv/utilities'; import { isAuthenticatedWithSSOe } from 'platform/user/authentication/selectors'; import { isLoggedIn, selectProfile } from 'platform/user/selectors'; @@ -61,10 +58,8 @@ export class CallToActionWidget extends Component { mviStatus: PropTypes.string, profile: PropTypes.object, // From mapDispatchToProps. - createAndUpgradeMHVAccount: PropTypes.func.isRequired, fetchMHVAccount: PropTypes.func.isRequired, toggleLoginModal: PropTypes.func.isRequired, - upgradeMHVAccount: PropTypes.func.isRequired, ariaLabel: PropTypes.string, ariaDescribedby: PropTypes.string, }; @@ -117,7 +112,7 @@ export class CallToActionWidget extends Component { this._toolUrl = url; if (redirect && !this._popup) this.goToTool(); } else if (this.isHealthTool()) { - const { accountLevel, accountState, loading } = this.props.mhvAccount; + const { accountState, loading } = this.props.mhvAccount; if (loading) return; @@ -129,11 +124,7 @@ export class CallToActionWidget extends Component { // Since T&C is still required to support the existing account states, // check the existence of a query param that gets appended after // successful T&C acceptance to complete account creation or upgrade. - if (!accountLevel && accountState !== 'register_failed') { - this.props.createAndUpgradeMHVAccount(); - } else if (accountLevel && accountState !== 'upgrade_failed') { - this.props.upgradeMHVAccount(); - } + /* We are no longer creating or upgrading MHV accounts on VA.gov */ } } } @@ -292,6 +283,10 @@ export class CallToActionWidget extends Component { return null; }; + sendToMHV = () => { + window.location = mhvUrl(this.props.authenticatedWithSSOe, 'home'); + }; + getInaccessibleHealthToolContent = () => { const { accountState } = this.props.mhvAccount; @@ -324,40 +319,11 @@ export class CallToActionWidget extends Component { case ACCOUNT_STATES.MULTIPLE_IDS: return ; - /* Handling for these states to be re-introduced after brand consolidation - * when VA patient and T&C acceptance checks will no longer gate access, so - * access to these tools will be accurately reported by the services list. - * For now, MHV account level requirements will be validated client-side. - * - * case 'no_account': - * return { - * heading: `You’ll need to create a My HealtheVet account before you can ${this._serviceDescription`, - * primaryButtonText: 'Create a My HealtheVet Account', - * primaryButtonHandler: this.props.createAndUpgradeMHVAccount, - * status: 'continue' - * }; - - * case 'existing': - * case 'registered': - * return { - * heading: `You’ll need to upgrade your account before you can ${this._serviceDescription}`, - * primaryButtonText: 'Upgrade Your Account', - * primaryButtonHandler: this.props.upgradeMHVAccount, - * status: 'continue' - * }; - */ - case ACCOUNT_STATES.REGISTER_FAILED: - return ( - - ); + return ; case ACCOUNT_STATES.UPGRADE_FAILED: - return ( - - ); + return ; default: // Handle other content outside of block. } @@ -383,7 +349,7 @@ export class CallToActionWidget extends Component { primaryButtonHandler={ accountState === 'needs_terms_acceptance' ? redirectToTermsAndConditions - : this.props.createAndUpgradeMHVAccount + : this.sendToMHV } secondaryButtonHandler={this.signOut} /> @@ -396,7 +362,7 @@ export class CallToActionWidget extends Component { primaryButtonHandler={ accountState === 'needs_terms_acceptance' ? redirectToTermsAndConditions - : this.props.upgradeMHVAccount + : this.sendToMHV } /> ); @@ -567,10 +533,8 @@ const mapStateToProps = state => { }; const mapDispatchToProps = { - createAndUpgradeMHVAccount, fetchMHVAccount, toggleLoginModal, - upgradeMHVAccount, }; export default connect( diff --git a/src/applications/static-pages/cta-widget/tests/index.unit.spec.js b/src/applications/static-pages/cta-widget/tests/index.unit.spec.js index 1112fd986989..2f9e3c31d4c0 100644 --- a/src/applications/static-pages/cta-widget/tests/index.unit.spec.js +++ b/src/applications/static-pages/cta-widget/tests/index.unit.spec.js @@ -260,79 +260,6 @@ describe('', () => { tree.unmount(); }); - it('should create and upgrade MHV account when necessary', () => { - const createAndUpgradeMHVAccount = sinon.spy(); - const tree = mount( - , - ); - expect(createAndUpgradeMHVAccount.called).to.be.false; - - global.dom.reconfigure({ url: 'http://localhost?tc_accepted=true' }); - tree.setProps({ - isLoggedIn: true, - mhvAccount: { - loading: false, - accountState: 'something', - }, - }); - - expect(createAndUpgradeMHVAccount.called).to.be.true; - tree.unmount(); - global.dom.reconfigure({ url: 'http://localhost' }); - }); - - it('should upgrade MHV account when necessary', () => { - const upgradeMHVAccount = sinon.spy(); - const tree = mount( - , - ); - expect(upgradeMHVAccount.called).to.be.false; - - global.dom.reconfigure({ url: 'http://localhost?tc_accepted=true' }); - tree.setProps({ - isLoggedIn: true, - mhvAccount: { - loading: false, - accountState: 'something', - accountLevel: 'Basic', - }, - }); - - expect(upgradeMHVAccount.called).to.be.true; - tree.unmount(); - global.dom.reconfigure({ url: 'http://localhost' }); - }); - it('should open myhealthevet popup', () => { const { props, mockStore } = getData({ profile: { loading: false, verified: true, multifactor: false }, diff --git a/src/platform/user/authorization/containers/MHVApp.jsx b/src/platform/user/authorization/containers/MHVApp.jsx index 3b13e5b45e3a..8f35d487d5bb 100644 --- a/src/platform/user/authorization/containers/MHVApp.jsx +++ b/src/platform/user/authorization/containers/MHVApp.jsx @@ -9,17 +9,12 @@ import LoadingIndicator from '@department-of-veterans-affairs/component-library/ import Telephone, { CONTACTS, } from '@department-of-veterans-affairs/component-library/Telephone'; +import { fetchMHVAccount } from 'platform/user/profile/actions'; import { mhvAccessError } from '../../../static-data/error-messages'; import backendServices from '../../profile/constants/backendServices'; import { selectProfile } from '../../selectors'; import SubmitSignInForm from '../../../static-data/SubmitSignInForm'; -import { - createMHVAccount, - fetchMHVAccount, - upgradeMHVAccount, -} from 'platform/user/profile/actions'; - /* eslint-disable camelcase */ const INELIGIBLE_MESSAGES = { needs_ssn_resolution: { @@ -154,12 +149,9 @@ export class MHVApp extends React.Component { } case 'no_account': - this.props.createMHVAccount(); - break; - case 'existing': case 'registered': - this.props.upgradeMHVAccount(); + // We will no longer be creating or upgrading MHV accounts break; default: // Do nothing. @@ -191,7 +183,7 @@ export class MHVApp extends React.Component { return ; }; - renderPlaceholderErrorMessage() { + renderPlaceholderErrorMessage = () => { const alertProps = { headline: ( We’re not able to process your My HealtheVet account @@ -199,13 +191,9 @@ export class MHVApp extends React.Component { content: (

Please{' '} - { - window.location.reload(true); - }} - > + {' '} or try again later. If you keep having trouble, please{' '}

@@ -213,7 +201,7 @@ export class MHVApp extends React.Component { }; return ; - } + }; renderIneligibleMessage = ineligibleState => { const alertProps = INELIGIBLE_MESSAGES[ineligibleState]; @@ -232,7 +220,7 @@ export class MHVApp extends React.Component { return mhvAccessError; }; - renderAccountUnknownMessage() { + renderAccountUnknownMessage = () => { const alertProps = { headline: We can’t confirm your My HealtheVet account level, content: ( @@ -247,9 +235,9 @@ export class MHVApp extends React.Component { }; return ; - } + }; - renderRegisterFailedMessage() { + renderRegisterFailedMessage = () => { const alertProps = { headline: `We can’t give you access to VA.gov health tools right now`, content: ( @@ -263,9 +251,9 @@ export class MHVApp extends React.Component { }; return ; - } + }; - renderUpgradeFailedMessage() { + renderUpgradeFailedMessage = () => { const alertProps = { headline: `We can’t give you access to VA.gov health tools right now`, content: ( @@ -282,7 +270,7 @@ export class MHVApp extends React.Component { }; return ; - } + }; render() { const { @@ -346,6 +334,8 @@ export class MHVApp extends React.Component { MHVApp.propTypes = { children: PropTypes.node, + fetchMHVAccount: PropTypes.func, + mhvAccount: PropTypes.object, serviceRequired: PropTypes.oneOf([ backendServices.HEALTH_RECORDS, backendServices.MESSAGING, @@ -364,11 +354,7 @@ const mapStateToProps = state => { return { mhvAccount, availableServices }; }; -const mapDispatchToProps = { - createMHVAccount, - fetchMHVAccount, - upgradeMHVAccount, -}; +const mapDispatchToProps = { fetchMHVAccount }; export default withRouter( connect( diff --git a/src/platform/user/exportsFile.js b/src/platform/user/exportsFile.js index f2597e2d628f..5d6265a593d3 100644 --- a/src/platform/user/exportsFile.js +++ b/src/platform/user/exportsFile.js @@ -197,16 +197,7 @@ export { FETCHING_MHV_ACCOUNT, FETCH_MHV_ACCOUNT_FAILURE, FETCH_MHV_ACCOUNT_SUCCESS, - CREATING_MHV_ACCOUNT, - CREATE_MHV_ACCOUNT_FAILURE, - CREATE_MHV_ACCOUNT_SUCCESS, - UPGRADING_MHV_ACCOUNT, - UPGRADE_MHV_ACCOUNT_FAILURE, - UPGRADE_MHV_ACCOUNT_SUCCESS, fetchMHVAccount, - createMHVAccount, - upgradeMHVAccount, - createAndUpgradeMHVAccount, } from './profile/actions/mhv'; export { diff --git a/src/platform/user/profile/actions/mhv.js b/src/platform/user/profile/actions/mhv.js index 06b613a99320..b05d06ce967b 100644 --- a/src/platform/user/profile/actions/mhv.js +++ b/src/platform/user/profile/actions/mhv.js @@ -1,19 +1,9 @@ import { apiRequest } from '../../../utilities/api'; -import get from '../../../utilities/data/get'; -import recordEvent from '../../../monitoring/record-event'; export const FETCHING_MHV_ACCOUNT = 'FETCHING_MHV_ACCOUNT'; export const FETCH_MHV_ACCOUNT_FAILURE = 'FETCH_MHV_ACCOUNT_FAILURE'; export const FETCH_MHV_ACCOUNT_SUCCESS = 'FETCH_MHV_ACCOUNT_SUCCESS'; -export const CREATING_MHV_ACCOUNT = 'CREATING_MHV_ACCOUNT'; -export const CREATE_MHV_ACCOUNT_FAILURE = 'CREATE_MHV_ACCOUNT_FAILURE'; -export const CREATE_MHV_ACCOUNT_SUCCESS = 'CREATE_MHV_ACCOUNT_SUCCESS'; - -export const UPGRADING_MHV_ACCOUNT = 'UPGRADING_MHV_ACCOUNT'; -export const UPGRADE_MHV_ACCOUNT_FAILURE = 'UPGRADE_MHV_ACCOUNT_FAILURE'; -export const UPGRADE_MHV_ACCOUNT_SUCCESS = 'UPGRADE_MHV_ACCOUNT_SUCCESS'; - const baseUrl = '/mhv_account'; export function fetchMHVAccount() { @@ -27,59 +17,3 @@ export function fetchMHVAccount() { ); }; } - -export function createMHVAccount() { - return dispatch => { - dispatch({ type: CREATING_MHV_ACCOUNT }); - recordEvent({ event: 'register-mhv-create-attempt' }); - - return apiRequest(baseUrl, { method: 'POST' }) - .then(({ data }) => { - recordEvent({ event: 'register-mhv-create-success' }); - return dispatch({ type: CREATE_MHV_ACCOUNT_SUCCESS, data }); - }) - .catch(() => dispatch({ type: CREATE_MHV_ACCOUNT_FAILURE })); - }; -} - -export function upgradeMHVAccount() { - return async dispatch => { - dispatch({ type: UPGRADING_MHV_ACCOUNT }); - recordEvent({ event: 'register-mhv-upgrade-attempt' }); - - let mhvAccount; - let userProfile; - - // If upgrade is successful, fetch user to update the list of services. - // Note that as long as the actual MHV upgrade responded with a success, - // it will count as a success even if user fetch fails for whatever reason. - try { - mhvAccount = await apiRequest(`${baseUrl}/upgrade`, { method: 'POST' }); - userProfile = await apiRequest('/user'); - } catch (error) { - if (!mhvAccount) return dispatch({ type: UPGRADE_MHV_ACCOUNT_FAILURE }); - } - - recordEvent({ event: 'register-mhv-upgrade-success' }); - return dispatch({ - type: UPGRADE_MHV_ACCOUNT_SUCCESS, - mhvAccount, - userProfile, - }); - }; -} - -export function createAndUpgradeMHVAccount() { - return async dispatch => { - const accountCreationResult = await dispatch(createMHVAccount()); - - const accountLevel = get( - 'data.attributes.accountLevel', - accountCreationResult, - ); - - if (accountLevel) return dispatch(upgradeMHVAccount()); - - return null; - }; -} diff --git a/src/platform/user/profile/reducers/index.js b/src/platform/user/profile/reducers/index.js index 963d04cd969b..f6a422bef614 100644 --- a/src/platform/user/profile/reducers/index.js +++ b/src/platform/user/profile/reducers/index.js @@ -9,12 +9,6 @@ import { FETCHING_MHV_ACCOUNT, FETCH_MHV_ACCOUNT_FAILURE, FETCH_MHV_ACCOUNT_SUCCESS, - CREATING_MHV_ACCOUNT, - CREATE_MHV_ACCOUNT_FAILURE, - CREATE_MHV_ACCOUNT_SUCCESS, - UPGRADING_MHV_ACCOUNT, - UPGRADE_MHV_ACCOUNT_FAILURE, - UPGRADE_MHV_ACCOUNT_SUCCESS, REMOVING_SAVED_FORM_SUCCESS, } from '../actions'; @@ -76,8 +70,6 @@ function profileInformation(state = initialState, action) { return set('loading', false, state); case FETCHING_MHV_ACCOUNT: - case CREATING_MHV_ACCOUNT: - case UPGRADING_MHV_ACCOUNT: return set('mhvAccount.loading', true, state); case FETCH_MHV_ACCOUNT_FAILURE: @@ -91,39 +83,10 @@ function profileInformation(state = initialState, action) { state, ); - case CREATE_MHV_ACCOUNT_FAILURE: - return set( - 'mhvAccount', - { - ...state.mhvAccount, - accountState: 'register_failed', - loading: false, - }, - state, - ); - - case UPGRADE_MHV_ACCOUNT_FAILURE: - return set( - 'mhvAccount', - { - ...state.mhvAccount, - accountState: 'upgrade_failed', - loading: false, - }, - state, - ); - + // We are no longer creating or upgrading MHV accounts case FETCH_MHV_ACCOUNT_SUCCESS: - case CREATE_MHV_ACCOUNT_SUCCESS: return updateMhvAccountState(state, action.data.attributes); - case UPGRADE_MHV_ACCOUNT_SUCCESS: { - const newState = !action.userProfile - ? state - : { ...state, ...mapRawUserDataToState(action.userProfile) }; - return updateMhvAccountState(newState, action.mhvAccount.data.attributes); - } - case REMOVING_SAVED_FORM_SUCCESS: { const forms = state.savedForms.filter(el => el.form !== action.formId); return set('savedForms', forms, state); diff --git a/src/platform/user/tests/authorization/containers/MHVApp.unit.spec.jsx b/src/platform/user/tests/authorization/containers/MHVApp.unit.spec.jsx index 20a80c519e79..bd8130848588 100644 --- a/src/platform/user/tests/authorization/containers/MHVApp.unit.spec.jsx +++ b/src/platform/user/tests/authorization/containers/MHVApp.unit.spec.jsx @@ -2,10 +2,10 @@ import React from 'react'; import { expect } from 'chai'; import { shallow } from 'enzyme'; import { merge } from 'lodash'; -import set from '../../../../utilities/data/set'; import sinon from 'sinon'; +import set from '../../../../utilities/data/set'; -import backendServices from '../../../../user/profile/constants/backendServices'; +import backendServices from '../../../profile/constants/backendServices'; import { MHVApp } from '../../../authorization/containers/MHVApp'; describe('', () => { @@ -25,9 +25,7 @@ describe('', () => { backendServices.USER_PROFILE, ], serviceRequired: backendServices.RX, - createMHVAccount: sinon.spy(), fetchMHVAccount: sinon.spy(), - upgradeMHVAccount: sinon.spy(), }; const setup = () => { @@ -36,9 +34,7 @@ describe('', () => { global.window.location = { replace: sinon.spy(), }; - props.createMHVAccount.reset(); props.fetchMHVAccount.reset(); - props.upgradeMHVAccount.reset(); }; const context = { router: {} }; @@ -70,14 +66,6 @@ describe('', () => { wrapper.unmount(); }); - it('should create an account if the user does not have an account but is eligible', () => { - const wrapper = shallow(, { context }); - const mhvAccount = set('accountState', 'no_account', props.mhvAccount); - wrapper.setProps({ mhvAccount }); - expect(props.createMHVAccount.calledOnce).to.be.true; - wrapper.unmount(); - }); - it('should redirect if the user needs to accepts T&C', () => { const wrapper = shallow(, { context }); const mhvAccount = set( @@ -90,22 +78,6 @@ describe('', () => { wrapper.unmount(); }); - it('should invoke upgrade if the user is only registered', () => { - const wrapper = shallow(, { context }); - const mhvAccount = set('accountState', 'registered', props.mhvAccount); - wrapper.setProps({ mhvAccount }); - expect(props.upgradeMHVAccount.calledOnce).to.be.true; - wrapper.unmount(); - }); - - it('should invoke upgrade if the user is existing without access to the service', () => { - const wrapper = shallow(, { context }); - const mhvAccount = set('accountState', 'existing', props.mhvAccount); - wrapper.setProps({ mhvAccount }); - expect(props.upgradeMHVAccount.calledOnce).to.be.true; - wrapper.unmount(); - }); - it('should show a success message after the user accepts T&C and gets upgraded', () => { const newProps = merge({}, props, { mhvAccount: { ...props.mhvAccount, accountState: 'upgraded' }, diff --git a/src/platform/user/tests/profile/reducers/index.unit.spec.js b/src/platform/user/tests/profile/reducers/index.unit.spec.js index 6541ef422359..4fb68fe5ad84 100644 --- a/src/platform/user/tests/profile/reducers/index.unit.spec.js +++ b/src/platform/user/tests/profile/reducers/index.unit.spec.js @@ -1,18 +1,12 @@ import { expect } from 'chai'; import reducer from '../../../profile/reducers'; -import { UPDATE_LOGGEDIN_STATUS } from '../../../../user/authentication/actions'; +import { UPDATE_LOGGEDIN_STATUS } from '../../../authentication/actions'; import { - CREATE_MHV_ACCOUNT_FAILURE, - CREATE_MHV_ACCOUNT_SUCCESS, - CREATING_MHV_ACCOUNT, FETCH_MHV_ACCOUNT_FAILURE, FETCH_MHV_ACCOUNT_SUCCESS, FETCHING_MHV_ACCOUNT, - UPGRADE_MHV_ACCOUNT_FAILURE, - UPGRADE_MHV_ACCOUNT_SUCCESS, - UPGRADING_MHV_ACCOUNT, PROFILE_LOADING_FINISHED, REMOVING_SAVED_FORM_SUCCESS, } from '../../../profile/actions'; @@ -35,121 +29,11 @@ describe('Profile reducer', () => { expect(state.loading).to.be.false; }); - it('should be loading when creating MHV account', () => { - const userProfile = { data: { attributes: { account: {} } } }; - const state = reducer( - { mhvAccount: {}, userProfile }, - { type: CREATING_MHV_ACCOUNT }, - ); - expect(state.mhvAccount.loading).to.be.true; - }); - - it('should be loading when upgrading MHV account', () => { - const state = reducer({ mhvAccount: {} }, { type: UPGRADING_MHV_ACCOUNT }); - expect(state.mhvAccount.loading).to.be.true; - }); - it('should be loading when fetching MHV account', () => { const state = reducer({ mhvAccount: {} }, { type: FETCHING_MHV_ACCOUNT }); expect(state.mhvAccount.loading).to.be.true; }); - it('should handle failed MHV account creation', () => { - const state = reducer( - { - mhvAccount: { - accountLevel: null, - accountState: 'no_account', - }, - }, - { - type: CREATE_MHV_ACCOUNT_FAILURE, - errors: [{ title: 'error', code: 500 }], - }, - ); - expect(state.mhvAccount.loading).to.be.false; - expect(state.mhvAccount.accountState).to.eq('register_failed'); - }); - - it('should handle successful MHV account creation', () => { - const state = reducer( - { - mhvAccount: { - accountLevel: null, - accountState: 'no_account', - }, - }, - { - type: CREATE_MHV_ACCOUNT_SUCCESS, - data: { - attributes: { - accountLevel: 'Advanced', - accountState: 'registered', - }, - }, - }, - ); - - expect(state.mhvAccount.accountLevel).to.eq('Advanced'); - expect(state.mhvAccount.accountState).to.eq('registered'); - }); - - it('should handle failed MHV account upgrade', () => { - const state = reducer( - { - mhvAccount: { - accountLevel: 'Advanced', - accountState: 'registered', - }, - }, - { - type: UPGRADE_MHV_ACCOUNT_FAILURE, - errors: [{ title: 'error', code: 500 }], - }, - ); - expect(state.mhvAccount.loading).to.be.false; - expect(state.mhvAccount.accountState).to.eq('upgrade_failed'); - }); - - it('should handle successful MHV account upgrade', () => { - const state = reducer( - { - mhvAccount: { - accountLevel: 'Advanced', - accountState: 'registered', - }, - services: ['health-records', 'rx'], - }, - { - type: UPGRADE_MHV_ACCOUNT_SUCCESS, - mhvAccount: { - data: { - attributes: { - accountLevel: 'Premium', - accountState: 'upgraded', - }, - }, - }, - userProfile: { - data: { - attributes: { - account: {}, - profile: { loa: { current: 3 } }, - vaProfile: {}, - veteranStatus: {}, - services: ['health-records', 'rx', 'messaging'], - }, - }, - meta: { errors: null }, - }, - }, - ); - - expect(state.mhvAccount.accountLevel).to.eq('Premium'); - expect(state.mhvAccount.accountState).to.eq('upgraded'); - expect(state.services).to.contain('messaging'); - }); - it('should handle failure to fetch MHV account', () => { const state = reducer( { mhvAccount: {} },