History

test(server): target the durable active queue run

Julius Marminge committed 2 months ago

Commit d8fefad1 parent e5153f51 file · +9 −5Browse files

Unified · Split

apps/server/src/orchestration-v2/runtimeLayer.test.ts+9−5
@@ -1720,13 +1720,14 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 1719 unmodified lines
17201720 worktreePath: `/tmp/${threadId}`,
17211721 });
17221722 }
1723+ const activeMessageId = MessageId.make("runtime-layer-queued-archived-target-active");
17231724 yield* orchestrator.dispatch({
17241725 type: "message.dispatch",
17251726 createdBy: "user",
17261727 creationSource: "web",
17271728 commandId: CommandId.make("runtime-layer-queued-archived-target-active"),
17281729 threadId: targetThreadId,
1729− messageId: MessageId.make("runtime-layer-queued-archived-target-active"),
1730+ messageId: activeMessageId,
17301731 text: "Keep the target active.",
17311732 attachments: [],
17321733 modelSelection,
@@ -1745,9 +1746,10 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 12 unmodified lines
17451746 modelSelection,
17461747 dispatchMode: { type: "queue_after_active" },
17471748 });
1748− const queuedRun = (yield* orchestrator.getThreadProjection(targetThreadId)).runs.find(
1749− (run) => run.userMessageId === queuedMessageId,
1750− );
1749+ const beforeMutation = yield* orchestrator.getThreadProjection(targetThreadId);
1750+ const activeRun = beforeMutation.runs.find((run) => run.userMessageId === activeMessageId);
1751+ const queuedRun = beforeMutation.runs.find((run) => run.userMessageId === queuedMessageId);
1752+ assert.isDefined(activeRun);
17511753 assert.isDefined(queuedRun);
17521754 yield* orchestrator.dispatch({
17531755 type: "thread.archive",
@@ -1771,17 +1773,19 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => { · 17 unmodified lines
17711773 })
17721774 .pipe(Effect.flip);
17731775 assert.equal(editError._tag, "OrchestratorDispatchError");
1776+ assert.match(String(editError.cause), /Caller thread .* is not an active thread/);
17741777 const promoteError = yield* orchestrator
17751778 .dispatch({
17761779 type: "queued-message.promote-to-steer",
17771780 commandId: CommandId.make("runtime-layer-queued-archived-caller-promote"),
17781781 threadId: targetThreadId,
17791782 queuedRunId: queuedRun.id,
1780− targetRunId: RunId.make("runtime-layer-queued-archived-target-active-run"),
1783+ targetRunId: activeRun.id,
17811784 policyCeiling,
17821785 })
17831786 .pipe(Effect.flip);
17841787 assert.equal(promoteError._tag, "OrchestratorDispatchError");
1788+ assert.match(String(promoteError.cause), /Caller thread .* is not an active thread/);
17851789
17861790 const projection = yield* orchestrator.getThreadProjection(targetThreadId);
17871791 assert.equal(