From 541a47e1e90e9ca1b3fc965597b8945680403f22 Mon Sep 17 00:00:00 2001
From: Carlos Felix <63804190+carlosfelix2@users.noreply.github.com>
Date: Thu, 11 Jul 2024 12:05:47 -0400
Subject: [PATCH] Updated MHV registration link in MHV Landing Page (#30792)
---
.../components/MhvRegistrationAlert.jsx | 12 ++++----
.../MhvRegistrationAlert.unit.spec.jsx | 30 ++++++++++++++++---
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/applications/mhv-landing-page/components/MhvRegistrationAlert.jsx b/src/applications/mhv-landing-page/components/MhvRegistrationAlert.jsx
index 331e33090e60..0d74ab7931f5 100644
--- a/src/applications/mhv-landing-page/components/MhvRegistrationAlert.jsx
+++ b/src/applications/mhv-landing-page/components/MhvRegistrationAlert.jsx
@@ -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(
@@ -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 (
+
Register with My HealtheVet
diff --git a/src/applications/mhv-landing-page/tests/components/MhvRegistrationAlert.unit.spec.jsx b/src/applications/mhv-landing-page/tests/components/MhvRegistrationAlert.unit.spec.jsx
index 57d18fd96a2c..0a675c64089d 100644
--- a/src/applications/mhv-landing-page/tests/components/MhvRegistrationAlert.unit.spec.jsx
+++ b/src/applications/mhv-landing-page/tests/components/MhvRegistrationAlert.unit.spec.jsx
@@ -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(
);
+ const { getByRole } = render(
+
+
+ ,
+ );
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 () => {
@@ -24,7 +42,11 @@ describe('MhvRegistrationAlert', () => {
};
const recordEventSpy = sinon.spy();
const props = { recordEvent: recordEventSpy };
- render(
);
+ render(
+
+
+ ,
+ );
await waitFor(() => {
expect(recordEventSpy.calledOnce).to.be.true;
expect(recordEventSpy.calledWith(event)).to.be.true;