feat: harden ai onboarding and approval chat flows

This commit is contained in:
kris
2026-03-31 04:18:57 +08:00
parent 4336dc22a7
commit 0cb2171dd3
16 changed files with 551 additions and 27 deletions

View File

@@ -187,6 +187,7 @@ test("POST /api/v1/projects/[projectId]/dispatch-plans/[planId]/confirm confirms
ok: boolean;
plan: { planId: string; status: string; confirmedTargetProjectIds: string[] };
executions: Array<{ planId: string; targetProjectId: string; status: string }>;
notice: { kind: string; body: string } | null;
};
assert.equal(payload.ok, true);
assert.equal(payload.plan.planId, dispatchPlan.planId);
@@ -196,6 +197,9 @@ test("POST /api/v1/projects/[projectId]/dispatch-plans/[planId]/confirm confirms
assert.equal(payload.executions[0]?.planId, dispatchPlan.planId);
assert.equal(payload.executions[0]?.targetProjectId, approvedTargetProjectId);
assert.equal(payload.executions[0]?.status, "queued");
assert.ok(payload.notice, "expected a confirmation notice in the response");
assert.equal(payload.notice?.kind, "system_notice");
assert.equal(payload.notice?.body, "已确认下发到 1 个线程:《北区试产线回归》。");
const nextState = await readState();
const notice = nextState.projects
@@ -280,6 +284,7 @@ test("rejecting a dispatch plan marks approval_required groups as rejected and w
assert.equal(payload.plan.planId, dispatchPlan.planId);
assert.equal(payload.plan.status, "rejected");
assert.equal(payload.notice.kind, "system_notice");
assert.equal(payload.notice.body, "已拒绝主 Agent 推荐,本次不会下发到任何线程。");
const nextState = await readState();
const nextGroupProject = nextState.projects.find((project) => project.id === groupProject.id);

View File

@@ -270,6 +270,14 @@ test("POST /api/v1/projects/[projectId]/messages marks approval_required groups
const persistedGroup = nextState.projects.find((project) => project.id === groupProject.id);
assert.ok(persistedGroup, "expected group project to persist");
assert.equal(persistedGroup?.approvalState, "pending_user");
const pendingNotice = persistedGroup?.messages.find(
(message) =>
message.sender === "master" &&
message.kind === "system_notice" &&
message.body.includes("等待你确认"),
);
assert.ok(pendingNotice, "expected an approval notice to be persisted in the group ledger");
assert.match(pendingNotice?.body ?? "", /等待你确认|待审批|待确认/);
});
test("POST /api/v1/projects/[projectId]/messages keeps message success when group dispatch recommendation fails", async () => {