diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index 56407e68f..35c0c7580 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -166,8 +166,12 @@ (assoc-in shape [:strokes 0 :stroke-width] value)))))) (defn update-rotation [value shape-ids] - (st/emit! (udw/trigger-bounding-box-cloaking shape-ids) - (udw/increase-rotation shape-ids value))) + (ptk/reify ::update-shape-dimensions + ptk/WatchEvent + (watch [_ _ _] + (rx/of + (udw/trigger-bounding-box-cloaking shape-ids) + (udw/increase-rotation shape-ids value))))) (defn update-layout-spacing-column [value shape-ids] (doseq [shape-id shape-ids] diff --git a/frontend/test/token_tests/logic/token_actions_test.cljs b/frontend/test/token_tests/logic/token_actions_test.cljs index c5a303387..e1c39ea9a 100644 --- a/frontend/test/token_tests/logic/token_actions_test.cljs +++ b/frontend/test/token_tests/logic/token_actions_test.cljs @@ -137,6 +137,30 @@ ;; TODO Fix opacity shape update not working? #_(t/is (= (:opacity rect-1') 0.5)))))))) +(t/deftest test-apply-rotation + (t/testing "applies rotation token and updates the shapes rotation") + (t/async + done + (let [file (-> (setup-file) + (toht/add-token :token-target {:value "120" + :name "rotation.medium" + :type :rotation})) + store (ths/setup-store file) + rect-1 (cths/get-shape file :rect-1) + events [(wtc/apply-token {:shape-ids [(:id rect-1)] + :attributes #{:rotation} + :token (toht/get-token file :token-target) + :on-update-shape wtc/update-rotation})]] + (tohs/run-store-async + store done events + (fn [new-state] + (let [file' (ths/get-file-from-store new-state) + token-target' (toht/get-token file' :token-target) + rect-1' (cths/get-shape file' :rect-1)] + (t/is (some? (:applied-tokens rect-1'))) + (t/is (= (:rotation (:applied-tokens rect-1')) (:id token-target'))) + (t/is (= (:rotation rect-1') 120)))))))) + (t/deftest test-toggle-token-none (t/testing "should apply token to all selected items, where no item has the token applied" (t/async