397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.8 KiB
JavaScript
41 lines
1.8 KiB
JavaScript
// tools/brain-retro-sanity-generator.test.mjs — Phase 3 Task 19 (spec §4.7)
|
|
import { describe, it, expect } from 'vitest';
|
|
import { generateCandidateQuestions } from './brain-retro-sanity-generator.mjs';
|
|
|
|
describe('generateCandidateQuestions — sanity-check candidates (spec §4.7)', () => {
|
|
it('emits a bugfix-themed question when bugfix volume > 10', () => {
|
|
const eps = Array(11).fill({ classifier_output: { task_type: 'bugfix' } });
|
|
const qs = generateCandidateQuestions(eps);
|
|
expect(qs.some((q) => /баг|debug/i.test(q))).toBe(true);
|
|
});
|
|
|
|
it('emits a feature-themed question when feature volume > 10', () => {
|
|
const eps = Array(12).fill({ classifier_output: { task_type: 'feature' } });
|
|
const qs = generateCandidateQuestions(eps);
|
|
expect(qs.some((q) => /фич|feature/i.test(q))).toBe(true);
|
|
});
|
|
|
|
it('never returns more than 5 candidate questions', () => {
|
|
const eps = Array(50).fill({ classifier_output: { task_type: 'bugfix' } });
|
|
expect(generateCandidateQuestions(eps).length).toBeLessThanOrEqual(5);
|
|
});
|
|
|
|
it('returns at most 5 even on empty input (defensive default)', () => {
|
|
expect(generateCandidateQuestions([]).length).toBeLessThanOrEqual(5);
|
|
});
|
|
|
|
it('handles legacy v2/v3 episodes (primary_rationale.task_classification fallback)', () => {
|
|
const eps = Array(11).fill({ schema_version: 3, primary_rationale: { task_classification: 'bugfix' } });
|
|
const qs = generateCandidateQuestions(eps);
|
|
expect(qs.some((q) => /баг|debug/i.test(q))).toBe(true);
|
|
});
|
|
|
|
it('always returns strings', () => {
|
|
const eps = Array(5).fill({ classifier_output: { task_type: 'feature' } });
|
|
for (const q of generateCandidateQuestions(eps)) {
|
|
expect(typeof q).toBe('string');
|
|
expect(q.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
});
|