-
Notifications
You must be signed in to change notification settings - Fork 245
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
(refactor) O3-3846: Replace Carbon datepickers with reusable OpenmrsDatePicker
#2154
base: main
Are you sure you want to change the base?
Conversation
packages/esm-patient-chart-app/src/mark-patient-deceased/mark-patient-deceased-form.scss
Outdated
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-date-time.component.tsx
Show resolved
Hide resolved
packages/esm-patient-tests-app/src/test-results/print-modal/print-modal.extension.tsx
Outdated
Show resolved
Hide resolved
83b8b3b
to
0b16f3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jwnasambu! Left a few nitpicks:
...ges/esm-patient-chart-app/src/mark-patient-deceased/mark-patient-deceased-form.workspace.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-conditions-app/src/conditions/conditions-widget.component.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-conditions-app/src/conditions/conditions-widget.component.tsx
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/components/orders-details-table.component.tsx
Show resolved
Hide resolved
packages/esm-patient-programs-app/src/programs/programs-form.workspace.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-tests-app/src/test-results/print-modal/print-modal.extension.tsx
Show resolved
Hide resolved
25100b4
to
a111ec8
Compare
packages/esm-patient-tests-app/src/test-results/print-modal/print-modal.extension.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-tests-app/src/test-results/print-modal/print-modal.extension.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-programs-app/src/programs/programs-form.workspace.tsx
Outdated
Show resolved
Hide resolved
…tePicker component across entire EMR
381a91d
to
1583d36
Compare
…-chart into feat/O3-3846
@ibacher One thing I am picking from the error I am getting on this PR is |
Try using this stub implementation of the import { OpenmrsDatePicker } from '@openmrs/esm-framework';
const mockOpenmrsDatePicker = jest.mocked(OpenmrsDatePicker);
mockOpenmrsDatePicker.mockImplementation(({ id, labelText, value, onChange }) => {
return (
<>
<label htmlFor={id}>{labelText}</label>
<input
aria-label={labelText.toString()}
id={id}
onChange={(evt) => {
onChange(dayjs(evt.target.value).toDate());
}}
type="text"
// @ts-ignore
value={value ? dayjs(value).format('DD/MM/YYYY') : ''}
/>
</>
);
}); |
@jwnasambu Standardize the use of the OpenMRS date picker Across All Apps O3-4287 however you are working on it . I checked what are changes you made . you already working on the visits, medication,conditions,Immunization,program,and other I think you did not worked on the Appointments so please work on it also Thank you . |
OpenmrsDatePicker
className={styles.datePicker} | ||
dateFormat="d/m/Y" | ||
datePickerType="single" | ||
id="deceasedDate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to maintain parity between the props passed to the Carbon datepicker and those passed to OpenmrsDatePicker
. In this case, this implementation is missing several props including labelText
, isInvalid
, and invalidText
. It should look like this instead:
<OpenmrsDatePicker
className={styles.datePicker}
id="deceasedDate"
isInvalid={!!errors?.deathDate}
invalidText={errors?.deathDate?.message}
labelText={t('dateOfDeath', 'Date of death')}
maxDate={new Date().toISOString()}
onChange={(date) => onChange(date)}
value={value}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @denniskigen
So I looked at the failing programs form tests and I couldn't exactly figure out why they were failing to set the correct dates. In the interest of getting the tests passing, I think we could modify it as follows: describe('ProgramsForm', () => {
const inpatientWardUuid = 'b1a8b05e-3542-4037-bbd3-998ee9c40574';
const oncologyScreeningProgramUuid = '11b129ca-a5e7-4025-84bf-b92a173e20de';
it('renders a success toast notification upon successfully recording a program enrollment', async () => {
await user.type(enrollmentDateInput, '2020-05-05'); // remove this line so we rely on the default enrollment date
});
it('updates a program enrollment', async () => {
const completionDateInput = screen.getByRole('textbox', { name: /date completed/i }); // remove this line and replace it with the next line
const enrollmentLocationInput = screen.getByRole('combobox', { name: /enrollment location/i });
// so we can simulate changing the enrollment location instead of the date
// remove the next two lines
await user.type(completionDateInput, '05/05/2020');
await user.tab();
// and replace them with the next two lines
await user.click(enrollmentLocationInput);
await user.selectOptions(enrollmentLocationInput, [inpatientWardUuid]);
expect(mockUpdateProgramEnrollment).toHaveBeenCalledTimes(1);
// and then assert using this payload instead
expect(mockUpdateProgramEnrollment).toHaveBeenCalledWith(
mockEnrolledProgramsResponse[0].uuid,
expect.objectContaining({
dateCompleted: null,
dateEnrolled: expect.stringMatching(/^2020-01-16/),
location: mockLocationsResponse[1].uuid,
patient: mockPatient.id,
program: mockEnrolledProgramsResponse[0].program.uuid,
}),
new AbortController(),
);
});
}; |
Another observation I made is that you'd need to add the
|
Thanks @denis I was somewhere I had reduced some build failures from 4 to one only that my adapter has blown off and I am planning to pick up from there tomorrow by God's grace when my issue is fixed.
Yahoo Mail: Search, Organize, Conquer
On Tue, Jan 7, 2025 at 10:11 PM, Dennis ***@***.***> wrote:
Another observation I made is that you'd need to add the OpenmrsDatePicker stub to the following tests to fix the specificMockImpl.apply is not a function error:
- mark-patient-deceased-form.test.tsx
- visit-form.test.tsx
- conditions-form.test.tsx
- immunizations-form.test.tsx
- add-drug-order.test.tsx
- visit-notes-form.test.tsx
- order-details-table.test.tsx
- programs-form.test.tsx
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Requirements
Summary
This PR replaces usages of the Carbon DatePicker component with our custom reusable OpenmrsDatePicker component.
Screenshots
Related Issue
https://openmrs.atlassian.net/browse/O3-3846
Other