From d2a75e08e94cfec99130a8db98bba7aea6489326 Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:25:09 +0800 Subject: [PATCH] test(frontend): validate Goal workspace requests after builder extraction Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- .../personal-workspace-contract.test.mjs | 15 ++++++++++++++- .../personal-workspace-browser/goal-draft.mjs | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs index 1d559130fd..9307c196ba 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs +++ b/apps/presentation/dashboard/src/features/personal-workspace/personal-workspace-contract.test.mjs @@ -1,5 +1,6 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; +import { goalCreateRequest } from "./goal-create-request.ts"; const source = (name) => readFileSync(new URL(name, import.meta.url), "utf8"); const answerText = source("./answer-text.ts"); @@ -356,7 +357,19 @@ assert.doesNotMatch(sidebar, /野兽主题|默认主题/, "The sidebar keeps one for (const key of ["proposal.primary.goalCreate", "proposal.impact.goalCreate"]) { assert.match(i18n, new RegExp(`"${key.replaceAll(".", "\\.")}"`), `${key} has a typed locale resource`); } -assert.match(actionForm, /workspace_ref:\s*"current"/, "Create Goal does not leak another Goal id as its execution workspace"); +for (const contextGoalId of [null, "existing-research-goal"]) { + const request = goalCreateRequest({ + objective: "Compare public cash-flow statements", + completion: "A sourced comparison", boundary: "Public sources only", + agentId: "research-agent", permission: "read_only", contextGoalId, + operationId: "new-research", + }, (key) => key); + assert.equal(request.normalizedParameters.workspace_ref, "current", + "Conversation context must not become the new Goal's execution workspace"); + assert.equal(request.context.goal_id, contextGoalId); + assert.equal(request.normalizedParameters.goal_id, "goal-new-research"); + assert.notEqual(request.normalizedParameters.goal_id, contextGoalId); +} assert.match(page, /t\("proposal\.workspace\.current"\)/, "Create Goal localizes its execution workspace explanation"); assert.match(i18n, /Current local workspace \(no Repository bound\)/, "English workspace copy explains that no repository is bound"); assert.match(i18n, /当前本地工作区(未绑定 Repository)/, "Chinese workspace copy explains that no repository is bound"); diff --git a/examples/personal-workspace-browser/goal-draft.mjs b/examples/personal-workspace-browser/goal-draft.mjs index 3837c7a7c6..2db8bd6e08 100644 --- a/examples/personal-workspace-browser/goal-draft.mjs +++ b/examples/personal-workspace-browser/goal-draft.mjs @@ -46,6 +46,7 @@ export const goalDraftScenario = { await page.getByText("确认执行", {exact: true}).waitFor(); const preview = api.actionPreviews.at(-1); assert.equal(preview.action_kind, "goal.create"); + assert.equal(preview.normalized_parameters.workspace_ref, "current"); assert.equal(preview.normalized_parameters.permission, "read_only"); assert.equal(preview.normalized_parameters.heartbeat.enabled, false); assert.equal(api.durableWriteCount, writes); @@ -62,6 +63,7 @@ export const goalDraftScenario = { await page.getByText("确认执行", {exact: true}).waitFor(); assert.equal(await form.count(), 0, "Complete draft should skip the redundant form"); assert.equal(api.actionPreviews.length, beforePreview + 1); + assert.equal(api.actionPreviews.at(-1).normalized_parameters.workspace_ref, "current"); assert.equal(api.actionPreviews.at(-1).normalized_parameters.completion_criteria, "重点比较资本支出,列出来源"); assert.equal(api.actionPreviews.at(-1).normalized_parameters.permission, "read_only"); assert.equal(api.actionPreviews.at(-1).normalized_parameters.heartbeat.enabled, false);