# GSoC 2023: Enhancing Component Test Coverage and Quality for OpenMRS3 Project updates and discussions

**URL:** <https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691>\
**Category:** Quality Assurance\
**Tags:** qa, gsoc2023, o3\
**Created:** [May 22, 2023, 4:06pm UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691 "2023-05-22T16:06:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayushmishra](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ayushmishra/32/17973_2.png) [@ayushmishra](https://talk.openmrs.org/u/ayushmishra)\
**Post date:** [May 22, 2023, 4:06pm UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691/1 "2023-05-22T16:06:30Z")

</div>

Hello Everyone,

I will be working on the project [GSoC 2023: Enhancing Component Test Coverage and Quality for OpenMRS3](https://wiki.openmrs.org/display/projects/GSoC+2023%3A+Enhancing+Component+Test+Coverage+and+Quality+for+OpenMRS3). This project will aim to achieve a high level of test coverage for O3 repos (patient-chart and patient-management will be primary repos) by using consistent and comprehensive unit and integration testing strategy.

The key areas of improvement for this project include:

1. Test Coverage: By identifying areas of the codebase with insufficient test coverage, we will work towards achieving a higher level of confidence in the quality and stability of the O3 repositories. This will involve writing new tests and enhancing existing ones.
2. Consistency: A consistent testing strategy ensures that tests are structured uniformly across the codebase. By adhering to established guidelines and best practices, we will create a reliable and predictable testing framework.
3. Comprehensive Testing: The project aims to cover a wide range of scenarios, including edge cases and potential error conditions, to ensure the robustness of the code. By considering various use cases and testing different aspects of the system, we can provide more comprehensive protection against potential issues.

**Mentors**

Primary Mentor: @piumal1999

Backup Mentor: @anjisvj

**Resources**

1. Project Details: [Link](https://wiki.openmrs.org/pages/viewpage.action?pageId=313327996)
2. Testing strategy docs: [Link](https://wiki.openmrs.org/pages/viewpage.action?pageId=313328159)
3. Meeting Notes: [Link](https://docs.google.com/document/d/1YOqTFF0H0_EkDWa-njcOsooyQQh_t78kmv5tSqHJUlk/edit?usp=sharing)
4. Meeting Link: [join here](https://meet.google.com/wfc-ebry-bfh)

We have weekly call for discussion about the project. Everyone is invited to join and be a part of discussion. I am eager to have discussion with you all regarding this project. Meeting details are given below:

GSOC’23 - Enhancing Component Test Coverage and Quality for OpenMRS3 Weekly discussion Wednesday, May 31 · 7:00 – 8:00pm Time zone: Asia/Kolkata

Video call link: [https://meet.google.com/wfc-ebry-bfh](https://meet.google.com/wfc-ebry-bfh)

Thank you for your support, and I welcome any suggestions or advice as I embark on this exciting journey.@jayasanka @jennifer @grace @ibacher @dennis @vasharma05 @hadijah315 @kdaud @piumal1999 @anjisvj

---

<div class="post-metadata">

**Author:** ![ayushmishra](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ayushmishra/32/17973_2.png) [@ayushmishra](https://talk.openmrs.org/u/ayushmishra)\
**Post date:** [May 31, 2023, 4:45am UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691/2 "2023-05-31T04:45:29Z")

</div>

Hello Everyone, The coding period has started, and I am excited to provide updates on the project progress during the community bonding period. I joined the onboarding call and gained lot of insights on how to complete my gsoc successfully. Then I had meeting with my mentors @piumal1999 and @anjisvj in which we discussed about the project the scope and the timeline. Most of the things are same as I proposed. Mentors are very helpful and explained how should I work efficiently. They also clarified more about the project and how should I proceed with the project.

I was working on improving the existing tests and created an epic for that. [Here](https://issues.openmrs.org/browse/O3-2063) is the link. I completed almost all the issues and created PR for all the issues out of which three of them are under review.

The links to the PR which I created during the community Bonding Period:-

> <https://github.com/openmrs/openmrs-esm-patient-management/pull/707>
>
> \## Requirements
> 
> \- \[x\] This PR has a title that briefly describes the work don…e including the ticket number. If there is a ticket, make sure your PR title includes a \[conventional commit\](https://o3-dev.docs.openmrs.org/#/getting\_started/contributing?id=your-pr-title-should-indicate-the-type-of-change-it-is) label. See existing PR titles for inspiration.
> \- \[\] My work conforms to the \[\*\*OpenMRS 3.0 Styleguide\*\*\](https://om.rs/styleguide) and \[\*\*design documentation\*\*\](https://zeroheight.com/23a080e38/p/880723-introduction).
> \- \[\] I checked for feature overlap with \[\*\*existing widgets\*\*\](https://om.rs/directory).
> 
> 
> \## Summary
> 
> In this PR, I tried to update the failing tests which was getting skipped. The test was failing because the error text was not coming when input field was left empty. I tried to fix those by mocking the input component. I also mocked the formik component.
> 
> \<!--
> Required.
> Please describe what problems your PR addresses.
> \--\>
> 
> 
> \## Screenshots
> 
> \<img width="1055" alt="Screenshot 2023-05-29 at 10 56 22 PM" src="https://github.com/openmrs/openmrs-esm-patient-management/assets/54752747/da368882-2e3a-4881-98bc-9f51915dae7c"\>
> 
> 
> \*None.\*
> \<!--
> Optional.
> If possible, please insert any screenshots/videos of your changes here.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Related Issue
> 
> https://issues.openmrs.org/browse/O3-2081
> 
> \*None.\*
> \<!--
> Required if applicable.
> If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/123").
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Other
> 
> Please carefully check If I am mocking input component and formik correctly or not. 
> 
> \*None.\*
> \<!--
> Optional.
> Anything else that isn't covered by one of the sections above.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>

Below one is the draft PR yet, because one of the test is still failing.

> <https://github.com/openmrs/openmrs-esm-patient-management/pull/709>
>
> \## Requirements
> 
> \- \[x\] This PR has a title that briefly describes the work don…e including the ticket number. If there is a ticket, make sure your PR title includes a \[conventional commit\](https://o3-dev.docs.openmrs.org/#/getting\_started/contributing?id=your-pr-title-should-indicate-the-type-of-change-it-is) label. See existing PR titles for inspiration.
> \- \[\] My work conforms to the \[\*\*OpenMRS 3.0 Styleguide\*\*\](https://om.rs/styleguide) and \[\*\*design documentation\*\*\](https://zeroheight.com/23a080e38/p/880723-introduction).
> \- \[\] I checked for feature overlap with \[\*\*existing widgets\*\*\](https://om.rs/directory).
> 
> 
> \## Summary
> 
> In this PR, I am fixed all the failing test cases for \[patient-registation.test.tsx\](https://github.com/openmrs/openmrs-esm-patient-management/blob/c9e9e6b6dea780a43e08b9c2ff61f56cdc702a49/packages/esm-patient-registration-app/src/patient-registration/patient-registration.test.tsx) file. There were multiple tests failing due to multiple reasons. I addressed those issues and now all the tests are passing except \[this one\](https://github.com/ayush-AI/openmrs-esm-patient-management/blob/9294feaa15f4eb110db5766f20b76b2fe7c9465e/packages/esm-patient-registration-app/src/patient-registration/patient-registration.test.tsx#LL268C6-L268C6). I have added necessary comments why the test is failing and also commented the approaches that I took in attempt to fix the issue, but the test is still failing.
> 
> \<!--
> Required.
> Please describe what problems your PR addresses.
> \--\>
> 
> 
> \## Screenshots
> 
> \*None.\*
> \<!--
> Optional.
> If possible, please insert any screenshots/videos of your changes here.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Related Issue
> 
> https://issues.openmrs.org/browse/O3-2082
> \<!--
> Required if applicable.
> If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/123").
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Other
> 
> Please look into the failing test and suggest some ways to fix it.
> 
> \*None.\*
> \<!--
> Optional.
> Anything else that isn't covered by one of the sections above.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>

Apart from this I also created a milestone docs for the gsoc2023.

> **[GSoC 2023: Enhancing Component Test Coverage and Quality for O3 Milestones](https://docs.google.com/document/d/1GjGQJK0EAwfyaICtY4LPvMtlV8S5pe4B6v1nnobD3kk/edit?usp=sharing)**
>
> GSoC 2023: Enhancing Component Test Coverage and Quality for O3 Milestones Enhance component Test Coverage for Patient Management Repo Improve the existing tests List out the components for which tests should be written. Setup the MSW Rewrite the...

I started my work with fixing the existing tests and then listing out the components for which more tests are needed. Doing so gave me some idea about how the tests are written, what are the issues with the existing tests and what challenges I can face while writing the tests. After completing these step I will move ahead with the mock service worker setup and then start writing the new tests for the improved coverage.

This is the path I will be following throughout the gsoc for each repo, currently I am doing for the [patient-management](https://github.com/openmrs/openmrs-esm-patient-management) repo and then I will move ahead with [patient-chart repo](https://github.com/openmrs/openmrs-esm-patient-chart). These two repos are primary focus during the gsoc. If you have an alternative approach that you believe may be more effective, I would greatly appreciate your suggestions.

PROGRESS:

1. Fixed the existing tests on patient-management repo(almost done)
2. List out the tests for patient-management repo(done)

UPNEXT:

1. Setup MSW in patient-management repo
2. Improve the tests using new setup.
3. Improve the coverage by writing new tests.

@jayasanka @anjisvj @dennis @piumal1999 and all that are interested.

---

<div class="post-metadata">

**Author:** ![ayushmishra](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ayushmishra/32/17973_2.png) [@ayushmishra](https://talk.openmrs.org/u/ayushmishra)\
**Post date:** [June 13, 2023, 5:16pm UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691/3 "2023-06-13T17:16:20Z")

</div>

Hello Everyone Below is my Blog posts:

- [Community Bonding Period Blog](https://medium.com/@ayushmishra2854/gsoc23-community-bonding-recap-26d0bf070a00)

- [Week 01 Blog](https://medium.com/@ayushmishra2854/gsoc23-community-bonding-recap-26d0bf070a00)

- [Week 02 Blog](https://medium.com/@ayushmishra2854/week-02-gsoc23-with-openmrs-b565606b9524)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [June 14, 2023, 6:17am UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691/4 "2023-06-14T06:17:07Z")

</div>

Impressive! Keep up the good work, @ayushmishra !

---

<div class="post-metadata">

**Author:** ![ayushmishra](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ayushmishra/32/17973_2.png) [@ayushmishra](https://talk.openmrs.org/u/ayushmishra)\
**Post date:** [June 26, 2023, 12:53pm UTC](https://talk.openmrs.org/t/gsoc-2023-enhancing-component-test-coverage-and-quality-for-openmrs3-project-updates-and-discussions/39691/5 "2023-06-26T12:53:11Z")

</div>

Hello Everyone,

The fourth week of coding Period has been completed and I am excited to provide updated on the project progress during these four weeks. I was working on fixing the existing tests which were getting skipped and had also created an [epic](https://issues.openmrs.org/browse/O3-2063) for that. I had completed the epic but found that we are left with one more component which tests are getting skipped i.e. identifier-input component. I created another [issue](https://issues.openmrs.org/browse/O3-2209) for this. Currently this is in progress and getting hard time in fixing these tests. This is the only component left from the epic whose PR is not ready for review yet. Other than that I have two PR which are under review. The PR Links are:-

> <https://github.com/openmrs/openmrs-esm-patient-management/pull/709>
>
> \## Requirements
> 
> \- \[x\] This PR has a title that briefly describes the work don…e including the ticket number. If there is a ticket, make sure your PR title includes a \[conventional commit\](https://o3-dev.docs.openmrs.org/#/getting\_started/contributing?id=your-pr-title-should-indicate-the-type-of-change-it-is) label. See existing PR titles for inspiration.
> \- \[\] My work conforms to the \[\*\*OpenMRS 3.0 Styleguide\*\*\](https://om.rs/styleguide) and \[\*\*design documentation\*\*\](https://zeroheight.com/23a080e38/p/880723-introduction).
> \- \[\] I checked for feature overlap with \[\*\*existing widgets\*\*\](https://om.rs/directory).
> 
> 
> \## Summary
> 
> In this PR, I fixed all the failing test cases for \[patient-registation.test.tsx\](https://github.com/openmrs/openmrs-esm-patient-management/blob/c9e9e6b6dea780a43e08b9c2ff61f56cdc702a49/packages/esm-patient-registration-app/src/patient-registration/patient-registration.test.tsx) file. There were multiple tests failing due to multiple reasons. I addressed those issues and now all the tests are passing except \[this one\](https://github.com/ayush-AI/openmrs-esm-patient-management/blob/9294feaa15f4eb110db5766f20b76b2fe7c9465e/packages/esm-patient-registration-app/src/patient-registration/patient-registration.test.tsx#LL268C6-L268C6). I have added necessary comments why the test is failing and also commented the approaches that I took in attempt to fix the issue, but the test is still failing.
> 
> \<!--
> Required.
> Please describe what problems your PR addresses.
> \--\>
> 
> 
> \## Screenshots
> 
> \*None.\*
> \<!--
> Optional.
> If possible, please insert any screenshots/videos of your changes here.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Related Issue
> 
> https://issues.openmrs.org/browse/O3-2082
> \<!--
> Required if applicable.
> If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/123").
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Other
> 
> Please look into the failing test and suggest some ways to fix it.
> 
> \*None.\*
> \<!--
> Optional.
> Anything else that isn't covered by one of the sections above.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>

> <https://github.com/openmrs/openmrs-esm-patient-management/pull/680>
>
> \## Requirements
> 
> \- \[x\] This PR has a title that briefly describes the work don…e including the ticket number. If there is a ticket, make sure your PR title includes a \[conventional commit\](https://o3-dev.docs.openmrs.org/#/getting\_started/contributing?id=your-pr-title-should-indicate-the-type-of-change-it-is) label. See existing PR titles for inspiration.
> \- \[\] My work conforms to the \[\*\*OpenMRS 3.0 Styleguide\*\*\](https://om.rs/styleguide) and \[\*\*design documentation\*\*\](https://zeroheight.com/23a080e38/p/880723-introduction).
> \- \[\] I checked for feature overlap with \[\*\*existing widgets\*\*\](https://om.rs/directory).
> 
> 
> \## Summary
> I have updated the tests for the death-info-section component in this PR. I noticed that the tests were failing due to the missing isDead context, causing them to be skipped. I fixed this issue and the tests now pass successfully.
> \<!--
> Required.
> Please describe what problems your PR addresses.
> \--\>
> 
> 
> \## Screenshots
> 
> \*None.\*
> \<!--
> Optional.
> If possible, please insert any screenshots/videos of your changes here.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Related Issue
> 
> https://issues.openmrs.org/browse/O3-2073
> 
> \<!--
> Required if applicable.
> If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/123").
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Other
> 
> \*None.\*
> \<!--
> Optional.
> Anything else that isn't covered by one of the sections above.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>

One PR I got merged for fixing the patient-registration-validation component. Test for this component was integration tests. But after the suggestion of @piumal1999 I changed it to unit tests. This was all for the update for fixing the skipped tests. Let’s move to the next step i.e. the MSW setup.

We are not going to use the MSW you can check [this conversation](https://talk.openmrs.org/t/configuring-mockserviceworker-on-o3-repos/39708) for the reasoning.

Now the next step is to write the new tests. For this I have decided to go by each micro-frontend one by one. I have started working on writing the new tests for the esm-patient-registration-app and created the epic for this. You can check the [epic here](https://issues.openmrs.org/browse/O3-2214). I have written tests for the one of the component named field.component.tsx and written all the tests but one of them is failing due to some missing mock values. I have created draft PR for this also. PR link:-

> <https://github.com/openmrs/openmrs-esm-patient-management/pull/741>
>
> \## Requirements
> 
> \- \[x\] This PR has a title that briefly describes the work don…e including the ticket number. If there is a ticket, make sure your PR title includes a \[conventional commit\](https://o3-dev.docs.openmrs.org/#/getting\_started/contributing?id=your-pr-title-should-indicate-the-type-of-change-it-is) label. See existing PR titles for inspiration.
> \- \[\] My work conforms to the \[\*\*OpenMRS 3.0 Styleguide\*\*\](https://om.rs/styleguide) and \[\*\*design documentation\*\*\](https://zeroheight.com/23a080e38/p/880723-introduction).
> \- \[\] I checked for feature overlap with \[\*\*existing widgets\*\*\](https://om.rs/directory).
> 
> 
> \## Summary
> 
> In this PR I have added the Tests for field.component.tsx of esm-patient-registration-app.
> 
> \## Screenshots
> \<img width="963" alt="Screenshot 2023-06-24 at 10 30 08 PM" src="https://github.com/openmrs/openmrs-esm-patient-management/assets/54752747/d313afe7-8abb-470d-afcd-3d9357181d2e"\>
> 
> 
> 
> \## Related Issue
> https://issues.openmrs.org/browse/O3-2215
> \<!--
> Required if applicable.
> If present, please link any related issue here, e.g. "https://issues.openmrs.org/browse/123").
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>
> 
> 
> \## Other
> 
> \*None.\*
> \<!--
> Optional.
> Anything else that isn't covered by one of the sections above.
> Don't forget to remove the \*None.\* above if you do fill this section.
> \--\>

I will work on writing new tests for esm-patient-registration-app throughtout this week.

Thank you for your support. Keep supporting and keep suggesting.
