From 408917e1b88a528db5d7570355027399811c5f68 Mon Sep 17 00:00:00 2001 From: Nisha Yerunkar Date: Tue, 6 Aug 2024 13:43:42 -0700 Subject: [PATCH] [Hint Mode: Start Coords] Correct flag logic for polygon graph start coords UI --- .changeset/clean-glasses-watch.md | 5 + .../perseus-editor/src/components/util.ts | 2 +- .../interactive-graph-editor.test.tsx | 94 +++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .changeset/clean-glasses-watch.md diff --git a/.changeset/clean-glasses-watch.md b/.changeset/clean-glasses-watch.md new file mode 100644 index 0000000000..58a9e8c45e --- /dev/null +++ b/.changeset/clean-glasses-watch.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus-editor": patch +--- + +[Hint Mode: Start Coords] Correct flag logic for polygon graph start coords UI diff --git a/packages/perseus-editor/src/components/util.ts b/packages/perseus-editor/src/components/util.ts index 7aa1d886da..e0d61de1a0 100644 --- a/packages/perseus-editor/src/components/util.ts +++ b/packages/perseus-editor/src/components/util.ts @@ -303,7 +303,7 @@ export const shouldShowStartCoordsUI = (flags, graph) => { if ( startCoordsPolygon && graph.type === "polygon" && - graph.numPoints !== "unlimited" && + graph.numSides !== "unlimited" && // Pre-initialized graph with undefined snapTo value // initializes to snapTo="grid" (graph.snapTo === "grid" || graph.snapTo === undefined) diff --git a/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx b/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx index 0936ec9759..0309c5b28f 100644 --- a/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx +++ b/packages/perseus-editor/src/widgets/__tests__/interactive-graph-editor.test.tsx @@ -673,6 +673,8 @@ describe("InteractiveGraphEditor", () => { ); }); + // TODO(LEMS-2228): Remove flag-related code once + // start coords UI is rolled out 100% test.each` type | shouldRender ${"linear"} | ${true} @@ -908,4 +910,96 @@ describe("InteractiveGraphEditor", () => { } }, ); + + test("should not render for point graphs with unlimited points", async () => { + // Arrange + + // Act + render( + , + { + wrapper: RenderStateRoot, + }, + ); + + // Assert + expect( + screen.queryByRole("button", { + name: "Use default start coordinates", + }), + ).toBeNull(); + }); + + test("should not render for polygon graphs with unlimited sides", async () => { + // Arrange + + // Act + render( + , + { + wrapper: RenderStateRoot, + }, + ); + + // Assert + expect( + screen.queryByRole("button", { + name: "Use default start coordinates", + }), + ).toBeNull(); + }); + + test("should not render for polygon graphs with non-grid snapTo (angles)", async () => { + // Arrange + + // Act + render( + , + { + wrapper: RenderStateRoot, + }, + ); + + // Assert + expect( + screen.queryByRole("button", { + name: "Use default start coordinates", + }), + ).toBeNull(); + }); + + test("should not render for polygon graphs with non-grid snapTo (sides)", async () => { + // Arrange + + // Act + render( + , + { + wrapper: RenderStateRoot, + }, + ); + + // Assert + expect( + screen.queryByRole("button", { + name: "Use default start coordinates", + }), + ).toBeNull(); + }); });