import { describe, it, expect } from "vitest"; import { mount } from "@vue/test-utils"; import BcCard from "../BcCard.vue"; import type { BcNode } from "@/lib/bc-graph"; const bc: BcNode = { name: "orders", rows: [ { id: "action:orders.place", kind: "action", name: "orders.place", public: true }, { id: "event:orders.placed", kind: "event", name: "orders.placed" }, { id: "query:orders.list", kind: "query", name: "orders.list" }, ], }; describe("BcCard", () => { it("shows the app name and member count", () => { const w = mount(BcCard, { props: { bc } }); expect(w.get('[data-testid="bc-card-name"]').text()).toBe("orders"); expect(w.text()).toContain("3"); }); it("renders per-kind count chips", () => { const w = mount(BcCard, { props: { bc } }); expect(w.text()).toContain("1 action"); expect(w.text()).toContain("1 event"); expect(w.text()).toContain("1 query"); }); it("strips the app prefix from row names", () => { const w = mount(BcCard, { props: { bc } }); const row = w.get('[data-testid="bc-row-action:orders.place"]'); expect(row.text()).toContain("place"); expect(row.text()).not.toContain("orders.place"); }); it("marks public rows and emits select with the row on click", async () => { const w = mount(BcCard, { props: { bc } }); const row = w.get('[data-testid="bc-row-action:orders.place"]'); expect(row.find('[data-testid="bc-row-public"]').exists()).toBe(true); await row.trigger("click"); expect(w.emitted("select")?.[0]?.[0]).toMatchObject({ id: "action:orders.place" }); }); it("highlights the selected row", () => { const w = mount(BcCard, { props: { bc, selectedId: "event:orders.placed" } }); expect(w.get('[data-testid="bc-row-event:orders.placed"]').classes()).toContain("bg-zinc-900"); }); it("shows an empty hint when the BC has no primitives", () => { const w = mount(BcCard, { props: { bc: { name: "empty", rows: [] } } }); expect(w.text()).toContain("No primitives yet"); }); });