mirror of
https://github.com/penpot/penpot.git
synced 2025-04-10 05:51:33 -05:00
🔧 Fix test cases
This commit is contained in:
parent
2790111405
commit
bbd561a772
9 changed files with 147 additions and 98 deletions
|
@ -181,7 +181,9 @@
|
|||
;; incoming shapes to the parent.
|
||||
(update :shapes d/vec-without-nils))]
|
||||
(cond-> parent
|
||||
(and (:shape-ref parent) (= (:type parent) :group) (not ignore-touched))
|
||||
(and (:shape-ref parent)
|
||||
(#{:group :frame} (:type parent))
|
||||
(not ignore-touched))
|
||||
(-> (update :touched cph/set-touched-group :shapes-group)
|
||||
(dissoc :remote-synced?)))))
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[app.common.types.components-list :as ctkl]
|
||||
[app.common.types.pages-list :as ctpl]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.uuid :as uuid]
|
||||
[clojure.spec.alpha :as s]))
|
||||
|
||||
(s/def ::type #{:page :component})
|
||||
|
@ -147,7 +148,8 @@
|
|||
(ctpl/get-page library-data (:main-instance-page component)))
|
||||
component-shape (if components-v2
|
||||
(-> (get-shape component-page (:main-instance-id component))
|
||||
(assoc :parent-id nil))
|
||||
(assoc :parent-id nil)
|
||||
(assoc :frame-id uuid/zero))
|
||||
(get-shape component (:id component)))
|
||||
|
||||
orig-pos (gpt/point (:x component-shape) (:y component-shape))
|
||||
|
@ -156,8 +158,10 @@
|
|||
objects (:objects container)
|
||||
unames (volatile! (common/retrieve-used-names objects))
|
||||
|
||||
frame-id (ctst/frame-id-by-position objects (gpt/add orig-pos delta))
|
||||
frame-ids-map (volatile! {})
|
||||
frame-id (ctst/frame-id-by-position objects
|
||||
(gpt/add orig-pos delta)
|
||||
{:skip-components? true}) ; It'd be weird to make an instance
|
||||
frame-ids-map (volatile! {}) ; inside other component
|
||||
|
||||
update-new-shape
|
||||
(fn [new-shape original-shape]
|
||||
|
@ -211,5 +215,6 @@
|
|||
(update $ :frame-id #(get @frame-ids-map % frame-id))
|
||||
(update $ :parent-id #(or % (:frame-id $)))))]
|
||||
|
||||
[new-shape (map remap-frame-id new-shapes)])))
|
||||
[(remap-frame-id new-shape)
|
||||
(map remap-frame-id new-shapes)])))
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[app.common.math :as mth]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
|
@ -108,20 +109,24 @@
|
|||
|
||||
(defn get-frames
|
||||
"Retrieves all frame objects as vector"
|
||||
[objects]
|
||||
(or (-> objects meta ::index-frames)
|
||||
(let [lookup (d/getf objects)
|
||||
xform (comp (remove #(= uuid/zero %))
|
||||
(keep lookup)
|
||||
(filter cph/frame-shape?))]
|
||||
(->> (keys objects)
|
||||
(into [] xform)))))
|
||||
([objects] (get-frames objects nil))
|
||||
([objects {:keys [skip-components?] :or {skip-components? false}}]
|
||||
(->> (or (-> objects meta ::index-frames)
|
||||
(let [lookup (d/getf objects)
|
||||
xform (comp (remove #(= uuid/zero %))
|
||||
(keep lookup)
|
||||
(filter cph/frame-shape?))]
|
||||
(->> (keys objects)
|
||||
(into [] xform))))
|
||||
(filter #(or (not skip-components?)
|
||||
(not (ctk/instance-root? %)))))))
|
||||
|
||||
(defn get-frames-ids
|
||||
"Retrieves all frame ids as vector"
|
||||
[objects]
|
||||
(->> (get-frames objects)
|
||||
(mapv :id)))
|
||||
([objects] (get-frames-ids objects nil))
|
||||
([objects options]
|
||||
(->> (get-frames objects options)
|
||||
(mapv :id))))
|
||||
|
||||
(defn get-nested-frames
|
||||
[objects frame-id]
|
||||
|
@ -228,24 +233,27 @@
|
|||
(sort comp ids))))
|
||||
|
||||
(defn frame-id-by-position
|
||||
[objects position]
|
||||
(assert (gpt/point? position))
|
||||
(let [top-frame
|
||||
(->> (get-frames-ids objects)
|
||||
(sort-z-index objects)
|
||||
(d/seek #(and position (gsh/has-point? (get objects %) position))))]
|
||||
(or top-frame uuid/zero)))
|
||||
([objects position] (frame-id-by-position objects position nil))
|
||||
([objects position options]
|
||||
(assert (gpt/point? position))
|
||||
(let [top-frame
|
||||
(->> (get-frames-ids objects options)
|
||||
(sort-z-index objects)
|
||||
(d/seek #(and position (gsh/has-point? (get objects %) position))))]
|
||||
(or top-frame uuid/zero))))
|
||||
|
||||
(defn frame-by-position
|
||||
[objects position]
|
||||
(let [frame-id (frame-id-by-position objects position)]
|
||||
(get objects frame-id)))
|
||||
([objects position] (frame-by-position objects position nil))
|
||||
([objects position options]
|
||||
(let [frame-id (frame-id-by-position objects position options)]
|
||||
(get objects frame-id))))
|
||||
|
||||
(defn all-frames-by-position
|
||||
[objects position]
|
||||
(->> (get-frames-ids objects)
|
||||
(filter #(and position (gsh/has-point? (get objects %) position)))
|
||||
(sort-z-index objects)))
|
||||
([objects position] (all-frames-by-position objects position nil))
|
||||
([objects position options]
|
||||
(->> (get-frames-ids objects options)
|
||||
(filter #(and position (gsh/has-point? (get objects %) position)))
|
||||
(sort-z-index objects))))
|
||||
|
||||
(defn top-nested-frame
|
||||
"Search for the top nested frame for positioning shapes when moving or creating.
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
components-v2)
|
||||
|
||||
changes (cond-> (pcb/add-object changes (first new-shapes) {:ignore-touched true})
|
||||
(some? old-id) (pcb/amend-last-change #(assoc % :old-id old-id))) ; on copy/paste old id is used later to reorder the paster layers
|
||||
(some? old-id) (pcb/amend-last-change #(assoc % :old-id old-id))) ; on copy/paste old id is used later to reorder the paster layers
|
||||
|
||||
changes (reduce #(pcb/add-object %1 %2 {:ignore-touched true})
|
||||
changes
|
||||
|
|
|
@ -152,7 +152,8 @@
|
|||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
changes (pcb/empty-changes it page-id)
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects))
|
||||
changes (prepare-move-shapes-into-frame changes
|
||||
frame-id
|
||||
shapes
|
||||
|
|
|
@ -179,8 +179,10 @@
|
|||
|
||||
modifiers
|
||||
(-> (ctm/empty)
|
||||
|
||||
(cond-> displacement
|
||||
(ctm/move displacement))
|
||||
|
||||
(ctm/resize scalev resize-origin shape-transform shape-transform-inverse)
|
||||
|
||||
(cond-> set-fix-width?
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns frontend-tests.helpers.pages
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
|
@ -15,6 +16,7 @@
|
|||
[app.main.data.workspace.groups :as dwg]
|
||||
[app.main.data.workspace.layout :as layout]
|
||||
[app.main.data.workspace.libraries-helpers :as dwlh]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.state-helpers :as wsh]))
|
||||
|
||||
;; ---- Helpers to manage pages and objects
|
||||
|
@ -102,6 +104,28 @@
|
|||
(update state :workspace-data
|
||||
cp/process-changes (:redo-changes changes)))))))
|
||||
|
||||
(defn frame-shapes
|
||||
([state label ids] (frame-shapes state label ids "Board"))
|
||||
([state label ids frame-name]
|
||||
(let [page (current-page state)
|
||||
shapes (dwg/shapes-for-grouping (:objects page) ids)
|
||||
changes (pcb/empty-changes nil (:id page))]
|
||||
(if (empty? shapes)
|
||||
state
|
||||
(let [[frame changes]
|
||||
(dwsh/prepare-create-artboard-from-selection changes
|
||||
nil
|
||||
nil
|
||||
(:objects page)
|
||||
(map :id shapes)
|
||||
nil
|
||||
frame-name
|
||||
true)]
|
||||
|
||||
(swap! idmap assoc label (:id frame))
|
||||
(update state :workspace-data
|
||||
cp/process-changes (:redo-changes changes)))))))
|
||||
|
||||
(defn make-component
|
||||
[state instance-label component-label shape-ids]
|
||||
(let [page (current-page state)
|
||||
|
@ -115,7 +139,8 @@
|
|||
(:id page)
|
||||
current-file-id
|
||||
true
|
||||
dwg/prepare-create-group)]
|
||||
dwg/prepare-create-group
|
||||
dwsh/prepare-create-artboard-from-selection)]
|
||||
|
||||
(swap! idmap assoc instance-label (:id group)
|
||||
component-label component-id)
|
||||
|
|
|
@ -6,17 +6,18 @@
|
|||
|
||||
(ns frontend-tests.state-components-sync-test
|
||||
(:require
|
||||
[app.common.colors :as clr]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.events :as the]
|
||||
[frontend-tests.helpers.libraries :as thl]
|
||||
[frontend-tests.helpers.pages :as thp]
|
||||
[potok.core :as ptk]))
|
||||
[app.common.colors :as clr]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.events :as the]
|
||||
[frontend-tests.helpers.libraries :as thl]
|
||||
[frontend-tests.helpers.pages :as thp]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(t/use-fixtures :each
|
||||
{:before thp/reset-idmap!})
|
||||
|
@ -41,6 +42,11 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
;; Uncomment to debug
|
||||
;; (ctf/dump-tree (get new-state :workspace-data)
|
||||
;; (get new-state :current-page-id)
|
||||
;; (get new-state :workspace-libraries)
|
||||
;; false true)
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
|
@ -355,11 +361,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :main2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -396,7 +402,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -409,7 +415,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/white))
|
||||
(t/is (= (:fill-opacity shape2) 1))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -446,11 +452,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :instance2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -487,7 +493,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -500,7 +506,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/test))
|
||||
(t/is (= (:fill-opacity shape2) 0.5))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -537,11 +543,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :instance2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -578,7 +584,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -591,7 +597,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/test))
|
||||
(t/is (= (:fill-opacity shape2) 0.5))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -943,11 +949,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :main2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -983,7 +989,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -996,7 +1002,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/white))
|
||||
(t/is (= (:fill-opacity shape2) 1))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -1034,11 +1040,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :instance2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -1074,7 +1080,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -1087,7 +1093,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/white))
|
||||
(t/is (= (:fill-opacity shape2) 1))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -1126,11 +1132,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :instance2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2)))
|
||||
|
||||
|
@ -1169,7 +1175,7 @@
|
|||
new-state
|
||||
(thp/id :instance2))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -1182,7 +1188,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/white))
|
||||
(t/is (= (:fill-opacity shape2) 1))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -1929,11 +1935,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :main2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2))
|
||||
(thp/instantiate-component :instance3
|
||||
|
@ -1983,7 +1989,7 @@
|
|||
new-state
|
||||
(thp/id :instance3))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -1996,7 +2002,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/white))
|
||||
(t/is (= (:fill-opacity shape2) 1))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -2009,7 +2015,7 @@
|
|||
(t/is (= (:fill-color c-shape2) clr/white))
|
||||
(t/is (= (:fill-opacity c-shape2) 1))
|
||||
|
||||
(t/is (= (:name instance4) "Group"))
|
||||
(t/is (= (:name instance4) "Board"))
|
||||
(t/is (= (:touched instance4) nil))
|
||||
(t/is (= (:name instance3) "Rect 1"))
|
||||
(t/is (= (:touched instance3) nil))
|
||||
|
@ -2047,11 +2053,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :main2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2))
|
||||
(thp/instantiate-component :instance3
|
||||
|
@ -2101,7 +2107,7 @@
|
|||
new-state
|
||||
(thp/id :instance3))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -2114,7 +2120,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/test))
|
||||
(t/is (= (:fill-opacity shape2) 0.5))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -2127,7 +2133,7 @@
|
|||
(t/is (= (:fill-color c-shape2) clr/test))
|
||||
(t/is (= (:fill-opacity c-shape2) 0.5))
|
||||
|
||||
(t/is (= (:name instance4) "Group"))
|
||||
(t/is (= (:name instance4) "Board"))
|
||||
(t/is (= (:touched instance4) nil))
|
||||
(t/is (= (:name instance3) "Rect 1"))
|
||||
(t/is (= (:touched instance3) nil))
|
||||
|
@ -2166,11 +2172,11 @@
|
|||
{:name "Circle 1"
|
||||
:fill-color clr/black
|
||||
:fill-opacity 0})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :instance1)
|
||||
(thp/id :shape2)])
|
||||
(thp/make-component :main2 :component2
|
||||
[(thp/id :group1)])
|
||||
[(thp/id :frame1)])
|
||||
(thp/instantiate-component :instance2
|
||||
(thp/id :component2))
|
||||
(thp/instantiate-component :instance3
|
||||
|
@ -2222,7 +2228,7 @@
|
|||
new-state
|
||||
(thp/id :instance3))]
|
||||
|
||||
(t/is (= (:name instance2) "Group"))
|
||||
(t/is (= (:name instance2) "Board"))
|
||||
(t/is (= (:touched instance2) nil))
|
||||
(t/is (= (:name instance1) "Rect 1"))
|
||||
(t/is (= (:touched instance1) nil))
|
||||
|
@ -2235,7 +2241,7 @@
|
|||
(t/is (= (:fill-color shape2) clr/test))
|
||||
(t/is (= (:fill-opacity shape2) 0.5))
|
||||
|
||||
(t/is (= (:name c-instance2) "Group"))
|
||||
(t/is (= (:name c-instance2) "Board"))
|
||||
(t/is (= (:touched c-instance2) nil))
|
||||
(t/is (= (:name c-instance1) "Rect 1"))
|
||||
(t/is (= (:touched c-instance1) nil))
|
||||
|
@ -2248,7 +2254,7 @@
|
|||
(t/is (= (:fill-color c-shape2) clr/test))
|
||||
(t/is (= (:fill-opacity c-shape2) 0.5))
|
||||
|
||||
(t/is (= (:name instance4) "Group"))
|
||||
(t/is (= (:name instance4) "Board"))
|
||||
(t/is (= (:touched instance4) nil))
|
||||
(t/is (= (:name instance3) "Rect 1"))
|
||||
(t/is (= (:touched instance3) nil))
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
[app.common.types.container :as ctn]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.groups :as dwg]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.events :as the]
|
||||
|
@ -119,7 +119,7 @@
|
|||
(dwl/add-component)
|
||||
:the/end))))
|
||||
|
||||
(t/deftest test-add-component-from-group
|
||||
(t/deftest test-add-component-from-frame
|
||||
(t/async
|
||||
done
|
||||
(let [state (-> thp/initial-state
|
||||
|
@ -128,7 +128,7 @@
|
|||
{:name "Rect 1"})
|
||||
(thp/sample-shape :shape2 :rect
|
||||
{:name "Rect-2"})
|
||||
(thp/group-shapes :group1
|
||||
(thp/frame-shapes :frame1
|
||||
[(thp/id :shape1)
|
||||
(thp/id :shape2)]))
|
||||
|
||||
|
@ -150,23 +150,23 @@
|
|||
component]
|
||||
(thl/resolve-instance-and-main
|
||||
new-state
|
||||
(thp/id :group1))
|
||||
(thp/id :frame1))
|
||||
|
||||
file (wsh/get-local-file new-state)]
|
||||
|
||||
(t/is (= (:name shape1) "Rect 1"))
|
||||
(t/is (= (:name shape2) "Rect-2"))
|
||||
(t/is (= (:name group) "Group"))
|
||||
(t/is (= (:name component) "Group"))
|
||||
(t/is (= (:name group) "Board"))
|
||||
(t/is (= (:name component) "Board"))
|
||||
(t/is (= (:name c-shape1) "Rect 1"))
|
||||
(t/is (= (:name c-shape2) "Rect-2"))
|
||||
(t/is (= (:name c-group) "Group"))
|
||||
(t/is (= (:name c-group) "Board"))
|
||||
|
||||
(thl/is-from-file group file))))]
|
||||
|
||||
(ptk/emit!
|
||||
store
|
||||
(dw/select-shape (thp/id :group1))
|
||||
(dw/select-shape (thp/id :frame1))
|
||||
(dwl/add-component)
|
||||
:the/end))))
|
||||
|
||||
|
@ -621,11 +621,11 @@
|
|||
new-state
|
||||
(:parent-id parent1))]
|
||||
|
||||
(t/is (= (:name group) "Group"))
|
||||
(t/is (= (:name group) "Board"))
|
||||
(t/is (= (:name shape1) "Rect 1"))
|
||||
(t/is (= (:name shape2) "Rect 1"))
|
||||
(t/is (= (:name component) "Group"))
|
||||
(t/is (= (:name c-group) "Group"))
|
||||
(t/is (= (:name component) "Board"))
|
||||
(t/is (= (:name c-group) "Board"))
|
||||
(t/is (= (:name c-shape1) "Rect 1"))
|
||||
(t/is (= (:name c-shape2) "Rect 1")))))]
|
||||
|
||||
|
@ -633,7 +633,7 @@
|
|||
store
|
||||
(dw/select-shape (thp/id :shape1))
|
||||
(dwl/add-component)
|
||||
dwg/group-selected
|
||||
(dwsh/create-artboard-from-selection)
|
||||
(dwl/add-component)
|
||||
:the/end))))
|
||||
|
||||
|
@ -740,10 +740,10 @@
|
|||
new-state
|
||||
(:parent-id instance1))]
|
||||
|
||||
(t/is (= (:name group1) "Group"))
|
||||
(t/is (= (:name group1) "Board"))
|
||||
(t/is (= (:name shape1) "Rect 1"))
|
||||
(t/is (= (:name shape2) "Rect 1"))
|
||||
(t/is (= (:name c-group1) "Group"))
|
||||
(t/is (= (:name c-group1) "Board"))
|
||||
(t/is (= (:name c-shape1) "Rect 1"))
|
||||
(t/is (= (:name c-shape2) "Rect 1"))
|
||||
(t/is (= (:component-file group1) thp/current-file-id))
|
||||
|
@ -756,6 +756,6 @@
|
|||
(ptk/emit!
|
||||
store
|
||||
(dw/select-shape (thp/id :instance1))
|
||||
dwg/group-selected
|
||||
(dwsh/create-artboard-from-selection)
|
||||
(dwl/add-component)
|
||||
:the/end))))
|
||||
|
|
Loading…
Add table
Reference in a new issue