import { describe, it, expect } from 'vitest';
import { sealOnWiredGo } from './enforce-judge-gate.mjs';

const planEvent = { tool_input: { file_path: 'docs/superpowers/plans/x.md', content: 'c' } };

describe('sealOnWiredGo owner-seal', () => {
  it('NO-GO + ownerSealOpen → печать плана, mentorGate пропущен', () => {
    let mentorCalled = false; let sealCalled = false;
    const deps = {
      key: 'k',
      sealPlan: () => { sealCalled = true; return { sealed: true, seal: {} }; },
      persistPlan: () => {},
      loadCurrentArtifact: () => null,
      mentorGate: () => { mentorCalled = true; return { pass: false }; },
    };
    const r = sealOnWiredGo({ event: planEvent, verdict: { wired: true, decision: 'NO-GO' }, judgeMode: 'live-block', ownerSealOpen: true, deps });
    expect(r.sealed).toBe(true);
    expect(mentorCalled).toBe(false);
    expect(sealCalled).toBe(true);
  });
  it('NO-GO без ownerSeal → не печатает', () => {
    const r = sealOnWiredGo({ event: planEvent, verdict: { wired: true, decision: 'NO-GO' }, ownerSealOpen: false, deps: { sealPlan: () => ({ sealed: true }) } });
    expect(r.sealed).toBe(false);
  });
});
