Skip to content
TypeScript

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

Julius Marmingeb3f8dd979af2
diff --git a/apps/server/src/orchestration/commandInvariants.test.ts b/apps/server/src/orchestration/commandInvariants.test.ts
index 9aaeba94342..93777c67d3e 100644
--- a/apps/server/src/orchestration/commandInvariants.test.ts
+++ b/apps/server/src/orchestration/commandInvariants.test.ts
@@ -11,12 +11,7 @@ import {
} from "@t3tools/contracts";
import * as Effect from "effect/Effect";
-import {
- findThreadById,
- listThreadsByProjectId,
- requireThread,
- requireThreadAbsent,
-} from "./commandInvariants.ts";
+import { listThreadsByProjectId, requireThread, requireThreadAbsent } from "./commandInvariants.ts";
const now = "2026-01-01T00:00:00.000Z";
@@ -121,9 +116,7 @@ const messageSendCommand: OrchestrationCommand = {
};
describe("commandInvariants", () => {
- it("finds threads by id and project", () => {
- expect(findThreadById(readModel, ThreadId.make("thread-1"))?.projectId).toBe("project-a");
- expect(findThreadById(readModel, ThreadId.make("missing"))).toBeUndefined();
+ it("lists threads by project", () => {
expect(
listThreadsByProjectId(readModel, ProjectId.make("project-b")).map((thread) => thread.id),
).toEqual([ThreadId.make("thread-2")]);
diff --git a/apps/server/src/orchestration/commandInvariants.ts b/apps/server/src/orchestration/commandInvariants.ts
index beaad93d5ee..110a499d37c 100644
--- a/apps/server/src/orchestration/commandInvariants.ts
+++ b/apps/server/src/orchestration/commandInvariants.ts
@@ -18,7 +18,7 @@ function invariantError(commandType: string, detail: string): OrchestrationComma
});
}
-export function findThreadById(
+function findThreadById(
readModel: OrchestrationReadModel,
threadId: ThreadId,
): OrchestrationThread | undefined {