// tools/create-spec-hu/advanced-testing-hu-adapter.ts — SPEC-049
// Adds advanced testing criteria to HU.md based on target and project knowledge.
import { isWebProject, buildA11yCriteria, } from '../../engine/advanced-testing/accessibility-checker.js';
import { buildTestDataCriteria } from '../../engine/advanced-testing/test-data-advisor.js';
/** Targets where advanced testing patterns are relevant. */
const ADVANCED_TESTING_TARGETS = new Set(['backend', 'frontend', 'fullstack', 'shared']);
/**
 * Build the advanced testing criteria section for HU.md.
 * Emits property-based, mutation, accessibility, and test data criteria
 * based on target and detected project knowledge.
 */
export function buildAdvancedTestingHuSection(target, knowledge) {
    if (!ADVANCED_TESTING_TARGETS.has(target)) {
        return [];
    }
    const lines = ['', '## Advanced Testing Patterns', ''];
    const stack = knowledge?.stack ?? [];
    // S1 — Property-based testing invariant criteria (always relevant for domain modules)
    lines.push('### Property-Based Testing', '');
    lines.push('- [ ] Para cualquier combinación válida de inputs, la función retorna un resultado dentro del rango esperado (verificado con property-based testing)');
    lines.push('- [ ] La operación es idempotente: aplicarla N veces produce el mismo resultado que aplicarla 1 vez');
    lines.push('- [ ] La operación es commutativa cuando aplica: el orden de los operandos no afecta el resultado');
    lines.push('');
    // S2 — Mutation testing criteria for critical modules
    lines.push('### Mutation Testing', '');
    lines.push('- [ ] Los módulos críticos (payment, auth, data integrity) tienen mutation score ≥ 80% — los tests detectan al menos 80% de mutaciones simples (operadores lógicos, comparaciones, valores de retorno)');
    lines.push('');
    // S4 — Accessibility criteria (web projects only)
    if (isWebProject(stack) || target === 'frontend' || target === 'fullstack') {
        lines.push('### Accessibility (WCAG 2.1 Level AA)', '');
        const a11yCriteria = buildA11yCriteria();
        for (const criterion of a11yCriteria) {
            lines.push(criterion);
        }
        lines.push('');
    }
    // S5 — Test data criteria
    lines.push('### Test Data Management', '');
    const testDataCriteria = buildTestDataCriteria();
    for (const criterion of testDataCriteria) {
        lines.push(criterion);
    }
    lines.push('');
    return lines;
}
//# sourceMappingURL=advanced-testing-hu-adapter.js.map