From bebe1e369031869b4198eeb8d31a6c005d7594b2 Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 13 Sep 2026 18:46:21 +0000 Subject: [PATCH] test(e2e): open UI-11 prelim_design by registered doc_proj id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Card title is 系统初步设计方案, not 系统设计输入; select doc_proj*_prelim_design so the template slot cannot be mistaken for the generated document. Co-authored-by: Cursor --- web/e2e/document-revision-runtime.spec.ts | 30 ++++++++++++++++++++++- web/src/engine/templateFactory.test.ts | 8 ++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/web/e2e/document-revision-runtime.spec.ts b/web/e2e/document-revision-runtime.spec.ts index e851e9b5..5c236de6 100644 --- a/web/e2e/document-revision-runtime.spec.ts +++ b/web/e2e/document-revision-runtime.spec.ts @@ -316,6 +316,30 @@ async function openWorkflowDocByLabel( return { title: title || docId, docId }; } +/** 按已注册 doc_proj{n}_{taskKey} 打开,避开同标题模板槽与宽泛文案误命中。 */ +async function openWorkflowDocByControlledTaskKey( + page: Page, + taskKey: string, +): Promise<{ title: string; docId: string }> { + if (!/^[a-z][a-z0-9_]*$/.test(taskKey)) fail(`invalid controlled taskKey: ${taskKey}`); + const trigger = page.getByTestId('doc-selector-trigger'); + await expect(trigger).toBeVisible({ timeout: 15_000 }); + await trigger.click(); + const item = page + .locator(`.dropdown-menu button[data-doc-id^="doc_proj"][data-doc-id$="_${taskKey}"]`) + .first(); + if ((await item.count()) === 0) { + fail(`workflow menu missing registered doc_proj*_${taskKey}`); + } + const docId = (await item.getAttribute('data-doc-id')) || ''; + const title = (await item.getAttribute('data-doc-title')) || ''; + if (!new RegExp(`^doc_proj\\d+_${taskKey}$`).test(docId)) { + fail(`expected doc_proj{n}_${taskKey}, got ${JSON.stringify(docId)}`); + } + await item.click(); + return { title: title || docId, docId }; +} + async function openWorkflowDocById(page: Page, docId: string): Promise { if (!docId) fail('openWorkflowDocById requires docId'); const trigger = page.getByTestId('doc-selector-trigger'); @@ -1053,7 +1077,11 @@ test.describe.serial('document-revision-runtime UI acceptance', () => { fail(`UI-11 task_key must be prelim_design, got ${JSON.stringify(taskBody.task_key)}`); } await waitForSquadCompletion(page, '系统设计输入'); - const second = await openWorkflowDocByLabel(page, /设计输入|系统设计/); + // Prompt alias is 系统设计输入; card title is 系统初步设计方案; open by registered doc_proj id. + const second = await openWorkflowDocByControlledTaskKey(page, 'prelim_design'); + if (second.title !== '系统初步设计方案') { + fail(`UI-11 prelim_design card title must be 系统初步设计方案, got ${JSON.stringify(second.title)}`); + } secondDocTitle = second.title; secondDocId = second.docId; await expect(page.getByTestId('active-document-pane')).toHaveAttribute('data-doc-id', secondDocId); diff --git a/web/src/engine/templateFactory.test.ts b/web/src/engine/templateFactory.test.ts index 947757b8..f4819f81 100644 --- a/web/src/engine/templateFactory.test.ts +++ b/web/src/engine/templateFactory.test.ts @@ -32,6 +32,14 @@ test('createProjectTemplateDeliverables: 必须精确生成 7 份全生命周期 const actualTaskKeys = result.deliverables.map((d) => d.taskKey); assert.deepStrictEqual(actualTaskKeys, expectedTaskKeys); + const prelim = result.deliverables.find((d) => d.taskKey === 'prelim_design'); + assert.ok(prelim, 'prelim_design template must exist'); + assert.strictEqual(prelim.title, '系统初步设计方案'); + assert.strictEqual( + STANDARD_WORKFLOW_TEMPLATES.find((t) => t.taskKey === 'prelim_design')?.title, + '系统初步设计方案', + ); + // 2. 验证阶段覆盖 (V0.1, V0.5, V1.0) const stages = new Set(result.deliverables.map((d) => d.stage)); assert.ok(stages.has('V0.1'));