test(core): add yaml-validator unit test coverage#193
test(core): add yaml-validator unit test coverage#193nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
Conversation
|
@nikolasdehor is attempting to deploy a commit to the Pedro Valério Lopez's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Pedrovaleriolopez @oalanicolas requesting review on this test coverage PR for the yaml-validator module. All 69 tests pass locally covering every public method of the |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit test coverage for the YAMLValidator utility class, contributing to the test coverage improvement initiative outlined in Issue #52. The tests verify YAML validation, auto-fixing, and reporting functionality across different YAML types (agent, manifest, workflow, and general).
Changes:
- Added 69 unit tests covering all public methods of
YAMLValidatorclass - Added tests for the
validateYAML()convenience function - Includes tests for validation rules, error handling, auto-fix behavior, and report generation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| test('does not warn on nesting at exactly 10 levels', () => { | ||
| let data = { level: 'bottom' }; | ||
| for (let i = 0; i < 9; i++) { | ||
| data = { nested: data }; | ||
| } | ||
| const results = { valid: true, errors: [], warnings: [] }; | ||
|
|
||
| validator.validateGeneral(data, results); | ||
|
|
||
| const deepWarnings = results.warnings.filter(w => w.type === 'deep_nesting'); | ||
| expect(deepWarnings).toHaveLength(0); | ||
| }); |
There was a problem hiding this comment.
The test name says "does not warn on nesting at exactly 10 levels" but the loop for (let i = 0; i < 9; i++) only creates 9 levels of nesting, not 10. To test exactly 10 levels (which should not trigger a warning since the threshold is > 10), the loop should be for (let i = 0; i < 10; i++). Currently, this test is verifying that 9 levels doesn't warn, but it's not actually testing the boundary condition at exactly 10 levels.
| * validateFieldTypes(), getMaxDepth(), autoFix(), fixIndentation(), | ||
| * fixQuotes(), generateReport(), and validateYAML(). |
There was a problem hiding this comment.
The header comment lists covered functions but is missing validateFieldStructure() (tested in lines 334-370) and validateGeneral() (tested in lines 466-503). The "Covers:" section should include these two functions to accurately reflect the complete test coverage.
| * validateFieldTypes(), getMaxDepth(), autoFix(), fixIndentation(), | |
| * fixQuotes(), generateReport(), and validateYAML(). | |
| * validateFieldTypes(), validateFieldStructure(), getMaxDepth(), | |
| * autoFix(), fixIndentation(), fixQuotes(), generateReport(), | |
| * validateGeneral(), and validateYAML(). |
Add comprehensive tests for the YAMLValidator class and validateYAML function covering validation, auto-fix, report generation, and all YAML type rules (agent, manifest, workflow). Refs SynkraAI#52
db63d9f to
36f6d7b
Compare
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Consolidated into #424 |
Summary
YAMLValidatorclass andvalidateYAMLfunctionvalidate()— valid/invalid YAML, agent/manifest/workflow type rulesvalidateFile()— file reading and error handlingvalidateStructure()— required fields, unknown fields, optional fieldsvalidateFieldTypes()— null values, empty names, icon validationvalidateGeneral()— circular references, deep nesting warningsgetMaxDepth()— depth calculation for nested structuresautoFix()— indentation and quote fixinggenerateReport()— human-readable report generationvalidateYAML()— convenience functionTest plan
npx jest tests/core/utils/yaml-validator.test.js)Closes #198
Refs #52