mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
The plugin parser's parse-point returned a plain `{:x … :y …}` map,
but shape interaction schemas (for example schema:open-overlay-interaction)
require the attribute to be a `::gpt/point` record. `(instance? Point {:x 0 :y 0})`
is false, so validation silently rejected plugin `addInteraction` calls
that passed `manualPositionLocation`; only a console warning was produced.
Change parse-point to return a `gpt/point` record via `gpt/point`.
All three call sites (parser.cljs:open-overlay, plugins/page.cljs,
plugins/comments.cljs) continue to work because Point records support
the same `:x`/`:y` access plain maps do.
Add a unit test that covers nil input and verifies the returned value
satisfies `gpt/point?`.
Github #8409
Signed-off-by: FairyPigDev <luislee3108@gmail.com>
Signed-off-by: Andrey Antukh <niwi@niwi.nz>
Co-authored-by: Andrey Antukh <niwi@niwi.nz>
34 lines
1.3 KiB
Clojure
34 lines
1.3 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC
|
|
|
|
(ns frontend-tests.plugins.parser-test
|
|
(:require
|
|
[app.common.geom.point :as gpt]
|
|
[app.plugins.parser :as parser]
|
|
[cljs.test :as t :include-macros true]))
|
|
|
|
(t/deftest test-parse-point-returns-gpt-point-record
|
|
;; Regression test for issue #8409.
|
|
;;
|
|
;; The plugin parser used to return a plain map `{:x … :y …}`, but the
|
|
;; shape-interaction schema expects `::gpt/point` (a Point record).
|
|
;; Plugin `addInteraction` calls with an `open-overlay` action and
|
|
;; `manualPositionLocation` were silently rejected by validation.
|
|
(t/testing "parse-point returns nil for nil input"
|
|
(t/is (nil? (parser/parse-point nil))))
|
|
|
|
(t/testing "parse-point returns a gpt/point record for valid input"
|
|
(let [result (parser/parse-point #js {:x 10 :y 20})]
|
|
(t/is (gpt/point? result))
|
|
(t/is (= 10 (:x result)))
|
|
(t/is (= 20 (:y result)))))
|
|
|
|
(t/testing "parse-point passes gpt/point? for a zero point"
|
|
(let [result (parser/parse-point #js {:x 0 :y 0})]
|
|
(t/is (gpt/point? result))
|
|
(t/is (= 0 (:x result)))
|
|
(t/is (= 0 (:y result))))))
|