[scanner] fix: add schema validation tests for web/src/config/cards#19655
Conversation
- Add comprehensive schema validation tests for all card configurations - Validate required properties (type, title, category, dataSource, content) - Validate data source types (hook, api, static, context) - Validate content types (list, table, chart, status-grid, stats-grid, custom) - Validate optional properties (stats, filters, emptyState, loadingState, drillDown) - Ensure all 150+ card configs conform to UnifiedCardConfig schema Fixes #19647 Signed-off-by: Copilot <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. |
|
🐝 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. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
| ] as const | ||
|
|
||
| /** Valid renderer types */ | ||
| const VALID_RENDERERS = [ |
There was a problem hiding this comment.
Pull request overview
Adds a new Vitest suite intended to validate the structure of all card configs registered in web/src/config/cards against the UnifiedCardConfig shape, catching missing/invalid fields early.
Changes:
- Introduces a registry-wide validation test for
CARD_CONFIGS(count, key format, key/type consistency, duplicates). - Adds per-card validation coverage for required/optional fields, plus type-specific checks for
dataSource,content,stats,filters,emptyState,loadingState, anddrillDown.
| /** Valid card categories */ | ||
| const VALID_CATEGORIES = [ | ||
| 'cluster-health', | ||
| 'workloads', | ||
| 'events', | ||
| 'network', | ||
| 'storage', | ||
| 'security', | ||
| 'observability', | ||
| 'gitops', | ||
| 'ai-ml', | ||
| 'gaming', | ||
| 'utilities', | ||
| 'compliance', | ||
| 'identity', | ||
| 'cost', | ||
| 'performance', | ||
| ] as const |
| it('has valid category value', () => { | ||
| expect(VALID_CATEGORIES).toContain(config.category as any) | ||
| }) |
| it('has valid variant if specified', () => { | ||
| if (emptyState.variant !== undefined) { | ||
| expect(['info', 'warning', 'error', 'neutral']).toContain(emptyState.variant) | ||
| } | ||
| }) |
| if (stat.icon !== undefined) { | ||
| expect(typeof stat.icon).toBe('string') | ||
| } | ||
|
|
||
| if (stat.color !== undefined) { | ||
| expect(typeof stat.color).toBe('string') | ||
| expect(stat.color).toMatch(/^text-/) | ||
| } | ||
|
|
||
| if (stat.bgColor !== undefined) { | ||
| expect(typeof stat.bgColor).toBe('string') | ||
| expect(stat.bgColor).toMatch(/^bg-/) | ||
| } | ||
|
|
||
| if (stat.label !== undefined) { | ||
| expect(typeof stat.label).toBe('string') | ||
| } |
| /** Valid renderer types */ | ||
| const VALID_RENDERERS = [ | ||
| 'text', | ||
| 'number', | ||
| 'percentage', | ||
| 'bytes', | ||
| 'duration', | ||
| 'date', | ||
| 'datetime', | ||
| 'relative-time', | ||
| 'status-badge', | ||
| 'cluster-badge', | ||
| 'namespace-badge', | ||
| 'progress-bar', | ||
| 'icon', | ||
| 'boolean', | ||
| 'json', | ||
| 'truncate', | ||
| 'link', | ||
| ] as const |
|
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: failedCommit: |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
Fixes #19647
Adds comprehensive schema validation tests for all card configurations in
web/src/config/cards.Changes
web/src/config/cards/__tests__/schema-validation.test.tswith comprehensive validation testsUnifiedCardConfigschematype,title,category,dataSource,contentstats,filters,emptyState,loadingState,drillDownhook,api,static,contextlist,table,chart,status-grid,stats-grid,customTest Coverage
The test suite includes:
All tests follow the existing test patterns in
web/src/config/__tests__/and use vitest as the test framework.