Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import type { Prisma } from "./client.js";
|
|
import { createThreadMessageInTransaction } from "./messages.js";
|
|
|
|
function transaction() {
|
|
return {
|
|
thread: { update: vi.fn().mockResolvedValue({ nextMessageSeq: 1 }) },
|
|
run: { findUnique: vi.fn().mockResolvedValue({ status: "running" }) },
|
|
message: { create: vi.fn().mockResolvedValue({ id: "message-1" }) },
|
|
};
|
|
}
|
|
|
|
describe("createThreadMessageInTransaction", () => {
|
|
it("allows an automated bot message to opt out of unread without changing the default", async () => {
|
|
const silent = transaction();
|
|
await createThreadMessageInTransaction(silent as unknown as Prisma.TransactionClient, {
|
|
threadId: "thread-1",
|
|
role: "bot",
|
|
blocks: [{ kind: "steps", steps: [{ label: "Checked status", count: 1 }] }],
|
|
markUnread: false,
|
|
});
|
|
expect(silent.thread.update).toHaveBeenCalledWith(
|
|
expect.objectContaining({ data: expect.objectContaining({ unread: undefined }) }),
|
|
);
|
|
|
|
const visible = transaction();
|
|
await createThreadMessageInTransaction(visible as unknown as Prisma.TransactionClient, {
|
|
threadId: "thread-1",
|
|
role: "bot",
|
|
blocks: [{ kind: "text", text: "Daily report ready" }],
|
|
});
|
|
expect(visible.thread.update).toHaveBeenCalledWith(
|
|
expect.objectContaining({ data: expect.objectContaining({ unread: true }) }),
|
|
);
|
|
});
|
|
});
|