Skip to content

Commit

Permalink
Removes mhv_landing_page_enabled/mhvLandingPageEnabled feature toggle (
Browse files Browse the repository at this point in the history
  • Loading branch information
radavis authored Jul 5, 2024
1 parent 795840b commit 6c43943
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 136 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const generateFeatureToggles = (toggles = {}) => {
const {
mhvLandingPageEnabled = true,
mhvLandingPagePersonalization = true,
mhvMedicationsToVaGovRelease = true,
mhvMedicationsDisplayRefillContent = true,
Expand All @@ -11,10 +10,6 @@ const generateFeatureToggles = (toggles = {}) => {
data: {
type: 'feature_toggles',
features: [
{
name: 'mhv_landing_page_enabled',
value: mhvLandingPageEnabled,
},
{
name: 'mhv_landing_page_personalization',
value: mhvLandingPagePersonalization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,14 +998,6 @@
"name": "medical_copay_notifications",
"value": true
},
{
"name": "mhvLandingPageEnabled",
"value": true
},
{
"name": "mhv_landing_page_enabled",
"value": true
},
{
"name": "mhvSecureMessagingToVAGovRelease",
"value": true
Expand Down
5 changes: 0 additions & 5 deletions src/platform/mhv/api/mocks/feature-toggles/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const generateFeatureToggles = (toggles = {}) => {
const {
mhvLandingPageEnabled = true,
mhvLandingPagePersonalization = true,
mhvMedicationsToVaGovRelease = true,
mhvMedicationsDisplayRefillContent = true,
Expand All @@ -16,10 +15,6 @@ const generateFeatureToggles = (toggles = {}) => {
name: 'mhv-mock-session',
value: true,
},
{
name: 'mhv_landing_page_enabled',
value: mhvLandingPageEnabled,
},
{
name: 'mhv_landing_page_personalization',
value: mhvLandingPagePersonalization,
Expand Down
9 changes: 1 addition & 8 deletions src/platform/mhv/downtime/mocks/api/feature-toggles/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
const generateFeatureToggles = (toggles = {}) => {
const {
mhvLandingPageEnabled = true,
mhvLandingPagePersonalization = true,
} = toggles;
const { mhvLandingPagePersonalization = true } = toggles;

return {
data: {
type: 'feature_toggles',
features: [
{
name: 'mhv_landing_page_enabled',
value: mhvLandingPageEnabled,
},
{
name: 'mhv_landing_page_personalization',
value: mhvLandingPagePersonalization,
Expand Down
1 change: 0 additions & 1 deletion src/platform/mhv/downtime/mocks/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const responses = {
...commonResponses,
'GET /v0/user': user.defaultUser,
'GET /v0/feature_toggles': featureToggles.generateFeatureToggles({
mhvLandingPageEnabled: true,
mhvLandingPagePersonalization: true,
}),
'GET /my_health/v1/messaging/folders': folders.allFoldersWithUnreadMessages,
Expand Down
10 changes: 2 additions & 8 deletions src/platform/site-wide/mega-menu/containers/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
togglePanelOpen,
updateCurrentSection,
} from '../actions';
import { toggleValues } from '../../feature-toggles/selectors';
import FEATURE_FLAG_NAMES from '../../../utilities/feature-toggles/featureFlagNames';

const tabbableSelectors =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
Expand Down Expand Up @@ -185,14 +183,10 @@ const mapStateToProps = (state, ownProps) => {
const defaultLinks = ownProps?.megaMenuData ? [...ownProps.megaMenuData] : [];

if (loggedIn) {
defaultLinks.push(MY_VA_LINK);
defaultLinks.push(MY_VA_LINK, MY_HEALTH_LINK);
}

const authenticatedLinks = toggleValues(state)[
FEATURE_FLAG_NAMES.mhvLandingPageEnabled
]
? [{ ...MY_HEALTH_LINK }]
: undefined;
const authenticatedLinks = [];

const data = flagCurrentPageInTopLevelLinks(
getAuthorizedLinkData(loggedIn, defaultLinks, authenticatedLinks),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import features from '~/platform/utilities/tests/header-footer/mocks/features';

describe('My HealtheVet on VA.gov', () => {
it('shows the new link when enabled', () => {
it('shows the VA.gov link', () => {
cy.intercept('/v0/feature_toggles*', features).as('features');
cy.login();
cy.visit('/');
Expand All @@ -15,16 +15,4 @@ describe('My HealtheVet on VA.gov', () => {
'/my-health/',
);
});

it('shows the old link when disabled', () => {
cy.login();
cy.visit('/');
cy.injectAxeThenAxeCheck();
cy.get('[data-e2e-id^="my-healthe-vet-"]')
.should('be.visible')
.and('have.text', 'My HealtheVet');
cy.get('[data-e2e-id^="my-healthe-vet-"]')
.should('have.attr', 'href')
.and('include', 'mhv-portal-web/eauth');
});
});
19 changes: 4 additions & 15 deletions src/platform/site-wide/user-nav/components/MyHealthLink.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
import React from 'react';
import PropTypes from 'prop-types';
import { mhvUrl } from '~/platform/site-wide/mhv/utilities';
import MY_HEALTH_LINK from '~/platform/site-wide/mega-menu/constants/MY_HEALTH_LINK';
import { useFeatureToggle } from '~/platform/utilities/feature-toggles';

const MyHealthLink = ({ isSSOe, recordNavUserEvent }) => {
const { useToggleValue, TOGGLE_NAMES } = useFeatureToggle();
const newLandingPageEnabled = useToggleValue(
TOGGLE_NAMES.mhvLandingPageEnabled,
);
const eventName = newLandingPageEnabled ? 'my-healthevet' : 'my-health';
const recordMyHealthEvent = recordNavUserEvent(eventName);
const href = newLandingPageEnabled
? MY_HEALTH_LINK.href
: mhvUrl(isSSOe, 'home');
const content = newLandingPageEnabled ? MY_HEALTH_LINK.title : 'My Health';
const MyHealthLink = ({ recordNavUserEvent }) => {
const recordMyHealthEvent = recordNavUserEvent('my-healthevet');
const { href, title } = MY_HEALTH_LINK;

return (
<li>
<a className="my-health-link" href={href} onClick={recordMyHealthEvent}>
{content}
{title}
</a>
</li>
);
};

MyHealthLink.propTypes = {
isSSOe: PropTypes.bool,
recordNavUserEvent: PropTypes.func,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,32 @@ import { expect } from 'chai';
import sinon from 'sinon';

import { $ } from 'platform/forms-system/src/js/utilities/ui';
import MyHealthLink from '../../components/MyHealthLink';
import MY_HEALTH_LINK from '~/platform/site-wide/mega-menu/constants/MY_HEALTH_LINK';
import { mhvUrl } from '~/platform/site-wide/mhv/utilities';
import MyHealthLink from '../../components/MyHealthLink';

const store = ({ featureToggleOn = false } = {}) => ({
getState: () => ({
featureToggles: {
// eslint-disable-next-line camelcase
mhv_landing_page_enabled: featureToggleOn,
},
}),
const store = () => ({
getState: () => {},
subscribe: () => {},
dispatch: () => {},
});

describe('MyHealthLink', () => {
describe('should render link when', () => {
it('`mhv_landing_page_enabled`: false | isSSOe: true', async () => {
const mockStore = store();
const recordNavUserEventSpy = sinon.spy();
const { container } = render(
<Provider store={mockStore}>
<MyHealthLink isSSOe recordNavUserEvent={recordNavUserEventSpy} />
</Provider>,
);
expect($('.my-health-link', container).textContent).to.eql('My Health');
expect($('.my-health-link', container).href).to.eql(mhvUrl(true, 'home'));
$('.my-health-link', container).click();
expect(recordNavUserEventSpy.calledOnce).to.be.true;
expect(recordNavUserEventSpy.firstCall.args[0]).to.eql('my-health');
});
it('`mhv_landing_page_enabled`: false | isSSOe: false', async () => {
const mockStore = store();
const recordNavUserEventSpy = sinon.spy();
const { container } = render(
<Provider store={mockStore}>
<MyHealthLink recordNavUserEvent={recordNavUserEventSpy} />
</Provider>,
);
expect($('.my-health-link', container).textContent).to.eql('My Health');
expect($('.my-health-link', container).href).to.eql(
mhvUrl(false, 'home'),
);
$('.my-health-link', container).click();
expect(recordNavUserEventSpy.calledOnce).to.be.true;
expect(recordNavUserEventSpy.firstCall.args[0]).to.eql('my-health');
});
it('`mhv_landing_page_enabled`: true', async () => {
const mockStore = store({ featureToggleOn: true });
const recordNavUserEventSpy = sinon.spy();
const { container } = render(
<Provider store={mockStore}>
<MyHealthLink recordNavUserEvent={recordNavUserEventSpy} />
</Provider>,
);
expect($('.my-health-link', container).textContent).to.eql(
MY_HEALTH_LINK.title,
);
expect($('.my-health-link', container).href).to.include(
MY_HEALTH_LINK.href,
);
$('.my-health-link', container).click();
expect(recordNavUserEventSpy.calledOnce).to.be.true;
expect(recordNavUserEventSpy.firstCall.args[0]).to.eql('my-healthevet');
});
it('should render link', async () => {
const mockStore = store();
const recordNavUserEventSpy = sinon.spy();
const { container } = render(
<Provider store={mockStore}>
<MyHealthLink recordNavUserEvent={recordNavUserEventSpy} />
</Provider>,
);
expect($('.my-health-link', container).textContent).to.eql(
MY_HEALTH_LINK.title,
);
expect($('.my-health-link', container).href).to.include(
MY_HEALTH_LINK.href,
);
$('.my-health-link', container).click();
expect(recordNavUserEventSpy.calledOnce).to.be.true;
expect(recordNavUserEventSpy.firstCall.args[0]).to.eql('my-healthevet');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('<PersonalizationDropdown>', () => {
</Provider>,
);
wrapper
.find({ children: 'My Health' })
.find({ children: 'My HealtheVet' })
.at(0)
.simulate('click');
const recordedEvent = global.window.dataLayer[0];
expect(recordedEvent.event).to.equal('nav-user');
expect(recordedEvent['nav-user-section']).to.equal('my-health');
expect(recordedEvent['nav-user-section']).to.equal('my-healthevet');
wrapper.unmount();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import features from '~/platform/utilities/tests/header-footer/mocks/features';

describe('My HealtheVet on VA.gov', () => {
it('shows the new link when enabled', () => {
it('shows the VA.gov link', () => {
cy.intercept('/v0/feature_toggles*', features).as('features');
cy.login();
cy.visit('/');
cy.injectAxeThenAxeCheck();
cy.viewportPreset('va-top-mobile-1');
cy.get('.my-health-link').should('have.attr', 'href', '/my-health/');
});

it('shows the old link when disabled', () => {
cy.login();
cy.visit('/');
cy.injectAxeThenAxeCheck();
cy.viewportPreset('va-top-mobile-1');
cy.get('.my-health-link')
.should('have.attr', 'href')
.and('include', 'mhv-portal');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"loopPages": "loop_pages",
"manageDependents": "dependents_management",
"medicalCopaysHtmlMedicalStatementsViewEnabled": "medical_copays_html_medical_statements_view_enabled",
"mhvLandingPageEnabled": "mhv_landing_page_enabled",
"mhvLandingPagePersonalization": "mhv_landing_page_personalization",
"mhvSecondaryNavigationEnabled": "mhv_secondary_navigation_enabled",
"mhvLandingPageEnableVaGovHealthToolsLinks": "mhv_landing_page_enable_va_gov_health_tools_links",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const features = {
{ name: 'vaOnlineSchedulingVAOSServiceRequests', value: false },
{ name: 'edu_section_103', value: true },
{ name: 'gibctEybBottomSheet', value: true },
{ name: 'mhv_landing_page_enabled', value: true },
],
},
};
Expand Down

0 comments on commit 6c43943

Please sign in to comment.