Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MHV-54372 Secure Messaging cleanup 556 transition flipper #28623

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,20 @@
*/

import React, { useMemo } from 'react';
import FEATURE_FLAG_NAMES from '@department-of-veterans-affairs/platform-utilities/featureFlagNames';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { selectUser } from '@department-of-veterans-affairs/platform-user/selectors';
import { selectEhrDataByVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/selectors';

Check warning on line 19 in src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx:19:1:Importing from platform via platform/site-wide is deprecated. Import from @department-of-veterans-affairs/platform-site-wide instead or check babel.config.json for an alias to the import.
import { getVamcSystemNameFromVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/utils';

Check warning on line 20 in src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx:20:1:Importing from platform via platform/site-wide is deprecated. Import from @department-of-veterans-affairs/platform-site-wide instead or check babel.config.json for an alias to the import.
import { CernerTransitioningFacilities } from '../../util/constants';

const CernerTransitioningFacilityAlert = () => {
/**
* @param {boolean} t5 - boolean flag to display the alert for 5 days before transition
* @param {boolean} t30 - boolean flag to display the alert for 30 days before transition
* @param {string} facilityId - facility id
*/
const CernerTransitioningFacilityAlert = ({ t5, t30, facilityId }) => {
const user = useSelector(selectUser);
const { featureToggles } = useSelector(state => state);
const transitioningFacilityId =
CernerTransitioningFacilities.NORTH_CHICAGO.facilityId;

const cernerTransition556T30 = useMemo(
() => {
return featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T30]
? featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T30]
: false;
},
[featureToggles],
);
const cernerTransition556T5 = useMemo(
() => {
return featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T5]
? featureToggles[FEATURE_FLAG_NAMES.cernerTransition556T5]
: false;
},
[featureToggles],
);

const transitioningFacilityId = facilityId;
const userFacilities = user.profile.facilities;
const ehrFacilities = useSelector(selectEhrDataByVhaId);

Expand All @@ -66,7 +50,7 @@
}
return null;
},
[userFacilities, ehrFacilities],

Check warning on line 53 in src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/mhv/secure-messaging/components/Alerts/CernerTransitioningFacilityAlert.jsx:53:5:React Hook useMemo has a missing dependency: 'transitioningFacilityId'. Either include it or remove the dependency array.
);

const contentT30 = useMemo(
Expand Down Expand Up @@ -130,16 +114,18 @@
);

const content = () => {
if (cernerTransition556T5) {
return contentT5;
}
if (cernerTransition556T30) {
return contentT30;
}
if (t5) return contentT5;
if (t30) return contentT30;
return null;
};

return <>{content()}</>;
};

CernerTransitioningFacilityAlert.propTypes = {
facilityId: PropTypes.string,
t30: PropTypes.bool,
t5: PropTypes.bool,
};

export default CernerTransitioningFacilityAlert;
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ describe('CernerTransitioningFacilityAlert', () => {
},
},
},
featureToggles: [],
user: {
profile: {
facilities: [],
},
},
};

const initialProps = {
t5: false,
t30: false,
facilityId: '556',
};

const alertT30 = {
alertTitle: 'Your health facility is moving to My VA Health',
alertContent:
Expand All @@ -47,10 +52,13 @@ describe('CernerTransitioningFacilityAlert', () => {
alertContent2: 'To contact your care team now, call your facility.',
};

const setup = (state = initialState) => {
return renderWithStoreAndRouter(<CernerTransitioningFacilityAlert />, {
initialState: state,
});
const setup = (state = initialState, props = initialProps) => {
return renderWithStoreAndRouter(
<CernerTransitioningFacilityAlert {...props} />,
{
initialState: state,
},
);
};

afterEach(() => {
Expand All @@ -72,10 +80,9 @@ describe('CernerTransitioningFacilityAlert', () => {
},
},
};
customState.featureToggles[`${'cerner_transition_556_t30'}`] = true;
customState.featureToggles[`${'cerner_transition_556_t5'}`] = false;
const customProps = { ...initialProps, t30: true };

const { findByText, container } = setup(customState);
const { findByText, container } = setup(customState, customProps);

expect(findByText(alertT30.alertTitle)).to.exist;
expect(container.textContent).to.contain(alertT30.alertContent);
Expand All @@ -97,10 +104,9 @@ describe('CernerTransitioningFacilityAlert', () => {
},
},
};
customState.featureToggles[`${'cerner_transition_556_t30'}`] = true;
customState.featureToggles[`${'cerner_transition_556_t5'}`] = true;
const customProps = { t30: true, facilityId: null };

const { queryByText, container } = setup(customState);
const { queryByText, container } = setup(customState, customProps);
expect(queryByText(alertT30.alertTitle)).to.be.null;
expect(container.textContent).to.not.contain(alertT30.alertContent);
expect(container.textContent).to.not.contain(alertT30.alertContent2);
Expand All @@ -110,16 +116,15 @@ describe('CernerTransitioningFacilityAlert', () => {
it('should not render when no facilites are fetched', async () => {
const customState = {
...initialState,
featureToggles: [],
user: {
profile: {
facilities: [],
},
},
};
customState.featureToggles[`${'cerner_transition_556_t30'}`] = true;
const customProps = { ...initialProps, t30: true };

const { queryByText, container } = setup(customState);
const { queryByText, container } = setup(customState, customProps);
expect(queryByText(alertT30.alertTitle)).to.be.null;
expect(container.textContent).to.not.contain(alertT30.alertContent);
expect(container.textContent).to.not.contain(alertT30.alertContent2);
Expand All @@ -141,9 +146,12 @@ describe('CernerTransitioningFacilityAlert', () => {
},
},
};
customState.featureToggles[`${'cerner_transition_556_t5'}`] = true;
const customProps = { t5: true, facilityId: '556' };

const { findByText, queryByText, container } = setup(customState);
const { findByText, queryByText, container } = setup(
customState,
customProps,
);

expect(findByText(alertT5.alertTitle)).to.exist;
expect(container.textContent).to.contain(alertT5.alertContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class FolderManagementPage {
);
cy.get(Locators.BUTTONS.MOVE_BUTTON_TEXT).click();
cy.get(Locators.ALERTS.MOVE_MODAL)

.find('[class = "form-radio-buttons hydrated"]', {
includeShadowDom: true,
})
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"burialFormEnabled": "burial_form_enabled",
"caregiverBrowserMonitoringEnabled": "caregiver_browser_monitoring_enabled",
"caregiverUseFacilitiesApi": "caregiver_use_facilities_API",
"cernerTransition556T30": "cerner_transition_556_t30",
"cernerTransition556T5": "cerner_transition_556_t5",
"cernerOverride653": "cerner_override_653",
"cernerOverride668": "cerner_override_668",
"cernerOverride687": "cerner_override_687",
Expand Down
Loading