import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdtempSync, rmSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import { Repository } from './repository.js';

let tempDir = '';
function makeRepo(): Repository {
  return new Repository(join(tempDir, 'orchestrator.db'));
}

beforeEach(() => { tempDir = mkdtempSync(join(tmpdir(), 'maestro-tconly-')); });
afterEach(() => { rmSync(tempDir, { recursive: true, force: true }); });

describe('makeTranscriptOnlyConversationIO', () => {
  it('yields empty comments and passes the transcript path through', async () => {
    const repo = makeRepo();
    const io = repo.makeTranscriptOnlyConversationIO('/tmp/does-not-matter/transcript.jsonl');
    expect(await io.listComments()).toEqual([]);
    expect(io.transcriptPath).toBe('/tmp/does-not-matter/transcript.jsonl');
  });

  it('accepts an undefined transcript path (comments still empty)', async () => {
    const repo = makeRepo();
    const io = repo.makeTranscriptOnlyConversationIO(undefined);
    expect(await io.listComments()).toEqual([]);
    expect(io.transcriptPath).toBeUndefined();
  });
});
