"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const globals_1 = require("@jest/globals");
const github_actions_generator_1 = require("./github-actions-generator");
(0, globals_1.describe)('GitHubActionsGenerator', () => {
    const generator = new github_actions_generator_1.GitHubActionsGenerator();
    const mockWorkflow = {
        workflow: {
            id: 'test-workflow',
            name: 'Test Workflow',
        },
        stack: {
            'web-app': {
                type: 'frontend',
                technology: 'react',
            },
            'api': {
                type: 'backend',
                technology: 'typescript/express',
            },
            'database': {
                type: 'database',
                technology: 'postgresql',
            },
        },
        testing: {
            unit_tests: [
                { component: 'web-app.login-form', scenarios: ['test1'] },
                { component: 'api.login-endpoint', scenarios: ['test2'] },
            ],
            integration_tests: [
                { name: 'complete-flow', steps: [] },
            ],
            e2e_tests: [
                { name: 'user-can-login', steps: [] },
            ],
        },
        deployment: {
            'web-app': {
                build_command: 'npm run build',
                output_directory: 'dist',
            },
            'api': {
                build_command: 'npm run build',
                start_command: 'npm start',
            },
        },
    };
    const mockContext = {
        workflow: mockWorkflow,
        executionPlan: {},
        outputDirectory: '/test/output',
    };
    (0, globals_1.it)('should have correct metadata', () => {
        (0, globals_1.expect)(generator.id).toBe('github-actions-cicd');
        (0, globals_1.expect)(generator.name).toBe('GitHub Actions CI/CD Generator');
        (0, globals_1.expect)(generator.description).toBe('Generates GitHub Actions workflows for CI/CD');
    });
    (0, globals_1.it)('should generate test workflow', () => {
        const result = generator.generate(mockContext);
        (0, globals_1.expect)(result.files.length).toBeGreaterThan(0);
        const testWorkflow = result.files.find(f => f.path.includes('test.yml'));
        (0, globals_1.expect)(testWorkflow).toBeDefined();
        (0, globals_1.expect)(testWorkflow?.content).toContain('name: Test');
        (0, globals_1.expect)(testWorkflow?.content).toContain('test-frontend');
        (0, globals_1.expect)(testWorkflow?.content).toContain('test-backend');
        (0, globals_1.expect)(testWorkflow?.content).toContain('test-e2e');
    });
    (0, globals_1.it)('should generate build workflow', () => {
        const result = generator.generate(mockContext);
        const buildWorkflow = result.files.find(f => f.path.includes('build.yml'));
        (0, globals_1.expect)(buildWorkflow).toBeDefined();
        (0, globals_1.expect)(buildWorkflow?.content).toContain('name: Build');
        (0, globals_1.expect)(buildWorkflow?.content).toContain('build-frontend');
        (0, globals_1.expect)(buildWorkflow?.content).toContain('build-backend');
    });
    (0, globals_1.it)('should generate deploy workflow', () => {
        const result = generator.generate(mockContext);
        const deployWorkflow = result.files.find(f => f.path.includes('deploy.yml'));
        (0, globals_1.expect)(deployWorkflow).toBeDefined();
        (0, globals_1.expect)(deployWorkflow?.content).toContain('name: Deploy');
    });
    (0, globals_1.it)('should include database services in workflows', () => {
        const result = generator.generate(mockContext);
        const testWorkflow = result.files.find(f => f.path.includes('test.yml'));
        (0, globals_1.expect)(testWorkflow?.content).toContain('postgres:');
        (0, globals_1.expect)(testWorkflow?.content).toContain('image: postgres:15-alpine');
    });
    (0, globals_1.it)('should not generate workflows when testing is not configured', () => {
        const contextWithoutTesting = {
            ...mockContext,
            workflow: {
                ...mockWorkflow,
                testing: undefined,
            },
        };
        const result = generator.generate(contextWithoutTesting);
        const testWorkflow = result.files.find(f => f.path.includes('test.yml'));
        (0, globals_1.expect)(testWorkflow).toBeUndefined();
    });
});
//# sourceMappingURL=github-actions-generator.test.js.map