// Task 168 — per-tool emit assertion for conversation-archive-enrich-rejection.
//
// Existing memory MCP test (conversation-archive-enrich-rejection.test.ts)
// runs the impl against a scratch directory; this companion file isolates
// the emit-wrapper contract. We mock the underlying derive-insights module's
// path constants + key helper so the impl runs without needing PLATFORM_ROOT.
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { mkdtempSync, rmSync } from "node:fs";
import { resolve } from "node:path";
import { tmpdir } from "node:os";
import { setupEmitCapture } from "./_helpers/emit-capture.js";
import { conversationArchiveEnrichRejection } from "../conversation-archive-enrich-rejection.js";
describe("conversation-archive-enrich-rejection — emit wrapper wired", () => {
    let emit;
    let scratch;
    let origRoot;
    beforeEach(() => {
        emit = setupEmitCapture();
        scratch = mkdtempSync(resolve(tmpdir(), "task-168-"));
        origRoot = process.env.PLATFORM_ROOT;
        process.env.PLATFORM_ROOT = resolve(scratch, "platform");
    });
    afterEach(() => {
        emit.restore();
        if (origRoot === undefined)
            delete process.env.PLATFORM_ROOT;
        else
            process.env.PLATFORM_ROOT = origRoot;
        rmSync(scratch, { recursive: true, force: true });
    });
    it("emits result=ok line on happy path (record mode)", async () => {
        await conversationArchiveEnrichRejection({
            accountId: "acct-1",
            archiveElementId: "4:archive:1",
            chunkElementId: "4:chunk:1",
            kind: "mention",
            contentHash: "abcd",
            mode: "record",
        });
        expect(emit.fetchSpy).toHaveBeenCalledTimes(1);
        const body = emit.captures()[0];
        expect(body.tag).toBe("mcp:memory");
        expect(body.level).toBe("info");
        expect(body.line).toContain("conversation-archive-enrich-rejection");
        expect(body.line).toContain("result=ok");
    });
});
//# sourceMappingURL=conversation-archive-enrich-rejection-emit.test.js.map