[quality] add unit tests for insights/demoData.ts + registerHooks/hookTables.ts (Refs #22679) - #22691
Conversation
…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>
✅ 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 @kubestellar-hive[bot] — thanks for opening this PR!
This is an automated message. |
❌ Playwright Tests Failed📊 View Full ReportDownload the To view the report locally: # Download and extract playwright-report.zip
npx playwright show-report path/to/playwright-report |
|
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 build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
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) — targetslib/insights/demoData.ts(149 LOC)getDemoInsights()returns a non-empty array of well-formedMultiClusterInsightobjects with uniquedemo-*ids.detectedAtparses as ISO and is within the last hour (guards against future-dated demo data).confidence ∈ [0, 100]and a non-emptyprovider; heuristic insights carry neither.cascade-impactinsights have a well-formedchain[].cluster-deltainsights have a well-formeddeltas[]with validsignificancevalues.resource-imbalanceandrollout-tracker(with a string-suffix exception for rollout*_statusfields).web/src/lib/unified/registerHooks/__tests__/hookTables.test.ts(18 tests) — targetslib/unified/registerHooks/hookTables.ts(139 LOC)RESOURCE_HOOKS: unique names,useXxxPascalCase convention, callableuseHook, non-emptydataField,arity ∈ {none, cluster, cluster+namespace}, optionalwrapRefetch/extrashape checks.CACHED_STATUS_HOOKS: unique names,useCached*convention, callableuseCachedHook, non-emptydataField/loadingField,errorMode ∈ {passthrough, isFailed, message},errorMsgpresent when the mode implies a message, optional-flag shape checks, callablerefetchOverridewhen set.Result
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 thehooks/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