Skip to content

test(e2e): repair the legacy workflow fixture - #14

Open
coollugi wants to merge 1 commit into
Rytass:mainfrom
coollugi:fix/legacy-designer-spec-fixture
Open

test(e2e): repair the legacy workflow fixture#14
coollugi wants to merge 1 commit into
Rytass:mainfrom
coollugi:fix/legacy-designer-spec-fixture

Conversation

@coollugi

Copy link
Copy Markdown
Contributor

normalizes legacy approval policy defaults before saving 目前在 main 上是失敗的,本 PR 修正它的 fixture

現象

在乾淨的 maind8feb9a)上執行

npx playwright test -c apps/client-e2e/playwright.config.ts template-designer-w3 -g "normalizes legacy"

會停在 page.getByRole('button', { name: '簽核節點' }).click() 逾時

兩個原因

一、fixture 的 edges 沒有 data,設計器在載入時就崩潰

readLegacyWorkflowDefinition 產生的連線是 { id, source, target },沒有 data
libs/shared/src/lib/workflow-toolset.ts:499readEdgeSnapshot 直接讀取

condition: edge.data.condition ?? null,

於是頁面丟出 Cannot read properties of undefined (reading 'condition'),整個設計器渲染不出來
測試看到的「找不到按鈕」只是這個崩潰的下游症狀

二、節點 id 缺少 userTask_ 前綴,存草稿會被 mock 的守衛擋下

workflowDefinitionHasLinearTask 要求 start → userTask_* → end,而 fixture 用的是 task_review
真實的 createWorkflowNode 產生的是 userTask_1,所以守衛本身是正確的,是 fixture 沒有對齊

修法

fixture 補上 data: {} 並把節點 id 改為 userTask_1,共 3 行

修改後該測試通過(本機實跑 731ms),pnpm typecheckpnpm lint 皆為 6 個 project 全過

附帶回報,未在本 PR 處理

edge.data 在下列位置也是直接解參考,沒有防禦

libs/bpm-core-react/src/views/instances/detail/InstanceDetailView.tsx:855 856 859 863 960 961 966
libs/bpm-core-react/src/views/templates/compose/steps/ComposeReviewStep.tsx:64 66
libs/bpm-core-react/src/views/templates/designer/TemplateDesignerView.tsx:2913 2942 2952
libs/shared/src/lib/workflow-toolset.ts:499

從設計器建立的流程一定會帶 datacreateWorkflowEdge 會給 {}),所以畫面操作不會踩到
但透過 API 或腳本寫入的流程若省略了 data,開啟設計器就會是白畫面

要不要保證 edge.data 必然存在,屬於資料契約層的取捨,可能適合在載入時統一補值
(如同 normalizeUserTaskPolicies 對節點所做的),而不是在每個讀取點各自防禦
這部分留給貴方判斷,本 PR 不做更動

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVBKX88XEgSHGrxzsL2Zjj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant