History

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

Julius Marminge committed 2 months ago

Commit b3f8dd91 parent 5fe29c82 files · +3 −10Browse files

Unified · Split

2 files
  1. apps/server/src/orchestration/commandInvariants.test.ts +2 −9
  2. apps/server/src/orchestration/commandInvariants.ts +1 −1
apps/server/src/orchestration/commandInvariants.test.ts+2−9
@@ -11,12 +11,7 @@ import { · 10 unmodified lines
1111 } from "@t3tools/contracts";
1212 import * as Effect from "effect/Effect";
1313
14−import {
15− findThreadById,
16− listThreadsByProjectId,
17− requireThread,
18− requireThreadAbsent,
19−} from "./commandInvariants.ts";
14+import { listThreadsByProjectId, requireThread, requireThreadAbsent } from "./commandInvariants.ts";
2015
2116 const now = "2026-01-01T00:00:00.000Z";
2217
@@ -121,9 +116,7 @@ const messageSendCommand: OrchestrationCommand = { · 98 unmodified lines
121116 };
122117
123118 describe("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 · 17 unmodified lines
1818 });
1919 }
2020
21−export function findThreadById(
21+function findThreadById(
2222 readModel: OrchestrationReadModel,
2323 threadId: ThreadId,
2424 ): OrchestrationThread | undefined {