Skip to content

Commit

Permalink
Removes vaOnlineSchedulingStatusImprovement from ScheduleNewAppointme…
Browse files Browse the repository at this point in the history
…nt component (#28048)

* Removes  vaOnlineSchedulingStatusImprovement from ScheduleNewAppointment

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* Updates unit tests

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* Revert "Updates unit tests"

This reverts commit c61a9cc.

* Updates unit test

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* WIP: skip test

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* WIP: update unit tests

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* WIP: updates unit test

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

* Upates unit tests

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>

---------

Signed-off-by: Ryan Shaw <ryan.shaw@adhocteam.us>
  • Loading branch information
ryanshaw authored and Peter Hill committed Mar 14, 2024
1 parent de30666 commit 604ae82
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 100 deletions.
Expand Up @@ -4,11 +4,7 @@ import { useHistory, useLocation } from 'react-router-dom';
import { recordEvent } from '@department-of-veterans-affairs/platform-monitoring/exports';
import { GA_PREFIX } from 'applications/vaos/utils/constants';
import { startNewAppointmentFlow } from '../redux/actions';
import {
selectFeatureRequests,
selectFeatureStatusImprovement,
selectFeatureStartSchedulingLink,
} from '../../redux/selectors';
import { selectFeatureStartSchedulingLink } from '../../redux/selectors';
// eslint-disable-next-line import/no-restricted-paths
import getNewAppointmentFlow from '../../new-appointment/newAppointmentFlow';

Expand Down Expand Up @@ -68,44 +64,14 @@ function ScheduleNewAppointmentButton() {
}

export default function ScheduleNewAppointment() {
const history = useHistory();
const dispatch = useDispatch();
const location = useLocation();
const featureStatusImprovement = useSelector(state =>
selectFeatureStatusImprovement(state),
);
const showScheduleButton = useSelector(state => selectFeatureRequests(state));
const { typeOfCare } = useSelector(getNewAppointmentFlow);

if (featureStatusImprovement) {
// Only display scheduling button on upcoming appointments page
if (
location.pathname.endsWith('pending') ||
location.pathname.endsWith('past')
) {
return null;
}
return <ScheduleNewAppointmentButton />;
// Only display scheduling button on upcoming appointments page
if (
location.pathname.endsWith('pending') ||
location.pathname.endsWith('past')
) {
return null;
}

return (
<>
{!featureStatusImprovement &&
showScheduleButton && (
<div className="vads-u-margin-bottom--1p5 vaos-hide-for-print">
Schedule primary or specialty care appointments.
</div>
)}

<button
type="button"
className="vaos-hide-for-print"
aria-label="Start scheduling an appointment"
id="schedule-button"
onClick={handleClick(history, dispatch, typeOfCare)}
>
Start scheduling
</button>
</>
);
return <ScheduleNewAppointmentButton />;
}
Expand Up @@ -86,8 +86,7 @@ describe('VAOS Page: AppointmentsPage', () => {
},
});

expect(screen.getByText(/Schedule primary or specialty care appointments./))
.to.be.ok;
expect(screen.getByText(/Start scheduling/)).to.be.ok;
userEvent.click(
await screen.findByRole('button', { name: /Start scheduling/i }),
);
Expand Down
Expand Up @@ -5,7 +5,10 @@ import { mockFetch } from '@department-of-veterans-affairs/platform-testing/help
import userEvent from '@testing-library/user-event';
import sinon from 'sinon';
import { fireEvent, waitFor } from '@testing-library/react';
import { APPOINTMENT_STATUS } from '../../../../utils/constants';
import {
APPOINTMENT_STATUS,
TYPE_OF_VISIT_ID,
} from '../../../../utils/constants';
import { renderWithStoreAndRouter, getTestDate } from '../../../mocks/setup';

import { AppointmentList } from '../../../../appointment-list';
Expand Down Expand Up @@ -66,7 +69,6 @@ describe('VAOS Page: ConfirmedAppointmentDetailsPage with VAOS service', () => {
});
mockFacilityFetchByVersion({ facility: facilityResponse });

// Act
// Act
const screen = renderWithStoreAndRouter(<AppointmentList />, {
initialState,
Expand Down Expand Up @@ -122,66 +124,36 @@ describe('VAOS Page: ConfirmedAppointmentDetailsPage with VAOS service', () => {
});

it('should show confirmed phone appointments detail page', async () => {
// Given a booked phone appointment
const myInitialState = {
...initialState,
featureToggles: {
...initialState.featureToggles,
vaOnlineSchedulingVAOSServiceVAAppointments: true,
},
};
// When fetching the specific appointment id
const url = '/va/1234';
const futureDate = moment(getTestDate());

const appointment = getVAOSAppointmentMock();
appointment.id = '1234';
appointment.attributes = {
...appointment.attributes,
kind: 'phone',
clinic: '455',
// Arrange
const response = new MockAppointmentResponse({
kind: TYPE_OF_VISIT_ID.phone,
});
response
.setLocationId('983GC')
.setClinicId('455')
.setReasonCode({ text: 'I have a headache' });
const clinicResponse = new MockClinicResponse({
id: 455,
locationId: '983GC',
id: '1234',
preferredTimesForPhoneCall: ['Morning'],
reasonCode: {
coding: [{ code: 'New Problem' }],
text: 'I have a headache',
},
comment: 'New issue: I have a headache',
serviceType: 'primaryCare',
localStartTime: futureDate.format('YYYY-MM-DDTHH:mm:ss.000ZZ'),
start: futureDate.add(1, 'days').format(),
status: 'booked',
cancellable: true,
};
name: 'Some fancy clinic name',
});
const facilityResponse = new MockFacilityResponse({ id: '983GC' });

mockSingleClinicFetchByVersion({
mockAppointmentApi({ response });
mockClinicsApi({
clinicId: '455',
locationId: '983GC',
clinicName: 'Some fancy clinic name',
version: 2,
});
mockSingleVAOSAppointmentFetch({ appointment });

mockFacilityFetchByVersion({
facility: createMockFacilityByVersion({
id: '983GC',
name: 'Cheyenne VA Medical Center',
phone: '970-224-1550',
address: {
postalCode: '82001-5356',
city: 'Cheyenne',
state: 'WY',
line: ['2360 East Pershing Boulevard'],
},
}),
response: [clinicResponse],
});
mockFacilityFetchByVersion({ facility: facilityResponse });

// Act
const screen = renderWithStoreAndRouter(<AppointmentList />, {
initialState: myInitialState,
path: url,
initialState,
path: `/va/${response.id}`,
});

// Assert
// Verify document title and content...
await waitFor(() => {
expect(document.activeElement).to.have.tagName('h1');
Expand All @@ -191,7 +163,9 @@ describe('VAOS Page: ConfirmedAppointmentDetailsPage with VAOS service', () => {
screen.getByRole('heading', {
level: 1,
name: new RegExp(
futureDate.tz('America/Denver').format('dddd, MMMM D, YYYY'),
moment()
.tz('America/Denver')
.format('dddd, MMMM D, YYYY'),
'i',
),
}),
Expand Down Expand Up @@ -222,11 +196,11 @@ describe('VAOS Page: ConfirmedAppointmentDetailsPage with VAOS service', () => {
name: 'You shared these details about your concern',
}),
).to.be.ok;
expect(screen.getByText(/New medical issue: I have a headache/)).to.be.ok;
expect(screen.getByText(/I have a headache/)).to.be.ok;
expect(
screen.getByTestId('add-to-calendar-link', {
name: new RegExp(
futureDate
moment()
.tz('America/Denver')
.format('[Add] MMMM D, YYYY [appointment to your calendar]'),
'i',
Expand Down

0 comments on commit 604ae82

Please sign in to comment.