/**
 * RED-GREEN tests for F-NEW-PRODUCT-SANDBOX-REPLAY (W4.2).
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-SANDBOX-REPLAY
 */
import { describe, it } from 'node:test';
import * as assert from 'node:assert/strict';
import { REPLAY_SEQUENCES, listReplaySequences, getReplaySequence, } from './sandbox-replay.js';
describe('F-NEW-PRODUCT-SANDBOX-REPLAY (W4.2)', () => {
    it('ships at least 8 replay sequences', () => {
        assert.ok(REPLAY_SEQUENCES.length >= 8);
    });
    it('every sequence has a unique id', () => {
        const ids = new Set(REPLAY_SEQUENCES.map((s) => s.id));
        assert.equal(ids.size, REPLAY_SEQUENCES.length);
    });
    it('every sequence has at least 3 events', () => {
        for (const seq of REPLAY_SEQUENCES) {
            assert.ok(seq.events.length >= 3, `${seq.id} has < 3 events`);
        }
    });
    it('events are time-ordered (non-decreasing tMs)', () => {
        for (const seq of REPLAY_SEQUENCES) {
            for (let i = 1; i < seq.events.length; i++) {
                assert.ok(seq.events[i].tMs >= seq.events[i - 1].tMs, `${seq.id} event ${i} tMs=${seq.events[i].tMs} < prev ${seq.events[i - 1].tMs}`);
            }
        }
    });
    it('last event tMs <= sequence durationMs', () => {
        for (const seq of REPLAY_SEQUENCES) {
            const lastT = seq.events[seq.events.length - 1].tMs;
            assert.ok(lastT <= seq.durationMs, `${seq.id} last event ${lastT} > duration ${seq.durationMs}`);
        }
    });
    it('every sequence starts with TOOL_CALL_REQUESTED', () => {
        for (const seq of REPLAY_SEQUENCES) {
            assert.equal(seq.events[0].kind, 'TOOL_CALL_REQUESTED', `${seq.id} should start with TOOL_CALL_REQUESTED`);
        }
    });
    it('outcome ACTION_BLOCKED sequences carry a VERDICT_DENY event', () => {
        for (const seq of REPLAY_SEQUENCES) {
            if (seq.outcome !== 'ACTION_BLOCKED')
                continue;
            const deny = seq.events.find((e) => e.kind === 'VERDICT_DENY');
            assert.ok(deny, `${seq.id} (ACTION_BLOCKED) is missing VERDICT_DENY`);
        }
    });
    it('outcome APPROVAL_REQUIRED sequences carry a VERDICT_PENDING_APPROVAL event', () => {
        for (const seq of REPLAY_SEQUENCES) {
            if (seq.outcome !== 'APPROVAL_REQUIRED')
                continue;
            const pending = seq.events.find((e) => e.kind === 'VERDICT_PENDING_APPROVAL');
            assert.ok(pending, `${seq.id} (APPROVAL_REQUIRED) is missing VERDICT_PENDING_APPROVAL`);
        }
    });
    it('outcome INCIDENT_FILED sequences carry a CRITICAL AUDIT_RECORDED', () => {
        for (const seq of REPLAY_SEQUENCES) {
            if (seq.outcome !== 'INCIDENT_FILED')
                continue;
            const incident = seq.events.find((e) => e.kind === 'AUDIT_RECORDED' && e.severity === 'CRITICAL');
            assert.ok(incident, `${seq.id} (INCIDENT_FILED) is missing a CRITICAL AUDIT_RECORDED`);
        }
    });
    it('listReplaySequences filters by vertical', () => {
        const hc = listReplaySequences({ vertical: 'healthcare' });
        assert.ok(hc.length >= 1);
        assert.ok(hc.every((s) => s.vertical === 'healthcare'));
    });
    it('getReplaySequence finds by id', () => {
        const first = REPLAY_SEQUENCES[0];
        const found = getReplaySequence(first.id);
        assert.equal(found?.id, first.id);
        assert.equal(getReplaySequence('does-not-exist'), undefined);
    });
    it('covers at least 5 distinct outcomes / verticals between them', () => {
        const verticals = new Set(REPLAY_SEQUENCES.map((s) => s.vertical));
        const outcomes = new Set(REPLAY_SEQUENCES.map((s) => s.outcome));
        assert.ok(verticals.size >= 5);
        assert.ok(outcomes.size >= 3);
    });
});
//# sourceMappingURL=sandbox-replay.test.js.map