mirror of
https://github.com/penpot/penpot.git
synced 2026-07-03 04:45:28 +00:00
* ✨ Adds static dispatch safe stubs in tests * 🐛 Fix shapesColors metadata key to match ColorShapeInfo * 🐛 Fix CommentThread.remove rejecting the owner's own threads * 🐛 Fix page.removeCommentThread throwing on a spurious Promise * ✨ Implement ShapeBase.swapComponent in the plugin API * ✨ Expose File.revn in the plugin API * 🐛 Fix FileVersion.createdAt calling Luxon method on a js/Date * 🐛 Fix plugin font/typography application to text and ranges * 🐛 Default plugin overlay interaction position for non-manual types * 🐛 Fix plugin interaction setters passing an id-only shape * 🐛 Fix grid addColumnAtIndex rejecting valid track types * 🐛 Expose libraryId on library color/typography/component proxies * ✨ Implement LibraryTypography.setFont in the plugin API * 🐛 Fix typography.applyToTextRange reading unexposed range bounds * 🐛 Fix utils.geometry.center argument mismatch * 🐛 Fix localStorage.removeItem calling getItem * 🐛 Fix shape backgroundBlur proxy key casing * 🐛 Report boolean shape type as 'boolean' in the plugin API * 🐛 Return the resulting paths from plugin flatten * 🐛 Make plugin z-order methods act on the target shape * 🐛 Make is-variant-container? return a boolean * ✨ Implement Group.isMask in the plugin API * 🐛 Return a shape proxy from TextRange.shape * 🐛 Return the duplicated set from TokenSet.duplicate * 🐛 Fix theme addSet/removeSet reading set name with a keyword * 🐛 Accept string fontFamilies token value in the plugin API * 🐛 Fix combineAsVariants ignoring the passed component ids * 🐛 Fix board removeRulerGuide ignoring its argument * 🐛 Fix board guides setter schema and parser * 🐛 Avoid 0-byte allocation when syncing empty grid tracks * 🐛 Validate grid track indices in the plugin API * 🐛 Return null for empty input in group() and centerShapes() * 🐛 Return TokenTypographyValue[] from a typography token's resolvedValue * 🐛 Return TokenShadowValue[] from a shadow token's resolvedValue * 🐛 Return string[] from a fontFamilies token's resolvedValue * 🐛 Clear mutually-exclusive reps when setting LibraryColor gradient/image * 🐛 Add readonly tags to types, deprecate Image type * 📚 Update plugins changelog
64 lines
2.5 KiB
Clojure
64 lines
2.5 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))))))
|
|
|
|
(t/deftest test-parse-overlay-action-defaults-manual-position
|
|
(let [destination #js {"$id" (random-uuid)}
|
|
action (parser/parse-action
|
|
#js {:type "open-overlay"
|
|
:destination destination
|
|
:position "center"})]
|
|
(t/is (= :open-overlay (:action-type action)))
|
|
(t/is (= :center (:overlay-pos-type action)))
|
|
(t/is (gpt/point? (:overlay-position action)))
|
|
(t/is (= 0 (:x (:overlay-position action))))
|
|
(t/is (= 0 (:y (:overlay-position action))))))
|
|
|
|
(t/deftest test-parse-frame-guide-calls-guide-parser
|
|
(let [column (parser/parse-frame-guide
|
|
#js {:type "column"
|
|
:display true
|
|
:params #js {:type "stretch"
|
|
:size 12}})
|
|
row (parser/parse-frame-guide
|
|
#js {:type "row"
|
|
:display false
|
|
:params #js {:type "center"
|
|
:margin 4}})]
|
|
(t/is (= :column (:type column)))
|
|
(t/is (= true (:display column)))
|
|
(t/is (= :stretch (get-in column [:params :type])))
|
|
(t/is (= :row (:type row)))
|
|
(t/is (= false (:display row)))
|
|
(t/is (= :center (get-in row [:params :type])))))
|