Skip to content

test(core): add yaml-validator unit test coverage#193

Closed
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:test/yaml-validator-coverage
Closed

test(core): add yaml-validator unit test coverage#193
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:test/yaml-validator-coverage

Conversation

@nikolasdehor
Copy link
Contributor

@nikolasdehor nikolasdehor commented Feb 18, 2026

Summary

  • Add 69 test cases for the YAMLValidator class and validateYAML function
  • Tests cover all 12 public methods across the validation lifecycle:
    • Constructor initialization and rule configuration
    • validate() — valid/invalid YAML, agent/manifest/workflow type rules
    • validateFile() — file reading and error handling
    • validateStructure() — required fields, unknown fields, optional fields
    • validateFieldTypes() — null values, empty names, icon validation
    • validateGeneral() — circular references, deep nesting warnings
    • getMaxDepth() — depth calculation for nested structures
    • autoFix() — indentation and quote fixing
    • generateReport() — human-readable report generation
    • validateYAML() — convenience function

Test plan

  • All 69 tests pass locally (npx jest tests/core/utils/yaml-validator.test.js)
  • Uses temp directories for file-based tests
  • Follows existing Jest test patterns
  • CI pipeline validation

Closes #198
Refs #52

Copilot AI review requested due to automatic review settings February 18, 2026 15:58
@vercel
Copy link

vercel bot commented Feb 18, 2026

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

@nikolasdehor
Copy link
Contributor Author

@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 YAMLValidator class and the validateYAML convenience function.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 YAMLValidator class
  • 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.

Comment on lines +491 to +502
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);
});
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
* validateFieldTypes(), getMaxDepth(), autoFix(), fixIndentation(),
* fixQuotes(), generateReport(), and validateYAML().
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
* validateFieldTypes(), getMaxDepth(), autoFix(), fixIndentation(),
* fixQuotes(), generateReport(), and validateYAML().
* validateFieldTypes(), validateFieldStructure(), getMaxDepth(),
* autoFix(), fixIndentation(), fixQuotes(), generateReport(),
* validateGeneral(), and validateYAML().

Copilot uses AI. Check for mistakes.
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
@nikolasdehor nikolasdehor force-pushed the test/yaml-validator-coverage branch from db63d9f to 36f6d7b Compare February 18, 2026 18:55
@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@nikolasdehor has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nikolasdehor
Copy link
Contributor Author

Consolidated into #424

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: yaml-validator.js has zero test coverage

2 participants