mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
🎉 Update tests
This commit is contained in:
parent
0711fa700b
commit
b91f1959b4
4 changed files with 2289 additions and 2022 deletions
|
@ -9,6 +9,7 @@
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.container :as ctn]
|
[app.common.types.container :as ctn]
|
||||||
|
[app.common.types.file :as ctf]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[cljs.pprint :refer [pprint]]
|
[cljs.pprint :refer [pprint]]
|
||||||
[cljs.test :as t :include-macros true]
|
[cljs.test :as t :include-macros true]
|
||||||
|
@ -16,6 +17,29 @@
|
||||||
|
|
||||||
;; ---- Helpers to manage libraries and synchronization
|
;; ---- Helpers to manage libraries and synchronization
|
||||||
|
|
||||||
|
(defn is-main-instance-root
|
||||||
|
[shape]
|
||||||
|
(t/is (nil? (:shape-ref shape)))
|
||||||
|
(t/is (some? (:component-id shape)))
|
||||||
|
(t/is (= (:component-root? shape) true)))
|
||||||
|
|
||||||
|
(defn is-main-instance-subroot
|
||||||
|
[shape]
|
||||||
|
(t/is (some? (:component-id shape))) ; shape-ref may or may be not nil
|
||||||
|
(t/is (= (:component-root? shape) true)))
|
||||||
|
|
||||||
|
(defn is-main-instance-child
|
||||||
|
[shape]
|
||||||
|
(t/is (nil? (:component-id shape))) ; shape-ref may or may be not nil
|
||||||
|
(t/is (nil? (:component-file shape)))
|
||||||
|
(t/is (nil? (:component-root? shape))))
|
||||||
|
|
||||||
|
(defn is-main-instance-inner
|
||||||
|
[shape]
|
||||||
|
(if (some? (:component-id shape))
|
||||||
|
(is-main-instance-subroot shape)
|
||||||
|
(is-main-instance-child shape)))
|
||||||
|
|
||||||
(defn is-instance-root
|
(defn is-instance-root
|
||||||
[shape]
|
[shape]
|
||||||
(t/is (some? (:shape-ref shape)))
|
(t/is (some? (:shape-ref shape)))
|
||||||
|
@ -58,27 +82,25 @@
|
||||||
(defn resolve-instance
|
(defn resolve-instance
|
||||||
"Get the shape with the given id and all its children, and
|
"Get the shape with the given id and all its children, and
|
||||||
verify that they are a well constructed instance tree."
|
verify that they are a well constructed instance tree."
|
||||||
[state root-inst-id]
|
[state root-id]
|
||||||
(let [page (thp/current-page state)
|
(let [page (thp/current-page state)
|
||||||
root-inst (ctn/get-shape page root-inst-id)
|
shapes (cph/get-children-with-self (:objects page)
|
||||||
shapes-inst (cph/get-children-with-self (:objects page)
|
root-id)]
|
||||||
root-inst-id)]
|
(is-instance-root (first shapes))
|
||||||
(is-instance-root (first shapes-inst))
|
(run! is-instance-inner (rest shapes))
|
||||||
(run! is-instance-inner (rest shapes-inst))
|
|
||||||
|
|
||||||
shapes-inst))
|
shapes))
|
||||||
|
|
||||||
(defn resolve-noninstance
|
(defn resolve-noninstance
|
||||||
"Get the shape with the given id and all its children, and
|
"Get the shape with the given id and all its children, and
|
||||||
verify that they are not a component instance."
|
verify that they are not a component instance."
|
||||||
[state root-inst-id]
|
[state root-id]
|
||||||
(let [page (thp/current-page state)
|
(let [page (thp/current-page state)
|
||||||
root-inst (ctn/get-shape page root-inst-id)
|
shapes (cph/get-children-with-self (:objects page)
|
||||||
shapes-inst (cph/get-children-with-self (:objects page)
|
root-id)]
|
||||||
root-inst-id)]
|
(run! is-noninstance shapes)
|
||||||
(run! is-noninstance shapes-inst)
|
|
||||||
|
|
||||||
shapes-inst))
|
shapes))
|
||||||
|
|
||||||
(defn resolve-instance-and-main
|
(defn resolve-instance-and-main
|
||||||
"Get the shape with the given id and all its children, and also
|
"Get the shape with the given id and all its children, and also
|
||||||
|
@ -87,38 +109,39 @@
|
||||||
(resolve-instance-and-main state root-inst-id false))
|
(resolve-instance-and-main state root-inst-id false))
|
||||||
|
|
||||||
([state root-inst-id subinstance?]
|
([state root-inst-id subinstance?]
|
||||||
(let [page (thp/current-page state)
|
(let [page (thp/current-page state)
|
||||||
root-inst (ctn/get-shape page root-inst-id)
|
root-inst (ctn/get-shape page root-inst-id)
|
||||||
|
main-instance? (:main-instance? root-inst)
|
||||||
|
|
||||||
libs (wsh/get-libraries state)
|
libs (wsh/get-libraries state)
|
||||||
component (cph/get-component libs (:component-id root-inst))
|
component (ctf/get-component libs (:component-id root-inst))
|
||||||
|
library (ctf/get-component-library libs root-inst)
|
||||||
|
|
||||||
shapes-inst (cph/get-children-with-self (:objects page) root-inst-id)
|
shapes-inst (cph/get-children-with-self (:objects page) root-inst-id)
|
||||||
shapes-main (cph/get-children-with-self (:objects component) (:shape-ref root-inst))
|
shapes-main (ctf/get-component-shapes (:data library) component)
|
||||||
|
unique-refs (into #{} (map :shape-ref) shapes-inst)
|
||||||
unique-refs (into #{} (map :shape-ref) shapes-inst)
|
|
||||||
|
|
||||||
main-exists? (fn [shape]
|
main-exists? (fn [shape]
|
||||||
(let [component-shape
|
(let [main-shape (ctf/get-ref-shape (:data library) component shape)]
|
||||||
(cph/get-component-shape (:objects page) shape)
|
|
||||||
|
|
||||||
component
|
|
||||||
(cph/get-component libs (:component-id component-shape))
|
|
||||||
|
|
||||||
main-shape
|
|
||||||
(ctn/get-shape component (:shape-ref shape))]
|
|
||||||
|
|
||||||
(t/is (some? main-shape))))]
|
(t/is (some? main-shape))))]
|
||||||
|
|
||||||
;; Validate that the instance tree is well constructed
|
;; Validate that the instance tree is well constructed
|
||||||
(if subinstance?
|
(if main-instance?
|
||||||
(is-instance-subroot (first shapes-inst))
|
(do
|
||||||
(is-instance-root (first shapes-inst)))
|
(if subinstance?
|
||||||
(run! is-instance-inner (rest shapes-inst))
|
(is-main-instance-subroot (first shapes-inst))
|
||||||
(t/is (= (count shapes-inst)
|
(is-main-instance-root (first shapes-inst)))
|
||||||
(count shapes-main)
|
(run! is-main-instance-inner (rest shapes-inst)))
|
||||||
(count unique-refs)))
|
(do
|
||||||
(run! main-exists? shapes-inst)
|
(if subinstance?
|
||||||
|
(is-instance-subroot (first shapes-inst))
|
||||||
|
(is-instance-root (first shapes-inst)))
|
||||||
|
(run! is-instance-inner (rest shapes-inst))))
|
||||||
|
|
||||||
|
(t/is (= (count shapes-inst) (count shapes-main)))
|
||||||
|
(when-not main-instance?
|
||||||
|
(t/is (= (count shapes-inst) (count unique-refs)))
|
||||||
|
(run! main-exists? shapes-inst))
|
||||||
|
|
||||||
[shapes-inst shapes-main component])))
|
[shapes-inst shapes-main component])))
|
||||||
|
|
||||||
|
@ -131,24 +154,11 @@
|
||||||
root-inst (ctn/get-shape page root-inst-id)
|
root-inst (ctn/get-shape page root-inst-id)
|
||||||
|
|
||||||
libs (wsh/get-libraries state)
|
libs (wsh/get-libraries state)
|
||||||
component (cph/get-component libs (:component-id root-inst))
|
component (ctf/get-component libs (:component-id root-inst))
|
||||||
|
library (ctf/get-component-library libs root-inst)
|
||||||
|
|
||||||
shapes-inst (cph/get-children-with-self (:objects page) root-inst-id)
|
shapes-inst (cph/get-children-with-self (:objects page) root-inst-id)
|
||||||
shapes-main (cph/get-children-with-self (:objects component) (:shape-ref root-inst))
|
shapes-main (ctf/get-component-shapes (:data library) component)]
|
||||||
|
|
||||||
unique-refs (into #{} (map :shape-ref) shapes-inst)
|
|
||||||
|
|
||||||
main-exists? (fn [shape]
|
|
||||||
(let [component-shape
|
|
||||||
(cph/get-component-shape (:objects page) shape)
|
|
||||||
|
|
||||||
component
|
|
||||||
(cph/get-component libs (:component-id component-shape))
|
|
||||||
|
|
||||||
main-shape
|
|
||||||
(ctn/get-shape component (:shape-ref shape))]
|
|
||||||
|
|
||||||
(t/is (some? main-shape))))]
|
|
||||||
|
|
||||||
;; Validate that the instance tree is well constructed
|
;; Validate that the instance tree is well constructed
|
||||||
(is-instance-root (first shapes-inst))
|
(is-instance-root (first shapes-inst))
|
||||||
|
@ -158,14 +168,12 @@
|
||||||
(defn resolve-component
|
(defn resolve-component
|
||||||
"Get the component with the given id and all its shapes."
|
"Get the component with the given id and all its shapes."
|
||||||
[state component-id]
|
[state component-id]
|
||||||
(let [page (thp/current-page state)
|
(let [libs (wsh/get-libraries state)
|
||||||
libs (wsh/get-libraries state)
|
component (ctf/get-component libs component-id)
|
||||||
component (cph/get-component libs component-id)
|
library (ctf/get-component-library libs component)
|
||||||
root-main (ctk/get-component-root component)
|
shapes-main (ctf/get-component-shapes (:data library) component)]
|
||||||
shapes-main (cph/get-children-with-self (:objects component) (:id root-main))]
|
|
||||||
|
|
||||||
;; Validate that the component tree is well constructed
|
;; Validate that the component tree is well constructed
|
||||||
(run! is-noninstance shapes-main)
|
(run! is-noninstance shapes-main)
|
||||||
|
|
||||||
[shapes-main component]))
|
[shapes-main component]))
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,14 @@
|
||||||
(ns frontend-tests.helpers.pages
|
(ns frontend-tests.helpers.pages
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace :as dw]
|
|
||||||
[app.main.data.workspace.groups :as dwg]
|
[app.main.data.workspace.groups :as dwg]
|
||||||
[app.main.data.workspace.layout :as layout]
|
[app.main.data.workspace.layout :as layout]
|
||||||
[app.main.data.workspace.libraries-helpers :as dwlh]
|
[app.main.data.workspace.libraries-helpers :as dwlh]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]))
|
||||||
[beicon.core :as rx]
|
|
||||||
[cljs.pprint :refer [pprint]]
|
|
||||||
[cljs.test :as t :include-macros true]
|
|
||||||
[potok.core :as ptk]))
|
|
||||||
|
|
||||||
;; ---- Helpers to manage pages and objects
|
;; ---- Helpers to manage pages and objects
|
||||||
|
|
||||||
|
@ -32,10 +26,12 @@
|
||||||
:workspace-layout layout/default-layout
|
:workspace-layout layout/default-layout
|
||||||
:workspace-global layout/default-global
|
:workspace-global layout/default-global
|
||||||
:workspace-data {:id current-file-id
|
:workspace-data {:id current-file-id
|
||||||
|
:options {:components-v2 true}
|
||||||
:components {}
|
:components {}
|
||||||
:pages []
|
:pages []
|
||||||
:pages-index {}}
|
:pages-index {}}
|
||||||
:workspace-libraries {}})
|
:workspace-libraries {}
|
||||||
|
:features {:components-v2 true}})
|
||||||
|
|
||||||
(def ^:private idmap (atom {}))
|
(def ^:private idmap (atom {}))
|
||||||
|
|
||||||
|
@ -56,6 +52,11 @@
|
||||||
(let [page (current-page state)]
|
(let [page (current-page state)]
|
||||||
(get-in page [:objects (id label)])))
|
(get-in page [:objects (id label)])))
|
||||||
|
|
||||||
|
(defn get-children
|
||||||
|
[state label]
|
||||||
|
(let [page (current-page state)]
|
||||||
|
(cph/get-children (:objects page) (id label))))
|
||||||
|
|
||||||
(defn sample-page
|
(defn sample-page
|
||||||
([state] (sample-page state {}))
|
([state] (sample-page state {}))
|
||||||
([state {:keys [id name] :as props
|
([state {:keys [id name] :as props
|
||||||
|
@ -106,7 +107,7 @@
|
||||||
objects (wsh/lookup-page-objects state (:id page))
|
objects (wsh/lookup-page-objects state (:id page))
|
||||||
shapes (dwg/shapes-for-grouping objects shape-ids)
|
shapes (dwg/shapes-for-grouping objects shape-ids)
|
||||||
|
|
||||||
[group component-root changes]
|
[group component-id changes]
|
||||||
(dwlh/generate-add-component nil
|
(dwlh/generate-add-component nil
|
||||||
shapes
|
shapes
|
||||||
(:objects page)
|
(:objects page)
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
true)]
|
true)]
|
||||||
|
|
||||||
(swap! idmap assoc instance-label (:id group)
|
(swap! idmap assoc instance-label (:id group)
|
||||||
component-label (:id component-root))
|
component-label component-id)
|
||||||
(update state :workspace-data
|
(update state :workspace-data
|
||||||
cp/process-changes (:redo-changes changes))))
|
cp/process-changes (:redo-changes changes))))
|
||||||
|
|
||||||
|
@ -148,7 +149,9 @@
|
||||||
assoc library-id {:id library-id
|
assoc library-id {:id library-id
|
||||||
:name name
|
:name name
|
||||||
:data {:id library-id
|
:data {:id library-id
|
||||||
|
:options (:options data)
|
||||||
|
:pages (:pages data)
|
||||||
|
:pages-index (:pages-index data)
|
||||||
:components (:components data)}})
|
:components (:components data)}})
|
||||||
(update :workspace-data
|
(update :workspace-data
|
||||||
assoc :components {} :pages [] :pages-index {}))))
|
assoc :components {} :pages [] :pages-index {}))))
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,18 @@
|
||||||
(ns frontend-tests.state-components-test
|
(ns frontend-tests.state-components-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.types.container :as ctn]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.container :as ctn]
|
[app.main.data.workspace :as dw]
|
||||||
[app.common.types.file :as ctf]
|
[app.main.data.workspace.groups :as dwg]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.groups :as dwg]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[cljs.test :as t :include-macros true]
|
||||||
[app.main.data.workspace.libraries-helpers :as dwlh]
|
[frontend-tests.helpers.events :as the]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[frontend-tests.helpers.libraries :as thl]
|
||||||
[beicon.core :as rx]
|
[frontend-tests.helpers.pages :as thp]
|
||||||
[cljs.pprint :refer [pprint]]
|
[linked.core :as lks]
|
||||||
[cljs.test :as t :include-macros true]
|
[potok.core :as ptk]))
|
||||||
[clojure.stacktrace :as stk]
|
|
||||||
[frontend-tests.helpers.events :as the]
|
|
||||||
[frontend-tests.helpers.libraries :as thl]
|
|
||||||
[frontend-tests.helpers.pages :as thp]
|
|
||||||
[linked.core :as lks]
|
|
||||||
[potok.core :as ptk]))
|
|
||||||
|
|
||||||
(t/use-fixtures :each
|
(t/use-fixtures :each
|
||||||
{:before thp/reset-idmap!})
|
{:before thp/reset-idmap!})
|
||||||
|
@ -37,7 +31,8 @@
|
||||||
;; Uncomment to debug
|
;; Uncomment to debug
|
||||||
;; (ctf/dump-tree (get new-state :workspace-data)
|
;; (ctf/dump-tree (get new-state :workspace-data)
|
||||||
;; (get new-state :current-page-id)
|
;; (get new-state :current-page-id)
|
||||||
;; (get new-state :workspace-libraries))
|
;; (get new-state :workspace-libraries)
|
||||||
|
;; false true)
|
||||||
|
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
|
@ -54,8 +49,8 @@
|
||||||
|
|
||||||
[[group shape1] [c-group c-shape1] component]
|
[[group shape1] [c-group c-shape1] component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(:parent-id shape1))
|
(:parent-id shape1))
|
||||||
|
|
||||||
file (wsh/get-local-file new-state)]
|
file (wsh/get-local-file new-state)]
|
||||||
|
|
||||||
|
@ -73,40 +68,6 @@
|
||||||
(dwl/add-component)
|
(dwl/add-component)
|
||||||
:the/end)))))
|
:the/end)))))
|
||||||
|
|
||||||
;; Remove definitely when we ensure that the other method works
|
|
||||||
;; well in more advanced tests.
|
|
||||||
#_(t/deftest test-add-component-from-single-shape
|
|
||||||
(t/async
|
|
||||||
done
|
|
||||||
(let [state (-> thp/initial-state
|
|
||||||
(thp/sample-page)
|
|
||||||
(thp/sample-shape :shape1 :rect
|
|
||||||
{:name "Rect 1"}))]
|
|
||||||
|
|
||||||
(->> state
|
|
||||||
(the/do-update (dw/select-shape (thp/id :shape1)))
|
|
||||||
(the/do-watch-update dwl/add-component)
|
|
||||||
(rx/do
|
|
||||||
(fn [new-state]
|
|
||||||
(let [shape1 (thp/get-shape new-state :shape1)
|
|
||||||
|
|
||||||
[[group shape1] [c-group c-shape1] component]
|
|
||||||
(thl/resolve-instance-and-main
|
|
||||||
new-state
|
|
||||||
(:parent-id shape1))
|
|
||||||
|
|
||||||
file (wsh/get-local-file new-state)]
|
|
||||||
|
|
||||||
(t/is (= (:name shape1) "Rect 1"))
|
|
||||||
(t/is (= (:name group) "Component 1"))
|
|
||||||
(t/is (= (:name component) "Component 1"))
|
|
||||||
(t/is (= (:name c-shape1) "Rect 1"))
|
|
||||||
(t/is (= (:name c-group) "Component 1"))
|
|
||||||
|
|
||||||
(thl/is-from-file group file))))
|
|
||||||
|
|
||||||
(rx/subs done #(throw %))))))
|
|
||||||
|
|
||||||
(t/deftest test-add-component-from-several-shapes
|
(t/deftest test-add-component-from-several-shapes
|
||||||
(t/async
|
(t/async
|
||||||
done
|
done
|
||||||
|
@ -120,17 +81,14 @@
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
; [Page]
|
||||||
; [Page]
|
; Root Frame
|
||||||
; Root Frame
|
; Component 1
|
||||||
; Component 1 #--> Component 1
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect-2
|
||||||
; Rect-2 ---> Rect-2
|
;
|
||||||
;
|
; [Component 1]
|
||||||
; [Component 1]
|
; page1 / Component 1
|
||||||
; Component 1
|
|
||||||
; Rect 1
|
|
||||||
; Rect-2
|
|
||||||
;
|
;
|
||||||
(let [shape1 (thp/get-shape new-state :shape1)
|
(let [shape1 (thp/get-shape new-state :shape1)
|
||||||
|
|
||||||
|
@ -138,8 +96,8 @@
|
||||||
[c-group c-shape1 c-shape2]
|
[c-group c-shape1 c-shape2]
|
||||||
component]
|
component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(:parent-id shape1))
|
(:parent-id shape1))
|
||||||
|
|
||||||
file (wsh/get-local-file new-state)]
|
file (wsh/get-local-file new-state)]
|
||||||
|
|
||||||
|
@ -174,38 +132,36 @@
|
||||||
(thp/id :shape2)]))
|
(thp/id :shape2)]))
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Group #--> Group
|
; Group
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
; Rect-2 ---> Rect-2
|
; Rect-2
|
||||||
|
;
|
||||||
|
; [Group]
|
||||||
|
; page1 / Group
|
||||||
;
|
;
|
||||||
; [Group]
|
(let [[[group shape1 shape2]
|
||||||
; Group
|
[c-group c-shape1 c-shape2]
|
||||||
; Rect 1
|
component]
|
||||||
; Rect-2
|
(thl/resolve-instance-and-main
|
||||||
;
|
new-state
|
||||||
(let [[[group shape1 shape2]
|
(thp/id :group1))
|
||||||
[c-group c-shape1 c-shape2]
|
|
||||||
component]
|
|
||||||
(thl/resolve-instance-and-main
|
|
||||||
new-state
|
|
||||||
(thp/id :group1))
|
|
||||||
|
|
||||||
file (wsh/get-local-file new-state)]
|
file (wsh/get-local-file new-state)]
|
||||||
|
|
||||||
(t/is (= (:name shape1) "Rect 1"))
|
(t/is (= (:name shape1) "Rect 1"))
|
||||||
(t/is (= (:name shape2) "Rect-2"))
|
(t/is (= (:name shape2) "Rect-2"))
|
||||||
(t/is (= (:name group) "Group"))
|
(t/is (= (:name group) "Group"))
|
||||||
(t/is (= (:name component) "Group"))
|
(t/is (= (:name component) "Group"))
|
||||||
(t/is (= (:name c-shape1) "Rect 1"))
|
(t/is (= (:name c-shape1) "Rect 1"))
|
||||||
(t/is (= (:name c-shape2) "Rect-2"))
|
(t/is (= (:name c-shape2) "Rect-2"))
|
||||||
(t/is (= (:name c-group) "Group"))
|
(t/is (= (:name c-group) "Group"))
|
||||||
|
|
||||||
(thl/is-from-file group file))))]
|
(thl/is-from-file group file))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
@ -220,42 +176,39 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)]))
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect 1 #--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 @--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
;
|
;
|
||||||
; [Rect 1]
|
; [Rect 1]
|
||||||
; Rect 1
|
; page1 / Rect 1
|
||||||
; Rect 1
|
;
|
||||||
;
|
; [Rect 1]
|
||||||
; [Rect 1]
|
; page1 / Rect 1
|
||||||
; Rect 1
|
|
||||||
; Rect 1 @--> Rect 1
|
|
||||||
; Rect 1 ---> Rect 1
|
|
||||||
;
|
;
|
||||||
(let [[[instance1 shape1]
|
(let [[[instance1 shape1]
|
||||||
[c-instance1 c-shape1]
|
[c-instance1 c-shape1]
|
||||||
component1]
|
component1]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(thp/id :instance1)
|
(thp/id :main1)
|
||||||
true)
|
true)
|
||||||
|
|
||||||
[[instance2 instance1' shape1']
|
[[instance2 instance1' shape1']
|
||||||
[c-instance2 c-instance1' c-shape1']
|
[c-instance2 c-instance1' c-shape1']
|
||||||
component2]
|
component2]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(:parent-id instance1))]
|
(:parent-id instance1))]
|
||||||
|
|
||||||
(t/is (= (:name shape1) "Rect 1"))
|
(t/is (= (:name shape1) "Rect 1"))
|
||||||
(t/is (= (:name instance1) "Rect 1"))
|
(t/is (= (:name instance1) "Rect 1"))
|
||||||
|
@ -273,7 +226,7 @@
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
(dw/select-shape (thp/id :instance1))
|
(dw/select-shape (thp/id :main1))
|
||||||
(dwl/add-component)
|
(dwl/add-component)
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
||||||
|
@ -284,34 +237,34 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)]))
|
||||||
|
|
||||||
instance1 (thp/get-shape state :instance1)
|
main1 (thp/get-shape state :main1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect-2 #--> Renamed component
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
;
|
;
|
||||||
; [Renamed]
|
; [Renamed component]
|
||||||
; Renamed component
|
; page1 / Rect 1
|
||||||
; Rect 1
|
;
|
||||||
(let [libs (wsh/get-libraries new-state)
|
(let [libs (wsh/get-libraries new-state)
|
||||||
component (cph/get-component libs
|
component (ctf/get-component libs
|
||||||
(:component-file instance1)
|
(:component-file main1)
|
||||||
(:component-id instance1))]
|
(:component-id main1))]
|
||||||
(t/is (= (:name component)
|
(t/is (= (:name component)
|
||||||
"Renamed component")))))]
|
"Renamed component")))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
(dwl/rename-component (:component-id instance1) "Renamed component")
|
(dwl/rename-component (:component-id main1) "Renamed component")
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
||||||
(t/deftest test-duplicate-component
|
(t/deftest test-duplicate-component
|
||||||
(t/async
|
(t/async
|
||||||
|
@ -320,28 +273,28 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)]))
|
||||||
|
|
||||||
instance1 (thp/get-shape state :instance1)
|
main1 (thp/get-shape state :main1)
|
||||||
component-id (:component-id instance1)
|
component-id (:component-id main1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect 1 #--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
;
|
; Rect 1 #--> Rect 1
|
||||||
|
; Rect 1 ---> Rect 1
|
||||||
|
;
|
||||||
; [Rect 1]
|
; [Rect 1]
|
||||||
; Rect 1
|
; page1 / Rect 1
|
||||||
; Rect 1
|
;
|
||||||
;
|
; [Rect 1]
|
||||||
; [Rect 1]
|
; page1 / Rect 1
|
||||||
; Rect 1
|
|
||||||
; Rect 1
|
|
||||||
;
|
;
|
||||||
(let [new-component-id (->> (get-in new-state
|
(let [new-component-id (->> (get-in new-state
|
||||||
[:workspace-data
|
[:workspace-data
|
||||||
|
@ -354,20 +307,20 @@
|
||||||
[c-instance1 c-shape1]
|
[c-instance1 c-shape1]
|
||||||
component1]
|
component1]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(:id instance1))
|
(:id main1))
|
||||||
|
|
||||||
[[c-component2 c-shape2]
|
[[c-component2 c-shape2]
|
||||||
component2]
|
component2]
|
||||||
(thl/resolve-component
|
(thl/resolve-component
|
||||||
new-state
|
new-state
|
||||||
new-component-id)]
|
new-component-id)]
|
||||||
|
|
||||||
(t/is (= (:name component2) "Rect 1")))))]
|
(t/is (= (:name component2) "Rect 1")))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
(dwl/duplicate-component {:id component-id})
|
(dwl/duplicate-component thp/current-file-id component-id)
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
||||||
(t/deftest test-delete-component
|
(t/deftest test-delete-component
|
||||||
|
@ -377,13 +330,13 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)]))
|
||||||
|
|
||||||
file (wsh/get-local-file state)
|
file (wsh/get-local-file state)
|
||||||
|
|
||||||
instance1 (thp/get-shape state :instance1)
|
main1 (thp/get-shape state :main1)
|
||||||
component-id (:component-id instance1)
|
component-id (:component-id main1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
|
@ -391,21 +344,19 @@
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect-2
|
|
||||||
; Rect 1
|
|
||||||
;
|
;
|
||||||
(let [[instance1 shape1]
|
(let [[main1 shape1]
|
||||||
(thl/resolve-noninstance
|
(thl/resolve-noninstance
|
||||||
new-state
|
new-state
|
||||||
(:id instance1))
|
(:id main1))
|
||||||
|
|
||||||
libs (wsh/get-libraries new-state)
|
libs (wsh/get-libraries new-state)
|
||||||
component (cph/get-component libs
|
component (ctf/get-component libs
|
||||||
(:component-file instance1)
|
(:component-file main1)
|
||||||
(:component-id instance1))]
|
(:component-id main1))]
|
||||||
|
|
||||||
(t/is (some? instance1))
|
(t/is (nil? main1))
|
||||||
(t/is (some? shape1))
|
(t/is (nil? shape1))
|
||||||
(t/is (nil? component)))))]
|
(t/is (nil? component)))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
|
@ -421,46 +372,45 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)]))
|
||||||
|
|
||||||
file (wsh/get-local-file state)
|
file (wsh/get-local-file state)
|
||||||
component-id (thp/id :component-1)
|
component-id (thp/id :component1)
|
||||||
instance1 (thp/get-shape state :instance1)
|
main1 (thp/get-shape state :main1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
|
; Rect 1
|
||||||
|
; Rect 1
|
||||||
; Rect 1 #--> Rect 1
|
; Rect 1 #--> Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1 ---> Rect 1
|
||||||
; Rect 1 #--> Rect 1
|
;
|
||||||
; Rect 1 ---> Rect 1
|
; [Rect 1]
|
||||||
;
|
; page1 / Rect 1
|
||||||
; [Rect 1]
|
|
||||||
; Rect 1
|
|
||||||
; Rect 1
|
|
||||||
;
|
;
|
||||||
(let [new-instance-id (-> new-state
|
(let [new-instance-id (-> new-state
|
||||||
wsh/lookup-selected
|
wsh/lookup-selected
|
||||||
first)
|
first)
|
||||||
|
|
||||||
[[instance2 shape2]
|
[[instance1 shape2]
|
||||||
[c-instance2 c-shape2]
|
[c-instance1 c-shape2]
|
||||||
component]
|
component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
new-instance-id)]
|
new-instance-id)]
|
||||||
|
|
||||||
(t/is (not= (:id instance1) (:id instance2)))
|
(t/is (not= (:id main1) (:id instance1)))
|
||||||
(t/is (= (:id component) component-id))
|
(t/is (= (:id component) component-id))
|
||||||
(t/is (= (:name instance2) "Rect 1"))
|
(t/is (= (:name instance1) "Rect 1"))
|
||||||
(t/is (= (:name shape2) "Rect 1"))
|
(t/is (= (:name shape2) "Rect 1"))
|
||||||
(t/is (= (:name c-instance2) "Rect 1"))
|
(t/is (= (:name c-instance1) "Rect 1"))
|
||||||
(t/is (= (:name c-shape2) "Rect 1"))
|
(t/is (= (:name c-shape2) "Rect 1"))
|
||||||
(t/is (= (:component-file instance2)
|
(t/is (= (:component-file instance1)
|
||||||
thp/current-file-id)))))]
|
thp/current-file-id)))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
|
@ -477,13 +427,13 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)])
|
[(thp/id :shape1)])
|
||||||
(thp/move-to-library :lib1 "Library 1")
|
(thp/move-to-library :lib1 "Library 1")
|
||||||
(thp/sample-page))
|
(thp/sample-page))
|
||||||
|
|
||||||
library-id (thp/id :lib1)
|
library-id (thp/id :lib1)
|
||||||
component-id (thp/id :component-1)
|
component-id (thp/id :component1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
|
@ -498,19 +448,19 @@
|
||||||
wsh/lookup-selected
|
wsh/lookup-selected
|
||||||
first)
|
first)
|
||||||
|
|
||||||
[[instance2 shape2]
|
[[instance1 shape2]
|
||||||
[c-instance2 c-shape2]
|
[c-instance1 c-shape2]
|
||||||
component]
|
component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
new-instance-id)]
|
new-instance-id)]
|
||||||
|
|
||||||
(t/is (= (:id component) component-id))
|
(t/is (= (:id component) component-id))
|
||||||
(t/is (= (:name instance2) "Rect 1"))
|
(t/is (= (:name instance1) "Rect 1"))
|
||||||
(t/is (= (:name shape2) "Rect 1"))
|
(t/is (= (:name shape2) "Rect 1"))
|
||||||
(t/is (= (:name c-instance2) "Rect 1"))
|
(t/is (= (:name c-instance1) "Rect 1"))
|
||||||
(t/is (= (:name c-shape2) "Rect 1"))
|
(t/is (= (:name c-shape2) "Rect 1"))
|
||||||
(t/is (= (:component-file instance2) library-id)))))]
|
(t/is (= (:component-file instance1) library-id)))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
@ -526,32 +476,34 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)]))
|
[(thp/id :shape1)])
|
||||||
|
(thp/instantiate-component :instance1
|
||||||
|
(thp/id :component1)))
|
||||||
|
|
||||||
instance1 (thp/get-shape state :instance1)
|
instance1 (thp/get-shape state :instance1)
|
||||||
component-id (:component-id instance1)
|
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect-2
|
; Rect 1
|
||||||
; Rect 1
|
; Rect 1
|
||||||
;
|
; Rect 1
|
||||||
; [Rect-2]
|
; Rect 1
|
||||||
; Rect-2
|
;
|
||||||
; Rect 1
|
; [Rect 1]
|
||||||
;
|
; page1 / Rect 1
|
||||||
(let [[instance1 shape1]
|
;
|
||||||
(thl/resolve-noninstance
|
(let [[instance2 shape1]
|
||||||
new-state
|
(thl/resolve-noninstance
|
||||||
(:id instance1))]
|
new-state
|
||||||
|
(:id instance1))]
|
||||||
|
|
||||||
(t/is (some? instance1))
|
(t/is (some? instance2))
|
||||||
(t/is (some? shape1)))))]
|
(t/is (some? shape1)))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
@ -566,28 +518,21 @@
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"}))
|
{:name "Rect 1"}))
|
||||||
|
|
||||||
file (wsh/get-local-file state)
|
|
||||||
instance1 (thp/get-shape state :instance1)
|
|
||||||
component-id (:component-id instance1)
|
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Group #--> Group
|
; Group
|
||||||
; Rect 1 @--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
;
|
;
|
||||||
; [Rect 1]
|
; [Rect 1]
|
||||||
; Rect 1
|
; page1 / Rect 1
|
||||||
; Rect 1
|
;
|
||||||
;
|
; [Group]
|
||||||
; [Group]
|
; page1 / Group
|
||||||
; Group
|
|
||||||
; Rect 1 @--> Rect 1
|
|
||||||
; Rect 1 ---> Rect 1
|
|
||||||
;
|
;
|
||||||
(let [page (thp/current-page new-state)
|
(let [page (thp/current-page new-state)
|
||||||
shape1 (thp/get-shape new-state :shape1)
|
shape1 (thp/get-shape new-state :shape1)
|
||||||
|
@ -623,46 +568,41 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)])
|
[(thp/id :shape1)])
|
||||||
(thp/group-shapes :group1
|
(thp/make-component :main2 :component-2
|
||||||
[(thp/id :instance1)])
|
[(thp/id :main1)]))
|
||||||
(thp/make-component :instance2 :component-2
|
|
||||||
[(thp/id :group1)]))
|
|
||||||
|
|
||||||
file (wsh/get-local-file state)
|
file (wsh/get-local-file state)
|
||||||
instance1 (thp/get-shape state :instance1)
|
main1 (thp/get-shape state :main1)
|
||||||
instance2 (thp/get-shape state :instance2)
|
main2 (thp/get-shape state :main2)
|
||||||
component-id (:component-id instance2)
|
component-id (:component-id main2)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Rect 1 #--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 @--> Rect 1
|
; Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1
|
||||||
; Rect 1 #--> Rect 1
|
; Rect 1 #--> Rect 1
|
||||||
; Rect 1 @--> Rect 1
|
; Rect 1 @--> Rect 1
|
||||||
; Rect 1 ---> Rect 1
|
; Rect 1 ---> Rect 1
|
||||||
;
|
;
|
||||||
; [Rect 1]
|
; [Rect 1]
|
||||||
; Rect 1
|
; page1 / Rect 1
|
||||||
; Rect 1
|
;
|
||||||
;
|
; [Rect 1]
|
||||||
; [Rect 1]
|
; page1 / Rect 1
|
||||||
; Rect 1
|
|
||||||
; Rect 1 @--> Rect 1
|
|
||||||
; Rect 1 ---> Rect 1
|
|
||||||
;
|
;
|
||||||
(let [new-instance-id (-> new-state
|
(let [new-instance-id (-> new-state
|
||||||
wsh/lookup-selected
|
wsh/lookup-selected
|
||||||
first)
|
first)
|
||||||
|
|
||||||
[[instance3 shape3 shape4]
|
[[instance1 shape1 shape2]
|
||||||
[c-instance3 c-shape3 c-shape4]
|
[c-instance1 c-shape1 c-shape2]
|
||||||
component]
|
component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
|
@ -670,19 +610,19 @@
|
||||||
|
|
||||||
; TODO: get and check the instance inside component [Rect-2]
|
; TODO: get and check the instance inside component [Rect-2]
|
||||||
|
|
||||||
(t/is (not= (:id instance1) (:id instance3)))
|
(t/is (not= (:id main1) (:id instance1)))
|
||||||
(t/is (= (:id component) component-id))
|
(t/is (= (:id component) component-id))
|
||||||
(t/is (= (:name instance3) "Rect 1"))
|
(t/is (= (:name instance1) "Rect 1"))
|
||||||
(t/is (= (:name shape3) "Rect 1"))
|
(t/is (= (:name shape1) "Rect 1"))
|
||||||
(t/is (= (:name shape4) "Rect 1"))
|
(t/is (= (:name shape2) "Rect 1"))
|
||||||
(t/is (= (:name c-instance3) "Rect 1"))
|
(t/is (= (:name c-instance1) "Rect 1"))
|
||||||
(t/is (= (:name c-shape3) "Rect 1"))
|
(t/is (= (:name c-shape1) "Rect 1"))
|
||||||
(t/is (= (:name c-shape4) "Rect 1")))))]
|
(t/is (= (:name c-shape2) "Rect 1")))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
(dwl/instantiate-component (:id file)
|
(dwl/instantiate-component (:id file)
|
||||||
(:component-id instance2)
|
(:component-id main2)
|
||||||
(gpt/point 100 100))
|
(gpt/point 100 100))
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
||||||
|
@ -693,38 +633,36 @@
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/sample-shape :shape1 :rect
|
(thp/sample-shape :shape1 :rect
|
||||||
{:name "Rect 1"})
|
{:name "Rect 1"})
|
||||||
(thp/make-component :instance1 :component-1
|
(thp/make-component :main1 :component1
|
||||||
[(thp/id :shape1)])
|
[(thp/id :shape1)])
|
||||||
(thp/move-to-library :lib1 "Library 1")
|
(thp/move-to-library :lib1 "Library 1")
|
||||||
(thp/sample-page)
|
(thp/sample-page)
|
||||||
(thp/instantiate-component :instance2
|
(thp/instantiate-component :instance1
|
||||||
(thp/id :component-1)
|
(thp/id :component1)
|
||||||
(thp/id :lib1)))
|
(thp/id :lib1)))
|
||||||
|
|
||||||
library-id (thp/id :lib1)
|
file (wsh/get-local-file state)
|
||||||
component-id (thp/id :component-1)
|
library-id (thp/id :lib1)
|
||||||
|
|
||||||
store (the/prepare-store state done
|
store (the/prepare-store state done
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
; Expected shape tree:
|
; Expected shape tree:
|
||||||
;
|
;
|
||||||
; [Page]
|
; [Page]
|
||||||
; Root Frame
|
; Root Frame
|
||||||
; Group #--> Group
|
; Group
|
||||||
; Rect 1 @--> <Library 1> Rect 1
|
; Rect 1 #--> <Library 1> Rect 1
|
||||||
; Rect 1 ---> <Library 1> Rect 1
|
; Rect 1 ---> <Library 1> Rect 1
|
||||||
|
;
|
||||||
|
; [Group]
|
||||||
|
; page1 / Group
|
||||||
;
|
;
|
||||||
; [Group]
|
(let [instance1 (thp/get-shape new-state :instance1)
|
||||||
; Group
|
|
||||||
; Rect 1 @--> <Library 1> Rect 1
|
|
||||||
; Rect 1 ---> <Library 1> Rect 1
|
|
||||||
;
|
|
||||||
(let [instance2 (thp/get-shape new-state :instance2)
|
|
||||||
|
|
||||||
[[group1 shape1 shape2] [c-group1 c-shape1 c-shape2] component]
|
[[group1 shape1 shape2] [c-group1 c-shape1 c-shape2] _component]
|
||||||
(thl/resolve-instance-and-main
|
(thl/resolve-instance-and-main
|
||||||
new-state
|
new-state
|
||||||
(:parent-id instance2))]
|
(:parent-id instance1))]
|
||||||
|
|
||||||
(t/is (= (:name group1) "Group"))
|
(t/is (= (:name group1) "Group"))
|
||||||
(t/is (= (:name shape1) "Rect 1"))
|
(t/is (= (:name shape1) "Rect 1"))
|
||||||
|
@ -735,14 +673,13 @@
|
||||||
(t/is (= (:component-file group1) thp/current-file-id))
|
(t/is (= (:component-file group1) thp/current-file-id))
|
||||||
(t/is (= (:component-file shape1) library-id))
|
(t/is (= (:component-file shape1) library-id))
|
||||||
(t/is (= (:component-file shape2) nil))
|
(t/is (= (:component-file shape2) nil))
|
||||||
(t/is (= (:component-file c-group1) nil))
|
(t/is (= (:component-file c-group1) (:id file)))
|
||||||
(t/is (= (:component-file c-shape1) library-id))
|
(t/is (= (:component-file c-shape1) library-id))
|
||||||
(t/is (= (:component-file c-shape2) nil)))))]
|
(t/is (= (:component-file c-shape2) nil)))))]
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
(dw/select-shape (thp/id :instance2))
|
(dw/select-shape (thp/id :instance1))
|
||||||
dwg/group-selected
|
dwg/group-selected
|
||||||
(dwl/add-component)
|
(dwl/add-component)
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue