test(knative): add unit test coverage for isKnativeInstalled helper - #1075
vikash7485 wants to merge 1 commit into
Conversation
illume
left a comment
There was a problem hiding this comment.
Thanks for these changes.
Can you please have a look at the git commits to see if they meet the contribution guidelines? We use a Linux kernel style of git commits. See the contributing guide for general context, and please see previous git commits with git log for examples.
Commits that need attention
test(knative): add unit test coverage for isKnativeInstalled helper— Missingarea: descriptionprefix — e.g.frontend: HomeButton: Fix so it navigates to homeorbackend: config: Add enable-dynamic-clusters flag.
Commit guidelines
- Use atomic commits focused on a single change.
- Use the title format
<area>: <Description of changes>— description must start with a capital letter. - Keep the title under 72 characters (soft requirement).
- Explain the intention and why the change is needed.
- Make commit titles meaningful and describe what changed.
- Do not add code that a later commit rewrites; squash or reorder commits instead.
- Do not include
Fixes #NNin commit messages.
Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The tests do not verify the CRD name and cluster arguments central to the helper’s behavior.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds unit coverage for Knative installation detection across empty, single-cluster, multi-cluster, missing-CRD, and rejected-request scenarios.
Changes:
- Mocks CRD API responses.
- Tests successful and failed installation checks.
| File | Description |
|---|---|
knative/src/isKnativeInstalled.test.ts |
Adds tests for isKnativeInstalled. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Add unit tests for isKnativeInstalled helper covering single cluster, multi-cluster, missing CRD, and request error cases, with apiGet argument assertions. Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
a548555 to
fefe62c
Compare

Description
This PR adds a comprehensive unit test suite for the
isKnativeInstalledhelper function (plugins/knative/src/isKnativeInstalled.ts), which determines whether Knative CRDs exist on selected cluster(s) to conditionally display or hide Knative navigation in Headlamp.Prior to this PR,
isKnativeInstalled.tshad zero test coverage.Covered Test Scenarios (
plugins/knative/src/isKnativeInstalled.test.ts):falsewhenclustersis an empty array,null, orundefined.truewhen theservices.serving.knative.devCRD exists in a single cluster.falsewhen the Knative CRD is not found in the cluster.truewhen Knative CRDs exist across all selected clusters in a multi-cluster setup.falsewhen Knative CRDs are missing in at least one cluster in a multi-cluster setup.false.How Has This Been Tested?
npx tsc --noEmit(0 errors).npx eslint).npx vitest run(All 28 unit tests passing across 5 test files).