Skip to content

Commit

Permalink
Wmedders21/appeals 50767 (#22091)
Browse files Browse the repository at this point in the history
* Fixed TimeSlot test

* update comment in test

* fix schedule veteran form test

* fix jest test from erroring out
  • Loading branch information
wmedders21 authored Jul 9, 2024
1 parent 0a2d17a commit 46f9d55
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
14 changes: 12 additions & 2 deletions client/test/app/hearings/components/ScheduleVeteranForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { mount } from 'enzyme';
import { VIRTUAL_HEARING_LABEL } from 'app/hearings/constants';
import { ScheduleVeteranForm } from 'app/hearings/components/ScheduleVeteranForm';
import { ReadOnly } from 'app/hearings/components/details/ReadOnly';
import { amaAppeal, defaultHearing, virtualHearing } from 'test/data';
import { amaAppeal } from 'test/data';
import { defaultHearing, virtualHearing } from 'test/data/hearings';
import { generateAmaTask } from 'test/data/tasks';
import { queueWrapper } from 'test/data/stores/queueStore';
import HearingTypeDropdown from 'app/hearings/components/details/HearingTypeDropdown';
Expand All @@ -21,13 +22,20 @@ import { Timezone } from 'app/hearings/components/VirtualHearings/Timezone';
import { UnscheduledNotes } from 'app/hearings/components/UnscheduledNotes';
import { HearingTime } from 'app/hearings/components/modalForms/HearingTime';
import { ReadOnlyHearingTimeWithZone } from 'app/hearings/components/modalForms/ReadOnlyHearingTimeWithZone';
import ApiUtil from 'app/util/ApiUtil';

// Set the spies
const changeSpy = jest.fn();
const submitSpy = jest.fn();
const cancelSpy = jest.fn();
const fetchScheduledHearingsMock = jest.fn();
const getSpy = jest.spyOn(ApiUtil, 'get');

describe('ScheduleVeteranForm', () => {
beforeEach(() => {
getSpy.mockImplementation(() => Promise.resolve({ body: {} }));
});

test('Matches snapshot with default props', () => {
// Render the address component
const scheduleVeteran = mount(
Expand All @@ -50,13 +58,14 @@ describe('ScheduleVeteranForm', () => {
expect(scheduleVeteran).toMatchSnapshot();
});

test('Displays hearing form when regional office is selected', () => {
test('Displays hearing form when regional office is selected', async () => {
// Render the address component
const scheduleVeteran = mount(
<ScheduleVeteranForm
goBack={cancelSpy}
submit={submitSpy}
onChange={changeSpy}
fetchScheduledVeterans={fetchScheduledHearingsMock}
appeal={{
...amaAppeal,
regionalOffice: defaultHearing.regionalOfficeKey,
Expand Down Expand Up @@ -220,6 +229,7 @@ describe('ScheduleVeteranForm', () => {
test('Displays ReadOnlyHearingTimeWithZone when video is selected and halfDay is true', () => {
const hearing = {
...defaultHearing,
requestType: 'Video',
regionalOffice: defaultHearing.regionalOfficeKey,
hearingDay: {
hearingId: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ exports[`ScheduleVeteranForm Displayes Unschedules Notes input 1`] = `
"hearingDay",
undefined,
],
Array [
"hearingDay",
undefined,
],
Array [
"hearingDay",
Object {
Expand Down Expand Up @@ -315,6 +319,10 @@ exports[`ScheduleVeteranForm Displayes Unschedules Notes input 1`] = `
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
}
Expand Down Expand Up @@ -21700,6 +21708,10 @@ exports[`ScheduleVeteranForm Displays HearingTime when video is selected and hal
"hearingDay",
undefined,
],
Array [
"hearingDay",
undefined,
],
Array [
"hearingDay",
Object {
Expand Down Expand Up @@ -21759,6 +21771,10 @@ exports[`ScheduleVeteranForm Displays HearingTime when video is selected and hal
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
}
Expand Down Expand Up @@ -58338,6 +58354,7 @@ exports[`ScheduleVeteranForm Displays ReadOnlyHearingTimeWithZone when video is
"representativeEmailAddress": "tom.brady@caseflow.gov",
"representativeName": null,
"representativeTz": "America/Los_Angeles",
"requestType": "Video",
"room": "1",
"scheduledFor": "2020-07-06T06:00:00.000-04:00",
"scheduledForIsPast": false,
Expand Down Expand Up @@ -58384,6 +58401,10 @@ exports[`ScheduleVeteranForm Displays ReadOnlyHearingTimeWithZone when video is
"hearingDay",
undefined,
],
Array [
"hearingDay",
undefined,
],
Array [
"hearingDay",
Object {
Expand Down Expand Up @@ -58432,6 +58453,10 @@ exports[`ScheduleVeteranForm Displays ReadOnlyHearingTimeWithZone when video is
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
}
Expand Down Expand Up @@ -58610,6 +58635,7 @@ exports[`ScheduleVeteranForm Displays ReadOnlyHearingTimeWithZone when video is
"representativeEmailAddress": "tom.brady@caseflow.gov",
"representativeName": null,
"representativeTz": "America/Los_Angeles",
"requestType": "Video",
"room": "1",
"scheduledFor": "2020-07-06T06:00:00.000-04:00",
"scheduledForIsPast": false,
Expand Down Expand Up @@ -142147,6 +142173,10 @@ exports[`ScheduleVeteranForm Displays error messages when errors are present 1`]
"hearingDay",
undefined,
],
Array [
"hearingDay",
undefined,
],
Array [
"hearingDay",
Object {
Expand Down Expand Up @@ -142176,6 +142206,10 @@ exports[`ScheduleVeteranForm Displays error messages when errors are present 1`]
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
}
Expand Down Expand Up @@ -169747,6 +169781,7 @@ exports[`ScheduleVeteranForm Displays hearing form when regional office is selec
"withdrawn": false,
}
}
fetchScheduledVeterans={[MockFunction]}
goBack={[MockFunction]}
hearing={
Object {
Expand Down Expand Up @@ -218886,6 +218921,10 @@ exports[`ScheduleVeteranForm RO dropdown includes Virtual Hearings as option is
"hearingDay",
undefined,
],
Array [
"hearingDay",
undefined,
],
Array [
"hearingDay",
Object {
Expand Down Expand Up @@ -218915,6 +218954,10 @@ exports[`ScheduleVeteranForm RO dropdown includes Virtual Hearings as option is
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import moment from 'moment-timezone/moment-timezone';
import { uniq } from 'lodash';
// caseflow
import { TimeSlot } from 'app/hearings/components/scheduleHearing/TimeSlot';
import { formatTimeSlotLabel, hearingTimeOptsWithZone, setTimeSlots, TIMEZONES_WITH_LUNCHBREAK } from 'app/hearings/utils';
import {
formatTimeSlotLabel,
hearingTimeOptsWithZone,
setTimeSlots,
TIMEZONES_WITH_LUNCHBREAK
} from 'app/hearings/utils';
// constants
import REGIONAL_OFFICE_INFORMATION from '../../../../../constants/REGIONAL_OFFICE_INFORMATION';
import HEARING_TIME_OPTIONS from '../../../../../constants/HEARING_TIME_OPTIONS';
import TIMEZONES from 'constants/TIMEZONES';

const emptyHearings = [];
const oneHearing = [{
Expand Down Expand Up @@ -180,17 +186,18 @@ describe('TimeSlot', () => {
});

it('slots have correct time values to submit to backend', () => {
const { timeSlots, utils } = setup({ roTimezone: ro.timezone });
const { timeSlots } = setup({ roTimezone: ro.timezone });

const roTime = timeSlots[0].hearingTime;

clickTimeslot(roTime, ro.timezone);
const easternTime = moment.tz(roTime, 'HH:mm', 'America/New_York').tz(ro.timezone).
format('HH:mm');
const tzName = Object.keys(TIMEZONES).find((key) => TIMEZONES[key] === ro.timezone);

// Expect that we called onChange with 12:30pm ro timezone
expect(mockOnChange).toHaveBeenLastCalledWith('scheduledTimeString', easternTime);
clickTimeslot(roTime, ro.timezone);
const timeString = `${moment.tz(roTime, 'HH:mm', 'America/New_York').tz(ro.timezone).
format('h:mm A')} ${tzName}`;

// Expect that we called onChange with ro timezone
expect(mockOnChange).toHaveBeenLastCalledWith('scheduledTimeString', timeString);
});

it('moves following slots when there is a lunch break', () => {
Expand Down

0 comments on commit 46f9d55

Please sign in to comment.