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

feat(tests): adding new mocks strategy to tests #880

Merged
merged 29 commits into from
Dec 10, 2024
Merged

feat(tests): adding new mocks strategy to tests #880

merged 29 commits into from
Dec 10, 2024

Conversation

thetif
Copy link
Collaborator

@thetif thetif commented Nov 27, 2024

Purpose

Replacing the adhoc mocking of the api calls with mock service worker. Created mocks for /item, /itemExists, /getUploadUrl, /submit, /test, and https://api.census.gov/data/2019/pep/population?get=NAME&for=county:*&in=state:${stateString}

Linked Issues to Close

https://jiraent.cms.gov/browse/OY2-31031

Approach

Removed need for redundant mocking for each test. Should speed up writing tests and make the test data more robust.

Assorted Notes/Considerations/Learning

@thetif thetif changed the title tests starting to work adding mocks to tests Nov 27, 2024
Copy link
Contributor

github-actions bot commented Nov 27, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 71.97% 5822 / 8089
🔵 Statements 71.32% 6147 / 8618
🔵 Functions 66.24% 1739 / 2625
🔵 Branches 38.53% 1061 / 2753
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
lib/packages/shared-types/user.ts 100% 100% 100% 100%
lib/packages/shared-types/events/upload-subsequent-documents.ts 100% 100% 100% 100%
lib/packages/shared-types/opensearch/changelog/index.ts 100% 100% 100% 100%
lib/packages/shared-types/opensearch/changelog/transforms/app-k.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/capitated-amendment.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/capitated-initial.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/capitated-renewal.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/contracting-amendment.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/contracting-initial.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/contracting-renewal.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/legacy-event.ts 57.14% 60% 75% 61.11% 35-45, 49, 41-43
lib/packages/shared-types/opensearch/changelog/transforms/new-chip-submission.ts 18.18% 0% 0% 14.28% 4-34, 5-22
lib/packages/shared-types/opensearch/changelog/transforms/new-medicaid-submission.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/respond-to-rai.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/temporary-extension.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/upload-subsequent-documents.ts 18.18% 0% 0% 14.28% 3-26, 4-15
lib/packages/shared-types/opensearch/changelog/transforms/withdraw-package.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/changelog/transforms/withdraw-rai.ts 18.18% 0% 0% 14.28% 3-33, 4-21
lib/packages/shared-types/opensearch/main/index.ts 100% 100% 100% 100%
lib/packages/shared-types/opensearch/main/transforms/app-k.ts 25% 0% 0% 14.28% 8-36
lib/packages/shared-types/opensearch/main/transforms/capitated-amendment.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/capitated-initial.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/capitated-renewal.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/contracting-amendment.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/contracting-initial.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/contracting-renewal.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/legacy-package-view.ts 82.35% 65% 50% 85.71% 11, 47-55, 65-66
lib/packages/shared-types/opensearch/main/transforms/new-chip-submission.ts 25% 0% 0% 14.28% 9-36
lib/packages/shared-types/opensearch/main/transforms/new-medicaid-submission.ts 25% 0% 0% 14.28% 9-35
lib/packages/shared-types/opensearch/main/transforms/remove-appk-child.ts 50% 0% 0% 33.33% 4-10
lib/packages/shared-types/opensearch/main/transforms/seatool.ts 56.57% 45.19% 48.38% 59.67% 22-29, 46-55, 59, 62, 65, 109, 119-121, 149-163, 191-55, 81-109
lib/packages/shared-types/opensearch/main/transforms/temporary-extension.ts 28.57% 0% 0% 16.66% 9-35
lib/packages/shared-types/opensearch/main/transforms/toggle-withdraw-rai.ts 40% 0% 0% 50% 6-10, 6-10
lib/packages/shared-types/opensearch/main/transforms/upload-subsequent-documents.ts 40% 0% 0% 50% 4-7, 4-7
lib/packages/shared-types/opensearch/main/transforms/withdraw-package.ts 40% 0% 0% 25% 4-16
lib/packages/shared-types/opensearch/main/transforms/withdraw-rai-response.ts 40% 0% 0% 25% 4-14
lib/packages/shared-types/tests/legacy-event.test.ts 100% 71.42% 100% 100%
lib/packages/shared-utils/package-check.ts 100% 100% 100% 100%
lib/packages/shared-utils/testData.ts 100% 100% 100% 100%
lib/packages/shared-utils/package-actions/getAvailableActions.ts 9.09% 0% 0% 10% 9-39, 21-37
react-app/src/api/amplifyConfig.ts 100% 100% 100% 100%
react-app/src/api/itemExists.ts 100% 100% 100% 100%
react-app/src/api/submissionService.ts 58.82% 37.93% 64.28% 58.06% 34, 72-86, 146-178, 189-191
react-app/src/api/useGetItem.test.ts 100% 100% 100% 100%
react-app/src/api/useGetTypes.test.ts 100% 100% 100% 100%
react-app/src/api/useGetUser.ts 100% 91.66% 100% 100%
react-app/src/components/ActionForm/ActionForm.test.tsx 75.9% 100% 58.33% 75.9% 34-35, 51-52, 75-76, 100-101, 125-128, 149-150, 174-175, 201-202, 221-222, 256-257, 286, 375, 414, 536-537, 557-558, 574-575, 599-600, 617-618, 641-642, 663-664, 680-681
react-app/src/components/ActionForm/index.tsx 94.59% 92.59% 88.88% 94.44% 275-276
react-app/src/components/Inputs/upload.test.tsx 100% 100% 100% 100%
react-app/src/components/Layout/index.test.tsx 100% 70% 97.91% 100%
react-app/src/components/RHF/tests/FieldArray.test.tsx 100% 100% 100% 100%
react-app/src/components/RHF/tests/NameGen.test.tsx 85.29% 100% 50% 85.29% 60-61, 76, 94, 114
react-app/src/components/RHF/tests/Section.test.tsx 100% 100% 100% 100%
react-app/src/components/RHF/tests/Slot.test.tsx 100% 100% 100% 100%
react-app/src/components/RHF/tests/SlotField.test.tsx 100% 100% 100% 100%
react-app/src/components/TimeoutModal/TimeoutModal.test.tsx 100% 100% 100% 100%
react-app/src/components/TimeoutModal/index.tsx 90.9% 83.33% 83.33% 90.9% 40, 46
react-app/src/features/dashboard/Lists/renderCells/index.tsx 25% 0% 0% 30% 9-11, 20-26, 29-32
react-app/src/features/forms/new-submission/chip.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/new-submission/medicaid.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/amend/index.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/amend/index.tsx 100% 87.5% 100% 100%
react-app/src/features/forms/post-submission/respond-to-rai/chip.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/respond-to-rai/index.tsx 66.66% 100% 50% 66.66% 18, 46, 74
react-app/src/features/forms/post-submission/respond-to-rai/medicaid.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/respond-to-rai/waiver.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/upload-subsequent-documents/index.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/upload-subsequent-documents/index.tsx 72.72% 53.84% 88.88% 72.72% 22, 64, 72-83, 146
react-app/src/features/forms/post-submission/withdraw-package/chip.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/withdraw-package/index.tsx 41.66% 0% 33.33% 41.66% 8-41, 93, 141
react-app/src/features/forms/post-submission/withdraw-package/medicaid.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/post-submission/withdraw-rai/index.test.tsx 100% 50% 100% 100%
react-app/src/features/forms/waiver/app-k/index.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/capitated/amendment.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/capitated/initial.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/capitated/renewal.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/contracting/amendment-contracting.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/contracting/initial-contracting.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/contracting/renewal-contracting.test.tsx 100% 100% 100% 100%
react-app/src/features/forms/waiver/temporary-extension/temporary-extension.test.tsx 100% 100% 100% 100%
react-app/src/features/package/package-activity/index.test.tsx 100% 100% 100% 100%
react-app/src/features/package/package-activity/index.tsx 94.28% 91.89% 100% 94.28% 160, 167
react-app/src/features/package/package-details/hooks.tsx 13.88% 0% 0% 15.62% 14-28, 42-129, 135-147, 152-156, 160-176
react-app/src/features/profile/index.tsx 100% 100% 100% 100%
react-app/src/features/profile/profile.test.tsx 100% 100% 100% 100%
react-app/src/formSchemas/capitated-renewal.ts 100% 100% 100% 100%
react-app/src/hooks/UseReadOnlyUser.test.tsx 100% 100% 100% 100%
react-app/src/hooks/useReadOnlyUser.tsx 100% 100% 100% 100%
react-app/src/utils/Utils.test.tsx 97.67% 100% 87.5% 100% 76
react-app/src/utils/zod.test.ts 100% 100% 100% 100%
react-app/src/utils/Poller/DataPoller.ts 100% 87.5% 100% 100%
react-app/src/utils/test-helpers/renderForm.tsx 100% 85.71% 100% 100%
Generated in workflow #914 for commit e95f24a by the Vitest Coverage Report Action

Copy link
Collaborator

@asharonbaltazar asharonbaltazar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the greater good 🫡

@asharonbaltazar
Copy link
Collaborator

Please don't forget to delete your branch after merging, thanks!

Copy link
Contributor

🎉 This PR is included in version 1.5.0-val.98 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants