Context
Depends on #37 (shared libs) and #38 (script extraction).
Current tests (3 .py + 2 .sh files) are keyword-grep checks against inline YAML — they validate almost nothing. With scripts extracted into standalone JS modules, we can write real unit tests.
Task
Language: Node.js (using built-in node:test runner, Node 18+)
1. YAML structure validation (tests/validate-workflows.js)
- Parse each
.yml with js-yaml
- Validate: name, triggers, permissions, job structure, job dependencies
- Replaces all existing structural tests
2. Unit tests for lib modules (tests/lib/*.test.js)
Test pure logic with real inputs — no GitHub API mocking:
| Test file |
What's tested |
config.test.js |
YAML section parsing with various inputs |
file-patterns.test.js |
Test/code/dependency file detection edge cases |
commit-validator.test.js |
Conventional commit format validation |
scope-matcher.test.js |
File path extraction from markdown + scope matching |
api-patterns.test.js |
Language-specific API surface regex patterns |
patch-parser.test.js |
Unified diff line number tracking |
severity.test.js |
Review comment severity keyword detection |
approval.test.js |
Non-stale approval logic |
fixes-parser.test.js |
Fixes #N extraction from PR bodies |
pr-body.test.js |
Idempotent section replacement |
3. Delete old tests
tests/test_guardrail_test_ratio.py
tests/test_human_review_workflow.py
tests/test_pr_review_workflow.py
tests/test-guardrail-commits.sh
tests/test-guardrail-scope.sh
Files
tests/validate-workflows.js (new)
tests/lib/*.test.js (10 new files)
tests/*.py, tests/*.sh (5 deleted)
Context
Depends on #37 (shared libs) and #38 (script extraction).
Current tests (3
.py+ 2.shfiles) are keyword-grep checks against inline YAML — they validate almost nothing. With scripts extracted into standalone JS modules, we can write real unit tests.Task
Language: Node.js (using built-in
node:testrunner, Node 18+)1. YAML structure validation (
tests/validate-workflows.js).ymlwithjs-yaml2. Unit tests for lib modules (
tests/lib/*.test.js)Test pure logic with real inputs — no GitHub API mocking:
config.test.jsfile-patterns.test.jscommit-validator.test.jsscope-matcher.test.jsapi-patterns.test.jspatch-parser.test.jsseverity.test.jsapproval.test.jsfixes-parser.test.jsFixes #Nextraction from PR bodiespr-body.test.js3. Delete old tests
tests/test_guardrail_test_ratio.pytests/test_human_review_workflow.pytests/test_pr_review_workflow.pytests/test-guardrail-commits.shtests/test-guardrail-scope.shFiles
tests/validate-workflows.js(new)tests/lib/*.test.js(10 new files)tests/*.py,tests/*.sh(5 deleted)