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

(fix) Fix DefaultWorkspaceProps type annotations #1996

Merged
merged 2 commits into from
Sep 5, 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 @@ -24,6 +24,9 @@ describe('FormRenderer', () => {
closeWorkspaceWithSavedChanges: jest.fn(),
promptBeforeClosing: jest.fn(),
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

test('renders FormError component when there is an error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ function renderAllergyForm(props = {}) {
patient: mockPatient,
patientUuid: mockPatient.id,
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

render(<AllergyForm {...defaultProps} {...props} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const defaultProps = {
closeWorkspaceWithSavedChanges: jest.fn(),
patientUuid: mockPatient.id,
promptBeforeClosing: jest.fn(),
setTitle: jest.fn(),
setTitle: jest.fn,
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

const mockPastVisits = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const testProps = {
promptBeforeClosing: mockPromptBeforeClosing,
showVisitEndDateTimeFields: false,
setTitle: mockSetTitle,
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

const mockSaveVisit = jest.mocked(saveVisit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const defaultProps = {
promptBeforeClosing: jest.fn(),
formContext: 'creating' as 'creating' | 'editing',
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

function renderConditionsForm(props = {}) {
Expand Down
3 changes: 3 additions & 0 deletions packages/esm-patient-flags-app/src/flags/flags-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ it('renders an Edit form that enables users to toggle flags on or off', async ()
patientUuid={mockPatient.id}
promptBeforeClosing={jest.fn()}
setTitle={jest.fn()}
setCancelTitle={jest.fn()}
setCancelMessage={jest.fn()}
setCancelConfirmText={jest.fn()}
/>,
);

Expand Down
3 changes: 3 additions & 0 deletions packages/esm-patient-forms-app/src/forms/form-entry.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const testProps = {
formInfo: { formUuid: 'some-form-uuid' },
mutateForm: jest.fn(),
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

const mockFormEntrySub = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ describe('FormsDashboard', () => {
closeWorkspaceWithSavedChanges={jest.fn()}
patientUuid=""
setTitle={jest.fn()}
setCancelTitle={jest.fn()}
setCancelMessage={jest.fn()}
setCancelConfirmText={jest.fn()}
/>,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const testProps = {
closeWorkspaceWithSavedChanges: mockCloseWorkspaceWithSavedChanges,
promptBeforeClosing: mockPromptBeforeClosing,
setTitle: mockSetTitle,
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

mockUseConfig.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function renderAddLabOrderWorkspace() {
promptBeforeClosing={mockPromptBeforeClosing}
patientUuid={ptUuid}
setTitle={jest.fn()}
setCancelTitle={jest.fn()}
setCancelMessage={jest.fn()}
setCancelConfirmText={jest.fn()}
/>,
);
return { mockCloseWorkspace, mockPromptBeforeClosing, mockCloseWorkspaceWithSavedChanges, ...view };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default function AddLabOrderWorkspace({
closeWorkspaceWithSavedChanges={closeWorkspaceWithSavedChanges}
promptBeforeClosing={promptBeforeClosing}
setTitle={() => {}}
setCancelTitle={() => {}}
setCancelMessage={() => {}}
setCancelConfirmText={() => {}}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const defaultProps = {
type: 'My List',
},
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

const mockPatientListData = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,7 @@ describe('AddDrugOrderWorkspace drug search', () => {
test('looks ok', async () => {
const user = userEvent.setup();

render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
/>,
);
renderAddDrugOrderWorkspace();

await user.type(screen.getByRole('searchbox'), 'Aspirin');
await screen.findAllByRole('listitem');
Expand All @@ -113,16 +104,7 @@ describe('AddDrugOrderWorkspace drug search', () => {
});
const user = userEvent.setup();

render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
/>,
);
renderAddDrugOrderWorkspace();

await user.type(screen.getByRole('searchbox'), 'Aspirin');
expect(screen.getAllByRole('listitem').length).toEqual(3);
Expand All @@ -133,16 +115,7 @@ describe('AddDrugOrderWorkspace drug search', () => {
test('can add items directly to the basket', async () => {
const user = userEvent.setup();

render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
/>,
);
renderAddDrugOrderWorkspace();

await user.type(screen.getByRole('searchbox'), 'Aspirin');
const { result: hookResult } = renderHook(() =>
Expand All @@ -166,16 +139,7 @@ describe('AddDrugOrderWorkspace drug search', () => {
test('can open the drug form ', async () => {
const user = userEvent.setup();

render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
/>,
);
renderAddDrugOrderWorkspace();

await user.type(screen.getByRole('searchbox'), 'Aspirin');
const { result: hookResult } = renderHook(() =>
Expand All @@ -191,16 +155,7 @@ describe('AddDrugOrderWorkspace drug search', () => {
test('can open an item in the medication form and on saving, it should add the order in the order basket store', async () => {
const user = userEvent.setup();

render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
/>,
);
renderAddDrugOrderWorkspace();

const { result: hookResult } = renderHook(() =>
useOrderBasket('medications', ((x) => x) as unknown as PostDataPrepFunction),
Expand Down Expand Up @@ -233,3 +188,19 @@ describe('AddDrugOrderWorkspace drug search', () => {
);
});
});

function renderAddDrugOrderWorkspace() {
render(
<AddDrugOrderWorkspace
order={undefined as any}
closeWorkspace={({ onWorkspaceClose }) => onWorkspaceClose()}
closeWorkspaceWithSavedChanges={({ onWorkspaceClose }) => onWorkspaceClose()}
promptBeforeClosing={() => false}
patientUuid={'mock-patient-uuid'}
setTitle={jest.fn()}
setCancelTitle={jest.fn()}
setCancelMessage={jest.fn()}
setCancelConfirmText={jest.fn()}
/>,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const defaultProps = {
closeWorkspaceWithSavedChanges: jest.fn(),
promptBeforeClosing: jest.fn(),
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

function renderVisitNotesForm(props = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const testProps = {
patientUuid: mockPatient.id,
promptBeforeClosing: mockPromptBeforeClosing,
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

jest.mock('./programs.resource', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const testProps = {
promptBeforeClosing: () => {},
formContext: 'creating' as 'creating' | 'editing',
setTitle: jest.fn(),
setCancelTitle: jest.fn(),
setCancelMessage: jest.fn(),
setCancelConfirmText: jest.fn(),
};

const mockShowSnackbar = jest.mocked(showSnackbar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ const VitalsAndBiometricsForm: React.FC<DefaultPatientWorkspaceProps> = ({
const height = watch('height');

useEffect(() => {
getMuacColorCode(extractNumbers(age(patient.patient?.birthDate)), midUpperArmCircumference, setMuacColorCode);
const patientBirthDate = patient?.patient?.birthDate;
if (patientBirthDate && midUpperArmCircumference) {
const patientAge = extractNumbers(age(patientBirthDate));
getMuacColorCode(patientAge, midUpperArmCircumference, setMuacColorCode);
}
}, [watch, patient.patient?.birthDate, midUpperArmCircumference]);

useEffect(() => {
Expand Down
Loading