Skip to content

Commit b6c7a86

Browse files
test(validator): cover fenced-only scenario headers in delta specs
Add a regression test asserting that a `#### Scenario:` appearing only inside a fenced code block does not count toward the required scenario count, so the validator still reports the missing-scenario error. This guards the fence awareness of `countScenarios()`: the existing fenced-example test always includes a real (unfenced) scenario, so it would not catch a regression that began counting fenced scenario headers. Addresses the review suggestion on PR #1151. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8c9ad35 commit b6c7a86

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

test/core/validation.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,39 @@ The system SHALL render a delta example in its output.
685685
expect(report.issues.some(i => i.message.includes('Example only'))).toBe(false);
686686
});
687687

688+
it('does not count scenario headers inside fenced code blocks toward the required scenario count', async () => {
689+
const changeDir = path.join(testDir, 'test-change-fenced-scenario-only');
690+
const specsDir = path.join(changeDir, 'specs', 'test-spec');
691+
await fs.mkdir(specsDir, { recursive: true });
692+
693+
const deltaSpec = `# Test Spec
694+
695+
## ADDED Requirements
696+
697+
### Requirement: Documentation Generator
698+
The system SHALL render a delta example in its output.
699+
700+
\`\`\`markdown
701+
#### Scenario: Example scenario
702+
\`\`\`
703+
`;
704+
705+
const specPath = path.join(specsDir, 'spec.md');
706+
await fs.writeFile(specPath, deltaSpec);
707+
708+
const validator = new Validator(true);
709+
const report = await validator.validateChangeDeltaSpecs(changeDir);
710+
711+
// The only "#### Scenario:" lives inside a fenced code block, so it must
712+
// not count toward the scenario requirement; the validator must still
713+
// flag the requirement as missing a scenario.
714+
expect(report.valid).toBe(false);
715+
expect(report.summary.errors).toBeGreaterThan(0);
716+
expect(
717+
report.issues.some(i => i.message.includes('must include at least one scenario'))
718+
).toBe(true);
719+
});
720+
688721
it('should treat delta headers case-insensitively', async () => {
689722
const changeDir = path.join(testDir, 'test-change-mixed-case');
690723
const specsDir = path.join(changeDir, 'specs', 'test-spec');

0 commit comments

Comments
 (0)