import { generateE2eTests, getE2eTestStatus } from '../engine/e2e-test-generator.js';
/**
 * Handle generate_e2e_tests tool call.
 * Generates E2E tests in the chosen framework from spec acceptance criteria.
 */
export async function handleGenerateE2eTests(input) {
    const { specId, projectPath, framework = 'gherkin', outputPath } = input;
    const result = await generateE2eTests(specId, projectPath, framework, outputPath);
    if ('isError' in result) {
        return {
            content: [{ type: 'text', text: `Error: ${result.message}` }],
            isError: true,
        };
    }
    const lines = [
        `E2E Tests Generated — ${result.specId}`,
        '='.repeat(50),
        `Framework: ${result.framework}`,
        `Test count: ${result.testCount}`,
        `Output: ${result.outputPath ?? '(not written to disk)'}`,
        ``,
        `--- Generated Content ---`,
        result.content,
        `--- End ---`,
    ];
    return { content: [{ type: 'text', text: lines.join('\n') }] };
}
/**
 * Handle e2e_test_status tool call.
 * Lists E2E test files matching SPEC-XXX pattern in tests/e2e/.
 */
export async function handleE2eTestStatus(input) {
    const result = await getE2eTestStatus(input.projectPath);
    if (result.total === 0) {
        return {
            content: [
                {
                    type: 'text',
                    text: `No E2E test files found in ${input.projectPath}/tests/e2e/\nRun generate_e2e_tests to create tests from your specs.`,
                },
            ],
        };
    }
    const lines = [
        `E2E Test Status`,
        `===============`,
        `Total files: ${result.total}`,
        ``,
        `Files:`,
        ...result.testFiles.map((f) => `  [${f.specId}] ${f.file} (${f.framework})`),
    ];
    return { content: [{ type: 'text', text: lines.join('\n') }] };
}
//# sourceMappingURL=e2e-test-generator-handler.js.map