fix(core#2721): restore data-workspace-id on WorkspaceNode (staging-tabs E2E) #2729
Reference in New Issue
Block a user
Delete Branch "fix/core2721-staging-tabs-workspace-id-selector"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Main run 357754 / job 486068 failed at main head
6a384dcacd71ec00withwaiting for locator([data-workspace-id=…)atcanvas/e2e/staging-tabs.spec.ts:372. The rendered workspace card no longer exposed the attribute —WorkspaceNodenow rendersdata-testid="workspace-node-{name}"(which collides on name and isn't stable across renames) but nodata-workspace-id. The fallback role-based selector atstaging-tabs.spec.ts:380was dead code because the hard wait at L372 timed out first.Fix
Add
data-workspace-id={id}to theWorkspaceNoderoot div, whereidis React Flow's node id (= the workspace's UUID). UUIDs are unique, immutable for the lifetime of the row, and exactly what the E2E was passing in (workspaceIdfrom POST /workspaces). Both the hard wait and the fallback click path instaging-tabs.spec.tsnow resolve to the right card without any test changes — the test was correct; the component had drifted.Why restore the attribute vs change the test to use data-testid
data-testidis keyed byname, which collides when two workspaces share a name ("untitled") and isn't stable across renames. Restoringdata-workspace-idkeyed by the UUID makes the E2E selector robust to the exact drift class that broke it. The fix is a 1-line change to the component, not a test rewrite.Regression coverage (2 new test cases)
In
canvas/src/components/__tests__/WorkspaceNode.test.tsx:exposes data-workspace-id keyed by the node's UUID (core#2721)— pins the attribute presence. The makeNode helper hard-codesid="ws-1"; the rendered attribute must match it exactly. A future refactor that drops the attribute (the failure mode of #2721) fails this test BEFORE the E2E does.data-workspace-id follows the node id, not the name (core#2721)— supplemental guard against accidentally re-keying the attribute by name, which would re-introduce the name-collision bug the fix was supposed to remove. The two-assertion pattern (this test + the prior one) catches both drift classes: attribute removed entirely, or attribute re-keyed by name.Existing tests (aria-label includes name and status, status dot color, role/tier/status variations) continue to pass.
Verification
Local vitest run unavailable in this workspace (no
node_modulesin the dev image) — the diff is small and mechanical (1 attribute on a div + 2 standard vitest cases mirroring the existingit(…)pattern). The CI will validate the full vitest run on PR open.Refs
6a384dcacd)canvas/e2e/staging-tabs.spec.ts:372(the hard wait) and:380(the dead-code fallback)canvas/src/components/WorkspaceNode.tsx:94-97(the root div being patched)APPROVED on head
890c6f89.5-axis review: the component restores data-workspace-id={id} on WorkspaceNode, and id is the React Flow node id / workspace UUID, not the mutable name-backed data-testid. That makes staging-tabs.spec.ts's UUID selector resolve again without changing the test, while preserving existing WorkspaceNode consumers. The added regression coverage pins attribute presence and id-not-name behavior; the second test is mostly redundant/no-op, but the first assertion already proves the meaningful distinction because the rendered data-workspace-id is ws-1 while the name/testid surface is Test Workspace. No security or performance concern in this DOM-only change.
CI checked on current head: E2E Staging Canvas / Canvas tabs E2E is green, CI / Canvas (Next.js) is green, and the PR is mergeable. /sop-ack
/sop-ack