[quality] unit tests for LLMd utility functions (KVCacheMonitor.utils + nightlyE2E.constants)#19662
Conversation
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
[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 |
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
✅ Test Coverage CheckAll new source files in this PR have corresponding test files. Checked |
There was a problem hiding this comment.
Pull request overview
This PR improves frontend test coverage by adding Vitest unit tests for two pure utility modules under web/src/components/cards/llmd/, targeting previously untested logic called out by #19631.
Changes:
- Adds unit tests for
KVCacheMonitor.utilshelpers (aggregation, trend, history trimming, layout sizing/classes, heatmap thresholds, display name formatting, and exported constants). - Adds unit tests for
nightlyE2E.constantshelpers (guide metadata extraction, average duration computation, duration formatting, and key constants).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| web/src/components/cards/llmd/tests/KVCacheMonitor.utils.test.ts | Adds coverage for KV cache monitor utility functions and constants. |
| web/src/components/cards/llmd/tests/nightlyE2E.constants.test.ts | Adds coverage for nightly E2E constants and helper functions. |
| it('returns zeros for null/undefined-like input', () => { | ||
| const result = calculateAggregateMetrics([] as KVCacheStats[]) | ||
| expect(result.avgUtil).toBe(0) | ||
| }) |
| const stack = { | ||
| cluster: 'test-cluster', | ||
| namespace: 'llmd', | ||
| name: 'test-stack', | ||
| components: { | ||
| prefill: [{ name: 'prefill-svc', replicas: 2, readyReplicas: 2, podNames: ['p-0', 'p-1'] }], | ||
| decode: [{ name: 'decode-svc', replicas: 1, readyReplicas: 1, podNames: ['d-0'] }], | ||
| both: [], | ||
| }, | ||
| } | ||
| const result = generateMonitorStats({ | ||
| aggregationMode: 'aggregated', | ||
| isDemoMode: false, | ||
| prometheusMetrics: null, | ||
| selectedStack: stack as any, | ||
| }) |
| const stack = { | ||
| cluster: 'test-cluster', | ||
| namespace: 'llmd', | ||
| name: 'test-stack', | ||
| components: { | ||
| prefill: [{ name: 'prefill-svc', replicas: 2, readyReplicas: 2, podNames: ['p-0', 'p-1'] }], | ||
| decode: [], | ||
| both: [], | ||
| }, | ||
| } | ||
| const result = generateMonitorStats({ | ||
| aggregationMode: 'disaggregated', | ||
| isDemoMode: false, | ||
| prometheusMetrics: null, | ||
| selectedStack: stack as any, | ||
| }) |
| { status: 'failed', createdAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-01T00:30:00Z' }, | ||
| ] as unknown as NightlyRun[] |
| { | ||
| status: 'failed', | ||
| createdAt: '2026-01-01T00:00:00Z', | ||
| updatedAt: '2026-01-01T02:00:00Z', | ||
| }, |
|
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 |
Fixes the shared root cause that broke render tests across card components and mission components after PR #19662 merged. Root cause: The new test files (KVCacheMonitor.utils.test.ts and nightlyE2E.constants.test.ts) were running in the default jsdom environment instead of Node.js environment. Since they test pure utility functions that import React types, these tests were polluting the global scope when they ran, affecting subsequent jsdom tests in CI (where tests run sequentially with 1 worker). Fix: Added @vitest-environment node directive to both test files so they run in Node.js environment instead of jsdom, preventing global scope pollution. This follows the same pattern as the fix in #19663 which resolved the previous 168 test failure cascade. Signed-off-by: Copilot <copilot@users.noreply.github.com> Co-authored-by: Copilot <copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Improvement
Adds 50+ unit tests for two previously-untested pure utility modules in
web/src/components/cards/llmd/:KVCacheMonitor.utils.test.ts(40+ tests)nightlyE2E.constants.test.ts(15+ tests)Partially addresses #19631 — targets the remaining untested utility files in
web/src/components/cards/llmd/.Filed by quality agent (ACMM L4/L6 — full mode)