Skip to content

Commit

Permalink
Updated MHV registration link in MHV Landing Page (#30792)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfelix2 committed Jul 11, 2024
1 parent f3609ce commit 541a47e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { mhvBaseUrl } from '@department-of-veterans-affairs/platform-site-wide/utilities';
import { useSelector } from 'react-redux';
import { mhvUrl } from '@department-of-veterans-affairs/platform-site-wide/utilities';
// eslint-disable-next-line import/no-named-default
import { default as recordEventFn } from '~/platform/monitoring/record-event';
import { isAuthenticatedWithSSOe } from '../selectors';

const MhvRegistrationAlert = ({ headline, recordEvent, status, icon }) => {
useEffect(
Expand All @@ -17,6 +19,9 @@ const MhvRegistrationAlert = ({ headline, recordEvent, status, icon }) => {
[headline, recordEvent, status],
);

const hasSsoe = useSelector(isAuthenticatedWithSSOe);
const mhvLink = `${mhvUrl(hasSsoe, '')}home&postLogin=true`;

return (
<div
className="mhv-c-reg-alert mhv-u-reg-alert-warning usa-alert vads-u-display--flex
Expand All @@ -36,10 +41,7 @@ const MhvRegistrationAlert = ({ headline, recordEvent, status, icon }) => {
this page.
</p>
<p>
<a
className="vads-c-action-link--green"
href={`${mhvBaseUrl()}/mhv-portal-web/web/myhealthevet/user-registration`}
>
<a className="vads-c-action-link--green" href={mhvLink}>
Register with My HealtheVet
</a>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,35 @@ import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { expect } from 'chai';
import sinon from 'sinon';
import { Provider } from 'react-redux';

import MhvRegistrationAlert from '../../components/MhvRegistrationAlert';

const defaultHeadline = MhvRegistrationAlert.defaultProps.headline;

describe('MhvRegistrationAlert', () => {
const mockStore = () => ({
getState: () => ({
user: {
profile: {
session: {
ssoe: true,
},
},
},
}),
subscribe: () => {},
dispatch: () => {},
});

it('renders', () => {
const { getByRole } = render(<MhvRegistrationAlert />);
const { getByRole } = render(
<Provider store={mockStore()}>
<MhvRegistrationAlert />
</Provider>,
);
getByRole('heading', { name: defaultHeadline });
const link = getByRole('link', { name: /Register with My HealtheVet/ });
expect(link.href).to.not.be.empty;
getByRole('link', { name: /Register with My HealtheVet/ });
});

it('reports to GA via recordEvent when rendered', async () => {
Expand All @@ -24,7 +42,11 @@ describe('MhvRegistrationAlert', () => {
};
const recordEventSpy = sinon.spy();
const props = { recordEvent: recordEventSpy };
render(<MhvRegistrationAlert {...props} />);
render(
<Provider store={mockStore()}>
<MhvRegistrationAlert {...props} />
</Provider>,
);
await waitFor(() => {
expect(recordEventSpy.calledOnce).to.be.true;
expect(recordEventSpy.calledWith(event)).to.be.true;
Expand Down

0 comments on commit 541a47e

Please sign in to comment.