Skip to content

[quality] add unit tests for insights/demoData.ts + registerHooks/hookTables.ts (Refs #22679) - #22691

Merged
kubestellar-hive[bot] merged 1 commit into
mainfrom
quality/test-pure-modules
Aug 21, 2026
Merged

[quality] add unit tests for insights/demoData.ts + registerHooks/hookTables.ts (Refs #22679)#22691
kubestellar-hive[bot] merged 1 commit into
mainfrom
quality/test-pure-modules

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds structural unit tests for two previously-untested pure-data modules — follow-up to #22679. Same lightweight-invariant pattern used for the merged #22686 (acmm.criteria.ts) and open #22688 (unified/registerHooks/demoData.ts).

Files added

web/src/lib/insights/__tests__/demoData.test.ts (18 tests) — targets lib/insights/demoData.ts (149 LOC)

  • getDemoInsights() returns a non-empty array of well-formed MultiClusterInsight objects with unique demo-* ids.
  • category / source / severity are members of the respective type unions.
  • detectedAt parses as ISO and is within the last hour (guards against future-dated demo data).
  • AI-sourced insights carry confidence ∈ [0, 100] and a non-empty provider; heuristic insights carry neither.
  • cascade-impact insights have a well-formed chain[].
  • cluster-delta insights have a well-formed deltas[] with valid significance values.
  • Numeric-metric contract for resource-imbalance and rollout-tracker (with a string-suffix exception for rollout *_status fields).
  • Purity: fresh array each call, stable ids across calls.

web/src/lib/unified/registerHooks/__tests__/hookTables.test.ts (18 tests) — targets lib/unified/registerHooks/hookTables.ts (139 LOC)

  • RESOURCE_HOOKS: unique names, useXxx PascalCase convention, callable useHook, non-empty dataField, arity ∈ {none, cluster, cluster+namespace}, optional wrapRefetch/extra shape checks.
  • CACHED_STATUS_HOOKS: unique names, useCached* convention, callable useCachedHook, non-empty dataField/loadingField, errorMode ∈ {passthrough, isFailed, message}, errorMsg present when the mode implies a message, optional-flag shape checks, callable refetchOverride when set.
  • Cross-table invariant: the two hook-name sets are disjoint.

Result

✓ src/lib/insights/__tests__/demoData.test.ts (18 tests) 91ms
✓ src/lib/unified/registerHooks/__tests__/hookTables.test.ts (18 tests) 90ms
Test Files  2 passed (2)
     Tests  36 passed (36)

Refs #22679 — third in the follow-up series after merged #22686 and open #22688. lib/cache/cacheCore.ts, lib/cache/hooks.ts, lib/cache/worker.ts, lib/kubectlProxy.resources.ts, and the hooks/mcp/* family remain open for later PRs (recorded as advisory beads).


Filed by quality agent (ACMM L3/L6 — full mode)

— hive: agent=quality backend=copilot model=claude-opus-4.7

…ookTables.ts

Adds structural unit tests for two previously-untested modules —
follow-up to #22679.

New files:
- web/src/lib/insights/__tests__/demoData.test.ts (18 tests)
  Targets `lib/insights/demoData.ts` (149 LOC). Verifies:
  * getDemoInsights() returns a non-empty array of well-formed
    MultiClusterInsight objects with unique demo-* ids
  * category, source, severity enum validity
  * ISO detectedAt timestamps within the last hour
  * AI-sourced insights carry confidence in [0, 100] and a provider;
    heuristic insights do not
  * cascade-impact insights have well-formed chain[]
  * cluster-delta insights have well-formed deltas[] with valid
    significance
  * numeric-metric contract for resource-imbalance and rollout-tracker
    (allowing string status suffixes)
  * purity: fresh array on each call, stable ids across calls

- web/src/lib/unified/registerHooks/__tests__/hookTables.test.ts (18 tests)
  Targets `lib/unified/registerHooks/hookTables.ts` (139 LOC).
  Verifies for both RESOURCE_HOOKS and CACHED_STATUS_HOOKS:
  * non-empty, unique hook names following the useXxx / useCached*
    conventions
  * every entry has a callable hook function and non-empty
    dataField / loadingField strings
  * arity is one of none | cluster | cluster+namespace
  * errorMode is one of passthrough | isFailed | message; errorMsg is
    required when errorMode implies a message
  * optional flags (wrapRefetch, optionalData) are boolean when set
  * refetchOverride is a callable factory when set
  * RESOURCE_HOOKS and CACHED_STATUS_HOOKS name sets are disjoint

Result: 36/36 passing locally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: kubestellar-hive[bot] <223556219+Copilot@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Aug 21, 2026
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 1bd4511
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a87fdcb7f8b9d0008edbb0d
😎 Deploy Preview https://deploy-preview-22691.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.

@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 clubanderson 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

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ Playwright Tests Failed

📊 View Full Report

Download the playwright-report artifact from the workflow run for screenshots and detailed traces.

To view the report locally:

# Download and extract playwright-report.zip
npx playwright show-report path/to/playwright-report

@kubestellar-hive
kubestellar-hive Bot merged commit 2160584 into main Aug 21, 2026
44 of 49 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-pure-modules branch August 21, 2026 07:56
@github-actions

Copy link
Copy Markdown
Contributor

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

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 2160584be6e71e12d5c3af160e80aef31a2ddf39.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 2160584be6e71e12d5c3af160e80aef31a2ddf39
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/32460835762

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

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant