import { describe, expect, it } from 'vitest';
import { loadPiece } from './piece-runner.js';

describe('sns-deep-sweep piece', () => {
  it('loads without throwing and lints clean', () => {
    expect(() => loadPiece('sns-deep-sweep')).not.toThrow();
  });

  it('is a single orchestrate movement with empty rules and COMPLETE default_next', () => {
    const piece = loadPiece('sns-deep-sweep');
    expect(piece.name).toBe('sns-deep-sweep');
    expect(piece.initial_movement).toBe('orchestrate');
    expect(piece.movements).toHaveLength(1);

    const mv = piece.movements[0]!;
    expect(mv.name).toBe('orchestrate');
    expect(mv.rules).toEqual([]);
    expect(mv.default_next).toBe('COMPLETE');
  });

  it('instruction guides one-delegate-per-tweet and the deepdive/report file layout', () => {
    const piece = loadPiece('sns-deep-sweep');
    const instr = piece.movements[0]!.instruction;
    expect(instr).toContain('output/deepdive/');
    expect(instr).toContain('output/report.md');
    expect(instr).toContain('output/triage.md');
    // The sub must be told not to delegate further (leaf guard via prompt).
    expect(instr).toContain('delegate は呼ぶな');
  });
});
