From cbdc8a225381eea263bb96099d27f8b33aa7abea Mon Sep 17 00:00:00 2001 From: NiJingzhe <1448976235@qq.com> Date: Wed, 4 Nov 2026 13:47:09 +0800 Subject: [PATCH] editor-web: test which selections offer the workplane command Co-Authored-By: Claude Opus 5.5 --- editor-web/src/lib/workplanes.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor-web/src/lib/workplanes.test.ts b/editor-web/src/lib/workplanes.test.ts index c7acd550..37a4bec7 100644 --- a/editor-web/src/lib/workplanes.test.ts +++ b/editor-web/src/lib/workplanes.test.ts @@ -56,3 +56,15 @@ describe("workplanes", () => { expect(workplaneRequest([v(1), v(2)])).toBeNull(); }); }); + +import { selectionContext, whenFor } from "@/lib/commands"; + +describe("the workplane command", () => { + const when = whenFor("workplane_from_selection")!; + const ctx = (...kinds: string[]) => selectionContext(kinds.map((kind) => ({ kind, geometry: kind === "face" ? { type: "plane" } : null }))); + it("is offered for the selections Space understands, and only those", () => { + for (const ok of [["face"], ["face", "edge"], ["face", "face"], ["vertex", "vertex", "vertex"], ["edge"]]) expect(when(ctx(...ok))).toBe(true); + for (const no of [[], ["solid"], ["edge", "edge"], ["vertex"], ["face", "vertex"]]) expect(when(ctx(...no))).toBe(false); + expect(when(selectionContext([{ kind: "face", geometry: { type: "cylinder" } }]))).toBe(false); + }); +});