From a75373074adea4b81cbd0958e5a55db499b76621 Mon Sep 17 00:00:00 2001 From: Molecule AI App-FE Date: Mon, 11 May 2026 03:37:57 +0000 Subject: [PATCH] fix(canvas): sortParentsBeforeChildren stable ordering + TIER_CONFIG string keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sortParentsBeforeChildren: stable-order fix — visit true roots (parentId undefined) before orphans (parentId references missing node). Previously processed input order, so [orphan, root] produced [orphan, root] instead of the expected [root, orphan]. TIER_CONFIG: use string keys ("1"…"4") in toHaveProperty calls. Vitest's toHaveProperty is string-keyed; TypeScript strict mode with noPropertyAccessFromIndexSignature rejects numeric literal keys on Record. Co-Authored-By: Claude Opus 4.7 --- canvas/src/lib/__tests__/statusDotClass.test.ts | 8 ++++---- canvas/src/store/canvas-topology.ts | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/canvas/src/lib/__tests__/statusDotClass.test.ts b/canvas/src/lib/__tests__/statusDotClass.test.ts index fcf22f98..857d9b3e 100644 --- a/canvas/src/lib/__tests__/statusDotClass.test.ts +++ b/canvas/src/lib/__tests__/statusDotClass.test.ts @@ -55,10 +55,10 @@ describe("statusDotClass", () => { describe("TIER_CONFIG", () => { it("has entries for all four tier levels", () => { - expect(TIER_CONFIG).toHaveProperty(1); - expect(TIER_CONFIG).toHaveProperty(2); - expect(TIER_CONFIG).toHaveProperty(3); - expect(TIER_CONFIG).toHaveProperty(4); + expect(TIER_CONFIG).toHaveProperty("1"); + expect(TIER_CONFIG).toHaveProperty("2"); + expect(TIER_CONFIG).toHaveProperty("3"); + expect(TIER_CONFIG).toHaveProperty("4"); }); it("each tier has label, color, and border fields", () => { diff --git a/canvas/src/store/canvas-topology.ts b/canvas/src/store/canvas-topology.ts index 334dcff7..6bf46032 100644 --- a/canvas/src/store/canvas-topology.ts +++ b/canvas/src/store/canvas-topology.ts @@ -34,7 +34,22 @@ export function sortParentsBeforeChildren