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

Removes My VA Health from VAOS direct schedule facility page #33516

Merged
merged 2 commits into from
Dec 12, 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
@@ -1,17 +1,13 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { shallowEqual, useSelector } from 'react-redux';
import { getCernerURL } from 'platform/utilities/cerner';
import { VaSelect } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { selectFacilitiesRadioWidget } from '../../redux/selectors';
import State from '../../../components/State';
import InfoAlert from '../../../components/InfoAlert';
import { FACILITY_SORT_METHODS, FETCH_STATUS } from '../../../utils/constants';
import { scrollAndFocus } from '../../../utils/scrollAndFocus';
import { isCernerLocation } from '../../../services/location';
import NoAddressNote from '../NoAddressNote';
import { useOHDirectScheduling } from '../../hooks/useOHDirectScheduling';
import { useOHRequestScheduling } from '../../hooks/useOHRequestScheduling';

const INITIAL_FACILITY_DISPLAY_COUNT = 5;
/*
Expand All @@ -26,12 +22,10 @@
onChange,
formContext,
}) {
const {
cernerSiteIds,
requestLocationStatus,
sortMethod,
loadingEligibility,
} = useSelector(state => selectFacilitiesRadioWidget(state), shallowEqual);
const { requestLocationStatus, sortMethod, loadingEligibility } = useSelector(
state => selectFacilitiesRadioWidget(state),
shallowEqual,
);

const { hasUserAddress, sortOptions, updateFacilitySortMethod } = formContext;
const { enumOptions } = options;
Expand Down Expand Up @@ -67,16 +61,13 @@
);
});

const useOHDirectSchedule = useOHDirectScheduling();
const useOHRequestSchedule = useOHRequestScheduling();

useEffect(
() => {
if (displayedOptions.length > INITIAL_FACILITY_DISPLAY_COUNT) {
scrollAndFocus(`#${id}_${INITIAL_FACILITY_DISPLAY_COUNT + 1}`);
}
},
[displayedOptions.length, displayAll],

Check warning on line 70 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:70:5:React Hook useEffect has a missing dependency: 'id'. Either include it or remove the dependency array.

Check warning on line 70 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:70:5:React Hook useEffect has a missing dependency: 'id'. Either include it or remove the dependency array.
);

return (
Expand Down Expand Up @@ -109,7 +100,7 @@
level="3"
>
<p>Make sure your browser’s location feature is turned on.</p>
<button

Check warning on line 103 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:103:15:The <va-button> Web Component should be used instead of the button HTML element.

Check warning on line 103 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:103:15:The <va-button> Web Component should be used instead of the button HTML element.
type="button"
className="va-button-link"
onClick={() =>
Expand All @@ -128,7 +119,6 @@
displayedOptions.map((option, i) => {
const { name, address, legacyVAR } = option?.label;
const checked = option.value === value;
const isCerner = isCernerLocation(option.value, cernerSiteIds);
let distance;

if (sortMethod === FACILITY_SORT_METHODS.distanceFromResidential) {
Expand Down Expand Up @@ -165,12 +155,6 @@
{distance} miles
</span>
)}
{isCerner &&
(!useOHDirectSchedule && !useOHRequestSchedule) && (
<a href={getCernerURL('/pages/scheduling/upcoming')}>
Schedule online at <strong>My VA Health</strong>
</a>
)}
</label>
</div>
);
Expand All @@ -178,7 +162,7 @@
{!displayAll &&
!requestingLocationFailed &&
hiddenCount > 0 && (
<button

Check warning on line 165 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:165:11:The <va-button> Web Component should be used instead of the button HTML element.

Check warning on line 165 in src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/vaos/new-appointment/components/VAFacilityPage/FacilitiesRadioWidget.jsx:165:11:The <va-button> Web Component should be used instead of the button HTML element.
type="button"
className="additional-info-button usa-button-secondary vads-u-display--block"
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect } from 'chai';

// eslint-disable-next-line import/no-unresolved
import { mockFetch } from '@department-of-veterans-affairs/platform-testing/helpers';
import { fireEvent, waitFor, within } from '@testing-library/dom';
import { fireEvent, waitFor } from '@testing-library/dom';
import { cleanup } from '@testing-library/react';
import VAFacilityPage from './VAFacilityPageV2';
import {
Expand Down Expand Up @@ -1317,16 +1317,6 @@ describe('VAOS Page: VAFacilityPage', () => {
expect(await screen.findByText(/First Cerner facility/i)).to.be.ok;
expect(screen.getByText(/Second Cerner facility/i)).to.be.ok;

// Make sure Cerner link shows up
const cernerSiteLabel = document.querySelector(
`label[for="${screen.getByLabelText(/First Cerner facility/i).id}"]`,
);
expect(
within(cernerSiteLabel)
.getByRole('link', { name: /My VA Health/ })
.getAttribute('href'),
).to.contain('pages/scheduling/upcoming');

// Make sure Cerner facilities show up only once
expect(screen.getAllByText(/Second Cerner facility/i)).to.have.length(1);
userEvent.click(screen.getByLabelText(/First cerner facility/i));
Expand All @@ -1338,131 +1328,4 @@ describe('VAOS Page: VAFacilityPage', () => {
);
});
});

describe('when OH Direct Scheduling is enabled', () => {
beforeEach(() => mockFetch());

const initialState = {
drupalStaticData: {
vamcEhrData: {
loading: false,
data: {
ehrDataByVhaId: {
'442': {
vhaId: '442',
vamcFacilityName: 'Cheyenne VA Medical Center',
vamcSystemName: 'VA Cheyenne health care',
ehr: 'cerner',
},
'552': {
vhaId: '552',
vamcFacilityName: 'Dayton VA Medical Center',
vamcSystemName: 'VA Dayton health care',
ehr: 'cerner',
},
},
cernerFacilities: [
{
vhaId: '442',
vamcFacilityName: 'Cheyenne VA Medical Center',
vamcSystemName: 'VA Cheyenne health care',
ehr: 'cerner',
},
{
vhaId: '552',
vamcFacilityName: 'Dayton VA Medical Center',
vamcSystemName: 'VA Dayton health care',
ehr: 'cerner',
},
],
vistaFacilities: [],
},
},
},
featureToggles: {
vaOnlineSchedulingDirect: true,
vaOnlineSchedulingUseDsot: true,
vaOnlineSchedulingOhDirectSchedule: true,
},
user: {
profile: {
facilities: [
{
facilityId: '442', // Must use real facility id when using DSOT
isCerner: false, // Not used when using DSOT
},
{ facilityId: '552', isCerner: false },
],
},
},
};

it('should not display MHV scheduling link for foodAndNutrition appointments', async () => {
mockFacilitiesFetch({
children: true,
facilities: [
createMockFacility({
id: '983',
name: 'First cerner facility',
lat: 39.1362562,
long: -83.1804804,
}),
createMockFacility({
id: '984',
name: 'Second Cerner facility',
lat: 39.1362562,
long: -83.1804804,
}),
],
});

mockSchedulingConfigurations([
getSchedulingConfigurationMock({
id: '983',
typeOfCareId: 'foodAndNutrition',
directEnabled: true,
}),
getSchedulingConfigurationMock({
id: '984',
typeOfCareId: 'foodAndNutrition',
directEnabled: true,
}),
]);

const store = createTestStore({
...initialState,
user: {
...initialState.user,
profile: {
...initialState.user.profile,
vapContactInfo: {
residentialAddress: {
latitude: 39.1362562,
longitude: -84.6804804,
},
},
},
},
});

await setTypeOfCare(store, /nutrition and food/i);

const screen = renderWithStoreAndRouter(<VAFacilityPage />, {
store,
});

// Make sure Cerner facilities show up
expect(await screen.findByText(/First Cerner facility/i)).to.be.ok;
expect(await screen.getByText(/Second Cerner facility/i)).to.be.ok;

// Make sure Cerner link does not show up for foodAndNutrition
const cernerSiteLabel = document.querySelector(
`label[for="${screen.getByLabelText(/First Cerner facility/i).id}"]`,
);

expect(
within(cernerSiteLabel).queryByRole('link', { name: /My VA Health/ }),
).not.to.exist;
});
});
});
Loading