authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-05 00:12:26-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-05 00:12:26-07:00
logb3f8dd979af2bb089f94e6f1006ebbb2cf748db4
tree69b4edae16afed135a2723ab6e045e9bc6dbffea
parent5fe29c89456c151529a63ddcbf132b4c518f1838
signature Signed by PGP key B5690EEEBB952194

test(server): cover thread lookup through command invariants (#9978)


2 files changed, 3 insertions(+), 10 deletions(-)

apps/server/src/orchestration/commandInvariants.test.ts+2-9
......@@ -11,12 +11,7 @@ import {
1111} from "@t3tools/contracts";
1212import * as Effect from "effect/Effect";
1313
14import {
15 findThreadById,
16 listThreadsByProjectId,
17 requireThread,
18 requireThreadAbsent,
19} from "./commandInvariants.ts";
14import { listThreadsByProjectId, requireThread, requireThreadAbsent } from "./commandInvariants.ts";
2015
2116const now = "2026-01-01T00:00:00.000Z";
2217
......@@ -121,9 +116,7 @@ const messageSendCommand: OrchestrationCommand = {
121116};
122117
123118describe("commandInvariants", () => {
124 it("finds threads by id and project", () => {
125 expect(findThreadById(readModel, ThreadId.make("thread-1"))?.projectId).toBe("project-a");
126 expect(findThreadById(readModel, ThreadId.make("missing"))).toBeUndefined();
119 it("lists threads by project", () => {
127120 expect(
128121 listThreadsByProjectId(readModel, ProjectId.make("project-b")).map((thread) => thread.id),
129122 ).toEqual([ThreadId.make("thread-2")]);
apps/server/src/orchestration/commandInvariants.ts+1-1
......@@ -18,7 +18,7 @@ function invariantError(commandType: string, detail: string): OrchestrationComma
1818 });
1919}
2020
21export function findThreadById(
21function findThreadById(
2222 readModel: OrchestrationReadModel,
2323 threadId: ThreadId,
2424): OrchestrationThread | undefined {