/**
 * Integration Test: Bundle → Run Workflow
 *
 * Tests complete flow from config to running bundle.
 * Uses real packages, real bundles, NO MOCKING.
 */
import { bundle } from '../../commands/bundle/index.js';
import { join } from 'path';
import fs from 'fs-extra';
const projectRoot = process.cwd();
describe('Bundle → Run Integration', () => {
    const testDir = join(projectRoot, '.tmp/integration-tests');
    beforeAll(async () => {
        await fs.ensureDir(testDir);
    });
    afterAll(async () => {
        await fs.remove(testDir).catch(() => { });
    });
    it('should create functional bundle from config', async () => {
        // Step 1: Bundle example config
        await bundle(join(projectRoot, 'examples/server-collect.json'), {
            verbose: false,
            silent: true,
        });
        // Step 2: Verify bundle exists
        const bundlePath = join(projectRoot, 'examples/server-collect.mjs');
        expect(fs.existsSync(bundlePath)).toBe(true);
        // Step 3: Verify it's valid ESM
        const module = await import(bundlePath);
        expect(module.default).toBeDefined();
        expect(typeof module.default).toBe('function');
        // Step 4: Verify factory function signature
        // (Don't actually execute to avoid port conflicts and hanging servers)
        const factoryFn = module.default;
        expect(factoryFn.length).toBeGreaterThanOrEqual(0);
        // Verify it's a function that would return the right structure
        // by checking the module exports
        expect(module).toHaveProperty('default');
    }, 60000);
    it('should bundle with correct dependencies included', async () => {
        const bundlePath = join(projectRoot, 'examples/server-collect.mjs');
        const content = fs.readFileSync(bundlePath, 'utf-8');
        // Should include runtime dependencies
        expect(content).toContain('express');
        // Should NOT include dev dependencies
        expect(content).not.toContain('jest');
        expect(content).not.toContain('@types/');
    });
});
//# sourceMappingURL=bundle-run.integration.test.js.map