import { describe, expect, test } from "bun:test"; import { parsePublicCommand } from "./widget-commands"; describe("parsePublicCommand", () => { test("preserves customer occurrence types on the track command", () => { for (const type of ["page", "screen"] as const) { expect( parsePublicCommand({ kind: "track", origin: "customer", type, event: "Settings Opened", properties: { source: "menu" }, }), ).toEqual({ kind: "track", origin: "customer", type, event: "Settings Opened", properties: { source: "menu" }, }); } }); test("accepts instance feedback command payloads", () => { expect( parsePublicCommand({ kind: "instanceFeedback.capture", payload: { category: "helpfulness", target: { collection: "docs-page", id: "page_1" }, value: false, }, }), ).toEqual({ kind: "instanceFeedback.capture", payload: { category: "helpfulness", target: { collection: "docs-page", id: "page_1" }, value: false, }, }); expect( parsePublicCommand({ kind: "instanceFeedback.listMine", payload: { selectors: [ { category: "answer-quality", target: { collection: "ai-answer", id: "answer_1" }, }, ], }, }), ).toEqual({ kind: "instanceFeedback.listMine", payload: { selectors: [ { category: "answer-quality", target: { collection: "ai-answer", id: "answer_1" }, }, ], }, }); }); });