mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 08:40:44 +00:00
test: require task parent flow ids
This commit is contained in:
@@ -101,6 +101,16 @@ async function withTaskExecutorStateDir(run: (stateDir: string) => Promise<void>
|
||||
});
|
||||
}
|
||||
|
||||
function expectParentFlowId(task: { parentFlowId?: string }): string {
|
||||
expect(task.parentFlowId).toMatch(
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,
|
||||
);
|
||||
if (task.parentFlowId === undefined) {
|
||||
throw new Error("Expected task parent flow id");
|
||||
}
|
||||
return task.parentFlowId;
|
||||
}
|
||||
|
||||
function createRunningAcpChildTaskRun(
|
||||
overrides: Partial<Parameters<typeof createRunningTaskRun>[0]> = {},
|
||||
) {
|
||||
@@ -289,11 +299,9 @@ describe("task-executor", () => {
|
||||
deliveryStatus: "pending",
|
||||
});
|
||||
|
||||
expect(created.parentFlowId).toMatch(
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,
|
||||
);
|
||||
expect(getTaskFlowById(created.parentFlowId!)).toMatchObject({
|
||||
flowId: created.parentFlowId,
|
||||
const parentFlowId = expectParentFlowId(created);
|
||||
expect(getTaskFlowById(parentFlowId)).toMatchObject({
|
||||
flowId: parentFlowId,
|
||||
ownerKey: "agent:main:main",
|
||||
status: "running",
|
||||
goal: "Write summary",
|
||||
@@ -307,8 +315,8 @@ describe("task-executor", () => {
|
||||
terminalSummary: "Done.",
|
||||
});
|
||||
|
||||
expect(getTaskFlowById(created.parentFlowId!)).toMatchObject({
|
||||
flowId: created.parentFlowId,
|
||||
expect(getTaskFlowById(parentFlowId)).toMatchObject({
|
||||
flowId: parentFlowId,
|
||||
status: "succeeded",
|
||||
endedAt: 40,
|
||||
goal: "Write summary",
|
||||
@@ -366,8 +374,9 @@ describe("task-executor", () => {
|
||||
terminalOutcome: "blocked",
|
||||
terminalSummary: "Writable session required.",
|
||||
});
|
||||
expect(getTaskFlowById(created.parentFlowId!)).toMatchObject({
|
||||
flowId: created.parentFlowId,
|
||||
const parentFlowId = expectParentFlowId(created);
|
||||
expect(getTaskFlowById(parentFlowId)).toMatchObject({
|
||||
flowId: parentFlowId,
|
||||
status: "blocked",
|
||||
blockedTaskId: created.taskId,
|
||||
blockedSummary: "Writable session required.",
|
||||
@@ -375,7 +384,7 @@ describe("task-executor", () => {
|
||||
});
|
||||
|
||||
const retried = retryBlockedFlowAsQueuedTaskRun({
|
||||
flowId: created.parentFlowId!,
|
||||
flowId: parentFlowId,
|
||||
runId: "run-executor-retry",
|
||||
childSessionKey: "agent:codex:acp:retry-child",
|
||||
});
|
||||
@@ -387,17 +396,17 @@ describe("task-executor", () => {
|
||||
taskId: created.taskId,
|
||||
}),
|
||||
task: expect.objectContaining({
|
||||
parentFlowId: created.parentFlowId,
|
||||
parentFlowId,
|
||||
parentTaskId: created.taskId,
|
||||
status: "queued",
|
||||
runId: "run-executor-retry",
|
||||
}),
|
||||
});
|
||||
expect(getTaskFlowById(created.parentFlowId!)).toMatchObject({
|
||||
flowId: created.parentFlowId,
|
||||
expect(getTaskFlowById(parentFlowId)).toMatchObject({
|
||||
flowId: parentFlowId,
|
||||
status: "queued",
|
||||
});
|
||||
expect(findLatestTaskForFlowId(created.parentFlowId!)).toMatchObject({
|
||||
expect(findLatestTaskForFlowId(parentFlowId)).toMatchObject({
|
||||
runId: "run-executor-retry",
|
||||
});
|
||||
expect(findTaskByRunId("run-executor-blocked")).toMatchObject({
|
||||
|
||||
Reference in New Issue
Block a user