🐛 Fix remaining Vitest failures from Coverage Suite run #1873#11184
🐛 Fix remaining Vitest failures from Coverage Suite run #1873#11184clubanderson merged 1 commit intomainfrom
Conversation
- Fix agentFetch mock in workloads.core and workloads-coverage tests to delegate to mockApiGet so test assertions match actual hook fetch path - Add null guard to shareMetricsBetweenSameServerClusters second pass (first pass already guarded, second pass crashed on null input) - Fix useDataCompliance corrupt cache test: with empty clusters the hook completes immediately so isLoading is false, not true Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]>
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
There was a problem hiding this comment.
Pull request overview
Fixes remaining Vitest failures from the coverage suite by aligning test mocks with the current REST fallback implementation (agentFetch), hardening a dedup pure function against nullish inputs, and updating an assertion to match the hook’s real loading behavior.
Changes:
- Updated workloads tests to route
agentFetchmock calls through existingmockApiGetso REST fallback paths receive expected data. - Added a null/undefined guard in the second pass of
shareMetricsBetweenSameServerClusters. - Adjusted
useDataCompliancecorrupt-cache test expectation forisLoading.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
web/src/hooks/mcp/dedup.ts |
Adds null guard for metrics-sharing second pass to prevent crashes on nullish input. |
web/src/hooks/mcp/__tests__/workloads.core.test.ts |
Rewires agentFetch mock to delegate to mockApiGet for REST fallback coverage. |
web/src/hooks/mcp/__tests__/workloads-coverage.test.ts |
Same as above for extended/branch coverage cases. |
web/src/hooks/__tests__/useDataCompliance-coverage.test.ts |
Updates loading expectation when clusters are empty and cache is corrupt. |
| agentFetch: vi.fn().mockImplementation(() => Promise.resolve(new Response(JSON.stringify({}), { status: 200 }))), | ||
| agentFetch: vi.fn().mockImplementation(async (...args: unknown[]) => { | ||
| const result = await mockApiGet(...args) | ||
| return { ok: true, status: 200, json: async () => result?.data ?? result } |
| return (clusters || []).map(cluster => { | ||
| if (!cluster.server) return cluster |
| agentFetch: vi.fn().mockImplementation(() => Promise.resolve(new Response(JSON.stringify({}), { status: 200 }))), | ||
| agentFetch: vi.fn().mockImplementation(async (...args: unknown[]) => { | ||
| const result = await mockApiGet(...args) | ||
| return { ok: true, status: 200, json: async () => result?.data ?? result } |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
✅ Post-Merge Verification: passedCommit: |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
…n, type signatures - feedback_config.go: add resolveGitHubUIBase() for GHE-aware web link construction - feedback_github.go: use resolveGitHubUIBase() for SHA commit link (#11177 follow-up) - ComplianceReports.tsx: clear selectedCluster when it's filtered out by reachability (was only auto-set when empty, leaving stale selection pointing to hidden cluster) - ComplianceReports.tsx + ControlPlaneHealth.tsx: fix misleading 'only reachable' comments — predicate c.reachable !== false also includes undefined (not-yet-checked) - dedup.ts: widen shareMetricsBetweenSameServerClusters signature to ClusterInfo[] | null | undefined to match the runtime guard already in the body (#11184 medium) - shared.ts: fix dedup priority comment — reachability is criterion #1, not #2 Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]>
* 🐛 Fix incorrect assertion in agentFetch 401 retry test Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]> * test: batch 16 coverage — preflightCheck, useClusterContext, sampleData (#11192) * test: add batch 16 coverage tests for preflightCheck, useClusterContext, sampleData Add 116 tests across 3 files to push line coverage past 90.50%: - preflightCheck-coverage (67 tests): classifyKubectlError, resolveRequiredTools, runToolPreflightCheck - useClusterContext-coverage (17 tests): operator name stripping, helm chart parsing, pod issues - sampleData-coverage (32 tests): field heuristics, detectFieldFormat edge cases Signed-off-by: Andrew Anderson <[email protected]> * fix: change savedCards/sharedDashboards to let for reassignment in resetShareRegistries Signed-off-by: Andrew Anderson <[email protected]> --------- Signed-off-by: Andrew Anderson <[email protected]> * 🐛 Fix medium Copilot comments: GHE commit URL, stale cluster selection, type signatures - feedback_config.go: add resolveGitHubUIBase() for GHE-aware web link construction - feedback_github.go: use resolveGitHubUIBase() for SHA commit link (#11177 follow-up) - ComplianceReports.tsx: clear selectedCluster when it's filtered out by reachability (was only auto-set when empty, leaving stale selection pointing to hidden cluster) - ComplianceReports.tsx + ControlPlaneHealth.tsx: fix misleading 'only reachable' comments — predicate c.reachable !== false also includes undefined (not-yet-checked) - dedup.ts: widen shareMetricsBetweenSameServerClusters signature to ClusterInfo[] | null | undefined to match the runtime guard already in the body (#11184 medium) - shared.ts: fix dedup priority comment — reachability is criterion #1, not #2 Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]> --------- Signed-off-by: Copilot <[email protected]> Signed-off-by: Andrew Anderson <[email protected]> Co-authored-by: Copilot <[email protected]>
…r#1873 (kubestellar#11184) - Fix agentFetch mock in workloads.core and workloads-coverage tests to delegate to mockApiGet so test assertions match actual hook fetch path - Add null guard to shareMetricsBetweenSameServerClusters second pass (first pass already guarded, second pass crashed on null input) - Fix useDataCompliance corrupt cache test: with empty clusters the hook completes immediately so isLoading is false, not true Signed-off-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]> Signed-off-by: lightyagami2109 <[email protected]>
…1202) * 🐛 Fix incorrect assertion in agentFetch 401 retry test Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]> * test: batch 16 coverage — preflightCheck, useClusterContext, sampleData (kubestellar#11192) * test: add batch 16 coverage tests for preflightCheck, useClusterContext, sampleData Add 116 tests across 3 files to push line coverage past 90.50%: - preflightCheck-coverage (67 tests): classifyKubectlError, resolveRequiredTools, runToolPreflightCheck - useClusterContext-coverage (17 tests): operator name stripping, helm chart parsing, pod issues - sampleData-coverage (32 tests): field heuristics, detectFieldFormat edge cases Signed-off-by: Andrew Anderson <[email protected]> * fix: change savedCards/sharedDashboards to let for reassignment in resetShareRegistries Signed-off-by: Andrew Anderson <[email protected]> --------- Signed-off-by: Andrew Anderson <[email protected]> * 🐛 Fix medium Copilot comments: GHE commit URL, stale cluster selection, type signatures - feedback_config.go: add resolveGitHubUIBase() for GHE-aware web link construction - feedback_github.go: use resolveGitHubUIBase() for SHA commit link (kubestellar#11177 follow-up) - ComplianceReports.tsx: clear selectedCluster when it's filtered out by reachability (was only auto-set when empty, leaving stale selection pointing to hidden cluster) - ComplianceReports.tsx + ControlPlaneHealth.tsx: fix misleading 'only reachable' comments — predicate c.reachable !== false also includes undefined (not-yet-checked) - dedup.ts: widen shareMetricsBetweenSameServerClusters signature to ClusterInfo[] | null | undefined to match the runtime guard already in the body (kubestellar#11184 medium) - shared.ts: fix dedup priority comment — reachability is criterion kubestellar#1, not kubestellar#2 Co-authored-by: Copilot <[email protected]> Signed-off-by: Copilot <[email protected]> --------- Signed-off-by: Copilot <[email protected]> Signed-off-by: Andrew Anderson <[email protected]> Co-authored-by: Copilot <[email protected]> Signed-off-by: lightyagami2109 <[email protected]>
Fixes #11182
Fix 28 remaining test failures (out of 44 total) not addressed by #11183.
Root Cause
api.getviamockApiGet, but hooks callagentFetch()for the REST API fallback path. TheagentFetchmock returned an empty Response, so test data never reached the hooks.shareMetricsBetweenSameServerClustersguarded the first pass with(clusters || [])but not the second pass, crashing on null input.isLoading=truewith corrupt cache, but with empty clusters the hook completes immediately settingisLoading=false.Changes
workloads.core.test.ts/workloads-coverage.test.ts: WireagentFetchmock to delegate tomockApiGet(adapting response shape) so existing test assertions workdedup.ts: Add null guard to second pass ofshareMetricsBetweenSameServerClustersuseDataCompliance-coverage.test.ts: Fix assertion to match actual hook behaviorVerification
All 299 previously-failing tests now pass across all 7 test files.