From 76070008c20622d5906d839117f3da50896ab8b7 Mon Sep 17 00:00:00 2001 From: Filip Sajdak Date: Wed, 17 Jun 2026 15:30:56 +0200 Subject: [PATCH] :bug: Fix plugin API board.guides invalid-schema on set/clear Setting or clearing `board.guides` from a plugin threw a malli `:malli.core/invalid-schema` for every value, including `[]`. Causes: - `shape.cljs` validated against `[:vector ::ctg/grid]`, but the `:app.common.types.grid/grid` reference is no longer registered (direct schemas replaced the namespaced-keyword registrations). Use the direct var `ctg/schema:grid`, matching every other setter. - `parser.cljs` `parse-frame-guide` returned the `parse-frame-guide-column` / `parse-frame-guide-row` fns instead of calling them with the guide, so column/row guides parsed to a vector containing a function. - `parse-frame-guide-square` used `parse-frame-guide-column-params` instead of the dedicated `parse-frame-guide-square-params`. Adds a regression test parsing column/square guides and validating the result (and an empty vector) against `ctg/schema:grid`. Fixes #9773 Co-authored-by: Claude Opus 4.8 Signed-off-by: Filip Sajdak --- frontend/src/app/plugins/parser.cljs | 2 +- .../frontend_tests/plugins/parser_test.cljs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/plugins/parser.cljs b/frontend/src/app/plugins/parser.cljs index 0c3c2af32a..d6ec255ab8 100644 --- a/frontend/src/app/plugins/parser.cljs +++ b/frontend/src/app/plugins/parser.cljs @@ -336,7 +336,7 @@ (d/without-nils {:type (-> (obj/get guide "type") parse-keyword) :display (obj/get guide "display") - :params (-> (obj/get guide "params") parse-frame-guide-column-params)}))) + :params (-> (obj/get guide "params") parse-frame-guide-square-params)}))) (defn parse-frame-guide [^js guide] diff --git a/frontend/test/frontend_tests/plugins/parser_test.cljs b/frontend/test/frontend_tests/plugins/parser_test.cljs index 44abb8ebbd..425c51d3fa 100644 --- a/frontend/test/frontend_tests/plugins/parser_test.cljs +++ b/frontend/test/frontend_tests/plugins/parser_test.cljs @@ -7,6 +7,8 @@ (ns frontend-tests.plugins.parser-test (:require [app.common.geom.point :as gpt] + [app.common.schema :as sm] + [app.common.types.grid :as ctg] [app.plugins.parser :as parser] [cljs.test :as t :include-macros true])) @@ -61,3 +63,25 @@ (t/is (= :row (:type row))) (t/is (= false (:display row))) (t/is (= :center (get-in row [:params :type]))))) + +(t/deftest test-parse-frame-guides + ;; Regression test for issue #9773. + ;; + ;; `parse-frame-guide` returned the parser fns for column/row instead of + ;; calling them with the guide, and the `board.guides` setter validated + ;; against an unregistered `::ctg/grid` reference (now `ctg/schema:grid`). + ;; Parsed guides must be plain maps that validate against the same direct + ;; schema the setter uses, and clearing (empty input) must validate too. + (let [column #js {:type "column" :display true + :params #js {:color #js {:color "#DE4762" :opacity 0.2} + :type "stretch" :size 12 :gutter 16 :margin 16}} + square #js {:type "square" :display true + :params #js {:color #js {:color "#DE4762" :opacity 0.2} :size 8}} + parsed (parser/parse-frame-guides #js [column square])] + (t/is (= :column (-> parsed first :type))) + (t/is (= :square (-> parsed second :type))) + (t/is (map? (-> parsed first :params))) + (t/is (sm/validate [:vector ctg/schema:grid] parsed))) + + (t/testing "clearing guides with an empty vector validates" + (t/is (sm/validate [:vector ctg/schema:grid] (parser/parse-frame-guides #js [])))))