Skip to content

test: batch 16 coverage — preflightCheck, useClusterContext, sampleData#11192

Merged
clubanderson merged 2 commits intomainfrom
coverage/batch-16-final-push
May 1, 2026
Merged

test: batch 16 coverage — preflightCheck, useClusterContext, sampleData#11192
clubanderson merged 2 commits intomainfrom
coverage/batch-16-final-push

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

  • Add 116 tests across 3 files to push line coverage from 90.42% past 90.50% (badge rounds to 91%)
  • preflightCheck-coverage (67 tests): classifyKubectlError patterns, resolveRequiredTools, runToolPreflightCheck, runPreflightCheck catch branch, getRemediationActions
  • useClusterContext-coverage (17 tests): operator name stripping, helm chart parsing, pod issues, namespace labels, distribution label, null guards
  • sampleData-coverage (32 tests): field heuristics, detectFieldFormat edge cases

Test plan

  • All 116 tests pass locally (npx vitest run)
  • CI build/lint pass
  • coverage-hourly updates badge to 91%

Copilot AI review requested due to automatic review settings May 1, 2026 01:44
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label May 1, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eeshaansa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 1477bcd
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69f4091a5068c4000999b13c
😎 Deploy Preview https://deploy-preview-11192.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted Vitest coverage suites to exercise previously uncovered branches in preflight tooling, cluster context aggregation, and AI sample-data heuristics—helping keep the web app’s high coverage bar and improving regression detection around edge-case handling.

Changes:

  • Adds additional branch/edge-case tests for preflightCheck.ts (classification, remediation, tool checks, catch-branch normalization).
  • Adds additional tests for useClusterContext aggregation behaviors (resources/issues/labels and null guards).
  • Adds additional tests for sampleData.ts heuristics and detectFieldFormat edge cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
web/src/lib/missions/tests/preflightCheck-coverage.test.ts New coverage-focused tests for preflight error classification, tool checks, and remediation actions
web/src/hooks/tests/useClusterContext-coverage.test.ts New coverage-focused tests for cluster context aggregation logic and null/edge handling
web/src/lib/ai/tests/sampleData-coverage.test.ts New coverage-focused tests for sample data generation heuristics and field-format detection

Comment on lines +398 to +403
it('handles non-Error thrown value (string)', async () => {
const exec = vi.fn().mockRejectedValue('raw string error')

const result = await runPreflightCheck(exec)
expect(result.ok).toBe(false)
})
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

This test currently only asserts ok is false; it doesn't verify the catch-branch classification behavior for non-Error thrown values. Add an assertion on result.error.code and/or result.error.message to ensure the hook keeps returning a stable, useful PreflightError for string throws.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +405 to +410
it('handles null thrown value', async () => {
const exec = vi.fn().mockRejectedValue(null)

const result = await runPreflightCheck(exec)
expect(result.ok).toBe(false)
})
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

Same issue here: asserting only ok is false doesn't validate the specific null-throw handling (the implementation normalizes null to "Unknown execution error"). Add an assertion that confirms the normalized message is used and that the returned PreflightError shape is consistent.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +59 to +63
describe('useClusterContext — additional coverage', () => {
it('extracts base name from operators with -operator suffix', () => {
vi.mocked(useClusters).mockReturnValue({
deduplicatedClusters: [
{ name: 'cluster-1', healthy: true, isCurrent: true },
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

The mocked hook return values are mutated in many tests but there's no beforeEach/afterEach resetting them, so tests can inadvertently depend on state from earlier cases (e.g., useHelmReleases/useOperators return values persisting). Add a beforeEach that restores default mock implementations/return values for all mocked hooks to keep each test independent and avoid order-dependent failures.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +279 to +284
it('returns explicit tools even if empty array', () => {
// Empty explicit array is falsy length, so falls through
const result = resolveRequiredTools('deploy', [])
// Empty array has length 0, so it falls through to type-based lookup
expect(result).toContain('helm')
})
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

The test name is misleading: resolveRequiredTools() only returns explicitTools when the array is non-empty. With an empty array it intentionally falls back to missionType/default tool resolution, so the test should be renamed to reflect that behavior (e.g., "falls back when explicit tools is an empty array").

Copilot uses AI. Check for mistakes.
Comment on lines +434 to +443
it('includes context in MISSING_CREDENTIALS code snippet when provided', () => {
const error: PreflightError = {
code: 'MISSING_CREDENTIALS',
message: 'No kubeconfig',
}
const actions = getRemediationActions(error, 'prod-ctx')
const copyActions = actions.filter(a => a.actionType === 'copy')
// The second copy action should include cloud provider commands
expect(copyActions.some(a => a.codeSnippet?.includes('GKE'))).toBe(true)
})
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

The test name suggests the context value is included in the MISSING_CREDENTIALS snippet, but getRemediationActions() only switches between a generic snippet and provider-login examples based on whether context is provided (it doesn't interpolate the context). Rename the test (and/or adjust the assertion) so the intent matches the actual behavior being verified.

Copilot uses AI. Check for mistakes.
Comment on lines +389 to +396
it('handles cross-realm error with undefined message', async () => {
const crossRealmError = { message: undefined }
const exec = vi.fn().mockRejectedValue(crossRealmError)

const result = await runPreflightCheck(exec)
expect(result.ok).toBe(false)
// Falls through to String(err) path
})
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

This test only asserts ok is false, which makes it very hard to detect regressions (any failure path satisfies the assertion). Since the code is specifically handling the message: undefined cross-realm case, assert something about the resulting error (e.g., that an UNKNOWN_EXECUTION_FAILURE is returned and that the message is derived via String(err) rather than the literal "undefined").

Copilot generated this review using guidance from repository custom instructions.
…xt, 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]>
@clubanderson clubanderson force-pushed the coverage/batch-16-final-push branch from 0e36ebf to ea4a27c Compare May 1, 2026 01:55
@clubanderson clubanderson merged commit c459d9e into main May 1, 2026
25 of 28 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the coverage/batch-16-final-push branch May 1, 2026 02:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

✅ Post-Merge Verification: passed

Commit: c459d9e0a732eb4278d22333b0cce6f8fff17f3e
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/25199045789

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit c459d9e0a732eb4278d22333b0cce6f8fff17f3e.

clubanderson added a commit that referenced this pull request May 1, 2026
…ta (#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]>
clubanderson added a commit that referenced this pull request May 1, 2026
* 🐛 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]>
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🤖 Reviewer: Addressed HIGH + MEDIUM Copilot comments (commit ea119e9d9):

  • Renamed misleading test name: includes context in MISSING_CREDENTIALS code snippet → accurately describes that context is used as a boolean flag to switch between generic vs cloud-provider commands, not embedded in the snippet
  • Renamed returns explicit tools even if empty array → clarifies the empty-array fallthrough to type-based lookup
  • Added expect(result.error?.code).toBe('UNKNOWN_EXECUTION_FAILURE') to three catch-branch tests that only asserted ok: false
  • Added beforeEach to useClusterContext-coverage resetting all vi.mocked hooks to prevent test-to-test contamination

lightyagami2109 pushed a commit to lightyagami2109/kubestellar_console_OJT that referenced this pull request May 3, 2026
…ta (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]>
Signed-off-by: lightyagami2109 <[email protected]>
lightyagami2109 pushed a commit to lightyagami2109/kubestellar_console_OJT that referenced this pull request May 3, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants