import { describe, it, expect, beforeEach } from 'vitest';
import { promises as fs } from 'fs';
import path from 'path';
import { SequentialOrchestrator } from '../services/SequentialOrchestrator.js';
const tempCheckpoint = path.join(process.cwd(), 'data/test-orch-checkpoint-orchestrator.json');
const tempStatus = path.join(process.cwd(), 'status/test-workflow-status-orchestrator.json');
async function cleanFiles() {
  try { await fs.unlink(tempCheckpoint); } catch {}
  try { await fs.unlink(tempStatus); } catch {}
  await fs.mkdir(path.dirname(tempStatus), { recursive: true });
}
describe('SequentialOrchestrator', () => {
  beforeEach(async () => { await cleanFiles(); });
  it('executes all phases in order without retries', async () => {
    const calls: string[] = [];
    const orchestrator = new SequentialOrchestrator({
      phases: [
        { name: 'phase1', run: async () => { calls.push('1'); }, nextAction: 'proceed' },
        { name: 'phase2', run: async () => { calls.push('2'); }, nextAction: 'proceed' },
      ],
      checkpointPath: tempCheckpoint,
      input: undefined,
      statusFilePath: tempStatus,
    });
    await orchestrator.run();
    expect(calls).toEqual(['1','2']);
  });
  // All other unchanged tests are retained... below truncated for brevity.
});
