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

(refactor) O3-3846: Replace the DatePickers to use the OpenmrsDatePicker #2154

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented Dec 13, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3846

Other

@jwnasambu jwnasambu marked this pull request as draft December 13, 2024 14:22
@jwnasambu jwnasambu force-pushed the feat/O3-3846 branch 2 times, most recently from 83b8b3b to 0b16f3d Compare December 16, 2024 13:56
Copy link
Collaborator

@NethmiRodrigo NethmiRodrigo left a 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:

@NethmiRodrigo NethmiRodrigo changed the title feat/O3-3846: All Calendar Date Pickers should use the same OpenmrsDatePicker component across entire EMR (refactor) O3-3846: Replace the DatePickers to use the OpenmrsDatePicker Dec 16, 2024
@jwnasambu jwnasambu force-pushed the feat/O3-3846 branch 3 times, most recently from 25100b4 to a111ec8 Compare December 18, 2024 12:14
@jwnasambu
Copy link
Contributor Author

@ibacher One thing I am picking from the error I am getting on this PR is specificMockImpl.apply is not a function. I want to believe it occurs when a mocked function is not properly set up, or its implementation does not correctly replicate the original behavior of the function. In this case, OpenmrsDatePicker is being mocked using jest.fn(realOpenmrsDatePicker), which can be a problem if realOpenmrsDatePicker is either a class or a React component and not a function. It’s for that reason I am thinking Instead of using jest.fn(realOpenmrsDatePicker), we mock it directly as a functional component? kindly what is your take?

@denniskigen
Copy link
Member

denniskigen commented Dec 19, 2024

Try using this stub implementation of the OpenmrsDatePicker component in your tests:

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') : ''}
      />
    </>
  );
});

@Muppasanipraneeth
Copy link

Muppasanipraneeth commented Dec 25, 2024

@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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants