Mirrors page tests#569
Conversation
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Adds/updates unit tests around the Mirrors UI, while adjusting a few helpers and MSW handlers to better support Mirrors page behavior in tests.
Changes:
- Added Vitest coverage for multiple Mirrors components (list, details, actions, modals, counts, form flows).
- Updated Mirrors list/actions rendering to handle missing mirror names and pass explicit props to actions.
- Tweaked utilities/mocks/MSW handlers to align with Mirrors page data shapes and URL/query-param conventions.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/output.ts | Makes boolToLabel accept optional boolean (used by Mirrors details). |
| src/utils/_helpers.ts | Allows pluralizeNew to be called with an omitted/undefined count via default param. |
| src/tests/server/handlers/mirrors.ts | Improves MSW mirror GET handling (lookup by id, returns 404 when missing) and aligns param naming. |
| src/tests/mocks/ubuntuArchiveInfo.ts | Adds a new Ubuntu Pro service fixture used by Mirrors UI tests. |
| src/features/wsl-profiles/components/WslProfileEditSidePanel/WslProfileEditSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/wsl-profiles/components/WslProfileDetailsSidePanel/WslProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/upgrade-profiles/components/UpgradeProfileDetailsSidePanel/UpgradeProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/security-profiles/components/SecurityProfileDownloadAuditSidePanel/SecurityProfileDownloadAuditSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/security-profiles/components/SecurityProfileDetailsSidePanel/SecurityProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/removal-profiles/components/RemovalProfileEditSidePanel/RemovalProfileEditSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/removal-profiles/components/RemovalProfileDetailsSidePanel/RemovalProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/reboot-profiles/components/RebootProfileEditSidePanel/RebootProfileEditSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/reboot-profiles/components/RebootProfileDuplicateSidePanel/RebootProfileDuplicateSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/reboot-profiles/components/RebootProfileDetailsSidePanel/RebootProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/package-profiles/components/PackageProfileEditSidePanel/PackageProfileEditSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/package-profiles/components/PackageProfileDetailsSidePanel/PackageProfileDetailsSidePanel.test.tsx | Updates tests to use name query param. |
| src/features/mirrors/components/UpdateMirrorModal/UpdateMirrorModal.test.tsx | Adds tests for update modal behavior (but has an assertion issue). |
| src/features/mirrors/components/SelectableMirrorContentsBlock/SelectableMirrorContentsBlock.test.tsx | Adds render-focused tests for selectable contents block. |
| src/features/mirrors/components/RemoveMirrorModal/RemoveMirrorModal.test.tsx | Adds tests for remove modal (publications list + delete action). |
| src/features/mirrors/components/MirrorsList/MirrorsList.tsx | Renders actions column as NoData when mirror.name is missing; passes explicit action props. |
| src/features/mirrors/components/MirrorsList/MirrorsList.test.tsx | Adds tests for list rendering with/without data. |
| src/features/mirrors/components/MirrorPublicationsList/MirrorPublicationsList.test.tsx | Adds a smoke test for publications list rendering. |
| src/features/mirrors/components/MirrorPublicationsLink/MirrorPublicationsLink.test.tsx | Adds tests for publications link count rendering. |
| src/features/mirrors/components/MirrorPackagesCount/MirrorPackagesCount.tsx | Uses pluralizeNew defaulting behavior when packages list is absent. |
| src/features/mirrors/components/MirrorPackagesCount/MirrorPackagesCount.test.tsx | Adds tests for exact vs limited package count display. |
| src/features/mirrors/components/MirrorDetails/MirrorDetails.tsx | Uses boolToLabel for boolean labels in the details panel. |
| src/features/mirrors/components/MirrorDetails/MirrorDetails.test.tsx | Adds a smoke test for details panel rendering/loading. |
| src/features/mirrors/components/MirrorActions/MirrorActions.tsx | Refactors actions to accept mirrorName/mirrorDisplayName instead of full Mirror object. |
| src/features/mirrors/components/MirrorActions/MirrorActions.test.tsx | Adds a render smoke test for actions component. |
| src/features/mirrors/components/EditMirrorForm/EditMirrorForm.test.tsx | Adds tests for editing different mirror source types. |
| src/features/mirrors/components/AddMirrorForm/AddMirrorForm.tsx | Changes how components/architectures inputs are edited (string input ↔ array state) and simplifies sourceType change logic. |
| src/features/mirrors/components/AddMirrorForm/AddMirrorForm.test.tsx | Adds tests for adding mirrors across source types. |
Comments suppressed due to low confidence (2)
src/features/mirrors/components/AddMirrorForm/AddMirrorForm.tsx:263
- Same issue as the Components field: the custom
onBlurreplaces Formik’s blur handler, soarchitecturesmay not becometouched, which can suppress validation errors fromgetFormikErroruntil submit. Callformik.handleBlur(event)(or set touched explicitly) alongside the normalization.
onBlur={async (event) => {
await formik.setFieldValue(
"architectures",
event.target.value.split(", ").filter(Boolean),
);
}}
src/features/mirrors/components/AddMirrorForm/AddMirrorForm.tsx:243
- The custom
onBlurhandler overrides Formik’s default blur handling fromgetFieldProps, so the field may never be marked astouched. That can preventgetFormikErrorfrom surfacing validation errors until submit. Consider callingformik.handleBlur(event)(orsetFieldTouched) in addition to your normalization logic.
onBlur={async (event) => {
await formik.setFieldValue(
"components",
event.target.value.split(", ").filter(Boolean),
);
}}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…Modal.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
marqode
left a comment
There was a problem hiding this comment.
Mirror tests all lgtm! When I ran with coverage locally I see some gaps on the following:
- PublishMirrorForm missing test file
- VSCode coverage tool shows <=60% coverage of useCreateMirror, useDeleteMirror, useListMirror, useSyncMirror, useUpdateMirror and useDistribution
I'm not sure how thoroughly we try to cover hooks / api calls at this stage.
|
Thanks @marqode! The |
Tests for mirrors page
Also fixed profile side panel tests, which weren't updated to use the newly renamed
nameparam