mirror of
https://github.com/penpot/penpot.git
synced 2026-07-04 21:35:22 +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
88 lines
3.4 KiB
Clojure
88 lines
3.4 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.text-test
|
|
(:require
|
|
[app.main.data.workspace.texts :as dwt]
|
|
[app.main.store :as st]
|
|
[app.plugins.fonts :as fonts]
|
|
[app.plugins.format :as format]
|
|
[app.plugins.register :as r]
|
|
[app.plugins.shape :as shape]
|
|
[app.plugins.text :as plugins.text]
|
|
[app.plugins.utils :as u]
|
|
[cljs.test :as t :include-macros true]
|
|
[frontend-tests.helpers.mock :as mock]))
|
|
|
|
(def ^:private plugin-id "00000000-0000-0000-0000-000000000000")
|
|
|
|
(t/deftest font-apply-to-text-uses-font-id-not-shape-id
|
|
(let [file-id (random-uuid)
|
|
page-id (random-uuid)
|
|
shape-id (random-uuid)
|
|
font (fonts/font-proxy
|
|
plugin-id
|
|
{:id "font-id"
|
|
:family "Inter"
|
|
:name "Inter"
|
|
:variants [{:id "regular"
|
|
:name "Regular"
|
|
:weight "400"
|
|
:style "normal"}]})
|
|
text (shape/shape-proxy plugin-id file-id page-id shape-id)
|
|
captured (atom nil)]
|
|
(with-redefs [r/check-permission (constantly true)
|
|
u/page-active? (constantly true)
|
|
dwt/update-attrs
|
|
(fn [id attrs]
|
|
(reset! captured {:id id :attrs attrs})
|
|
:update-attrs)
|
|
st/emit! mock/noop]
|
|
(.applyToText font text nil)
|
|
(t/is (= shape-id (:id @captured)))
|
|
(t/is (= "font-id" (get-in @captured [:attrs :font-id]))))))
|
|
|
|
(t/deftest font-apply-to-range-uses-hidden-range-bounds
|
|
(let [file-id (random-uuid)
|
|
page-id (random-uuid)
|
|
shape-id (random-uuid)
|
|
font (fonts/font-proxy
|
|
plugin-id
|
|
{:id "font-id"
|
|
:family "Inter"
|
|
:name "Inter"
|
|
:variants [{:id "regular"
|
|
:name "Regular"
|
|
:weight "400"
|
|
:style "normal"}]})
|
|
range (plugins.text/text-range-proxy plugin-id file-id page-id shape-id 1 4)
|
|
captured (atom nil)]
|
|
(with-redefs [r/check-permission (constantly true)
|
|
u/page-active? (constantly true)
|
|
dwt/update-text-range
|
|
(fn [id start end attrs]
|
|
(reset! captured {:id id
|
|
:start start
|
|
:end end
|
|
:attrs attrs})
|
|
:update-text-range)
|
|
st/emit! mock/noop]
|
|
(.applyToRange font range nil)
|
|
(t/is (= shape-id (:id @captured)))
|
|
(t/is (= 1 (:start @captured)))
|
|
(t/is (= 4 (:end @captured)))
|
|
(t/is (= "font-id" (get-in @captured [:attrs :font-id]))))))
|
|
|
|
(t/deftest text-range-shape-returns-a-shape-proxy
|
|
(let [file-id (random-uuid)
|
|
page-id (random-uuid)
|
|
shape-id (random-uuid)
|
|
range (plugins.text/text-range-proxy plugin-id file-id page-id shape-id 0 3)]
|
|
(with-redefs [format/shape-proxy shape/shape-proxy]
|
|
(let [text-shape (.-shape range)]
|
|
(t/is (shape/shape-proxy? text-shape))
|
|
(t/is (= shape-id (aget text-shape "$id")))))))
|