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
11} from "@t3tools/contracts";11} from "@t3tools/contracts";
12import * as Effect from "effect/Effect";12import * as Effect from "effect/Effect";
13 13
14import {14import { listThreadsByProjectId, requireThread, requireThreadAbsent } from "./commandInvariants.ts";
15 findThreadById,
16 listThreadsByProjectId,
17 requireThread,
18 requireThreadAbsent,
19} from "./commandInvariants.ts";
20 15
21const now = "2026-01-01T00:00:00.000Z";16const now = "2026-01-01T00:00:00.000Z";
22 17
@@ -121,9 +116,7 @@ const messageSendCommand: OrchestrationCommand = { · 98 unmodified lines
121};116};
122 117
123describe("commandInvariants", () => {118describe("commandInvariants", () => {
124 it("finds threads by id and project", () => {119 it("lists threads by project", () => {
125 expect(findThreadById(readModel, ThreadId.make("thread-1"))?.projectId).toBe("project-a");
126 expect(findThreadById(readModel, ThreadId.make("missing"))).toBeUndefined();
127 expect(120 expect(
128 listThreadsByProjectId(readModel, ProjectId.make("project-b")).map((thread) => thread.id),121 listThreadsByProjectId(readModel, ProjectId.make("project-b")).map((thread) => thread.id),
129 ).toEqual([ThreadId.make("thread-2")]);122 ).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
18 });18 });
19}19}
20 20
21export function findThreadById(21function findThreadById(
22 readModel: OrchestrationReadModel,22 readModel: OrchestrationReadModel,
23 threadId: ThreadId,23 threadId: ThreadId,
24): OrchestrationThread | undefined {24): OrchestrationThread | undefined {