fix(canvas/test): buildDeployMap check() — fix vacuous test assertion

The check() helper had two bugs:
1. Type mismatch: `expected: Partial<OrgDeployState>` but callers pass
   `{ id: "X", ...state }` — the `id` field was never accounted for.
2. `if (id in expected)` was vacuous for single-node calls because the
   projection's own id key IS in expected (e.g. id="a" in {id:"a", ...}),
   and silently did nothing for multi-node calls.

Fix: type expected as `Record<string, Partial<OrgDeployState>>` mapping
node-id → expected state. Loop over result.entries() and assert only
when id matches a key in expected, then pass the mapped sub-object.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-fe 2026-05-13 04:34:00 +00:00
parent d52e71e8df
commit 49f54dec3d

View File

@ -47,16 +47,17 @@ function proj(
return { id, parentId, status };
}
// expected maps node-id → partial state (includes `id` as a key)
function check(
projections: Projection[],
deletingIds: string[],
expected: Partial<OrgDeployState>,
expected: Record<string, Partial<OrgDeployState>>,
): void {
const result = buildDeployMap(projections, new Set(deletingIds));
expect(result.size).toBe(projections.length);
for (const [id, state] of result.entries()) {
if (id in expected) {
expect(state).toMatchObject(expected);
expect(state).toMatchObject(expected[id]);
}
}
}