mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
💄 Add indentation fixes on frontend tests
This commit is contained in:
parent
dae5e71fa1
commit
42aee56c36
3 changed files with 2566 additions and 2558 deletions
|
@ -19,21 +19,28 @@
|
|||
|
||||
;; ---- Helpers to manage global events
|
||||
|
||||
(defn on-error
|
||||
[cause]
|
||||
(js/console.log "[CAUSE]:" (.-stack cause))
|
||||
(js/console.log "[DATA]:" (pr-str (ex-data cause))))
|
||||
|
||||
(defn prepare-store
|
||||
"Create a store with the given initial state. Wait until
|
||||
a :the/end event occurs, and then call the function with
|
||||
the final state at this point."
|
||||
[state done completed-cb]
|
||||
(let [store (ptk/store {:state state})
|
||||
(let [store (ptk/store {:state state :on-error on-error})
|
||||
stream (ptk/input-stream store)
|
||||
stream (->> stream
|
||||
(rx/take-until (rx/filter #(= :the/end %) stream))
|
||||
(rx/last)
|
||||
(rx/do
|
||||
(fn []
|
||||
(rx/do (fn []
|
||||
(completed-cb @store)))
|
||||
(rx/subs done #(throw %)))]
|
||||
(rx/subs (fn [_] (done))
|
||||
(fn [cause]
|
||||
(js/console.log "[error]:" cause))
|
||||
(fn [_]
|
||||
(js/console.log "[complete]"))))]
|
||||
store))
|
||||
|
||||
;; Remove definitely when we ensure that the above method works
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,6 +15,9 @@
|
|||
[linked.core :as lks]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(.on js/process "uncaughtException" (fn [cause]
|
||||
(js/console.log "EE" cause)))
|
||||
|
||||
(t/use-fixtures :each
|
||||
{:before thp/reset-idmap!})
|
||||
|
||||
|
@ -35,17 +38,17 @@
|
|||
;; (get new-state :workspace-libraries)
|
||||
;; false true)
|
||||
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1 #--> Rect 1
|
||||
; Rect 1 ---> Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1 #--> Rect 1
|
||||
;; Rect 1 ---> Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
(let [shape1 (thp/get-shape new-state :shape1)
|
||||
|
||||
[[group shape1] [c-group c-shape1] component]
|
||||
|
@ -81,16 +84,16 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Component 1
|
||||
; Rect 1
|
||||
; Rect-2
|
||||
;
|
||||
; [Component 1]
|
||||
; page1 / Component 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Component 1
|
||||
;; Rect 1
|
||||
;; Rect-2
|
||||
;;
|
||||
;; [Component 1]
|
||||
;; page1 / Component 1
|
||||
;;
|
||||
(let [shape1 (thp/get-shape new-state :shape1)
|
||||
|
||||
[[group shape1 shape2]
|
||||
|
@ -134,17 +137,17 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Group
|
||||
; Rect 1
|
||||
; Rect-2
|
||||
;
|
||||
; [Group]
|
||||
; page1 / Group
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Group
|
||||
;; Rect 1
|
||||
;; Rect-2
|
||||
;;
|
||||
;; [Group]
|
||||
;; page1 / Group
|
||||
;;
|
||||
(let [[[group shape1 shape2]
|
||||
[c-group c-shape1 c-shape2]
|
||||
component]
|
||||
|
@ -182,20 +185,20 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [[[instance1 shape1]
|
||||
[c-instance1 c-shape1]
|
||||
component1]
|
||||
|
@ -245,16 +248,16 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
; [Renamed component]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
;; [Renamed component]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [libs (wsh/get-libraries new-state)
|
||||
component (ctf/get-component libs
|
||||
(:component-file main1)
|
||||
|
@ -282,21 +285,21 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
; Rect 1 #--> Rect 1
|
||||
; Rect 1 ---> Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1 #--> Rect 1
|
||||
;; Rect 1 ---> Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [new-component-id (->> (get-in new-state
|
||||
[:workspace-data
|
||||
:components])
|
||||
|
@ -325,27 +328,24 @@
|
|||
:the/end))))
|
||||
|
||||
(t/deftest test-delete-component
|
||||
(t/async
|
||||
done
|
||||
(t/async done
|
||||
(let [state (-> thp/initial-state
|
||||
(thp/sample-page)
|
||||
(thp/sample-shape :shape1 :rect
|
||||
{:name "Rect 1"})
|
||||
(thp/make-component :main1 :component1
|
||||
[(thp/id :shape1)])
|
||||
(thp/instantiate-component :instance1
|
||||
(thp/id :component1)))
|
||||
(thp/sample-shape :shape1 :rect {:name "Rect 1"})
|
||||
(thp/make-component :main1 :component1 [(thp/id :shape1)])
|
||||
(thp/instantiate-component :instance1 (thp/id :component1)))
|
||||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1 #--> ?
|
||||
; Rect 1 ---> ?
|
||||
;
|
||||
(let [[main1 shape1]
|
||||
;; Expected shape tree:
|
||||
;;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1 #--> ?
|
||||
;; Rect 1 ---> ?
|
||||
;;;
|
||||
(let [
|
||||
[main1 shape1]
|
||||
(thl/resolve-noninstance
|
||||
new-state
|
||||
(thp/id :main1))
|
||||
|
@ -383,10 +383,11 @@
|
|||
(t/is (some? (:objects component3)))
|
||||
|
||||
(t/is (= (:name saved-main1) "Rect 1"))
|
||||
(t/is (= (:name saved-shape2) "Rect 1")))))]
|
||||
(t/is (= (:name saved-shape2) "Rect 1"))
|
||||
|
||||
(ptk/emit!
|
||||
store
|
||||
)))
|
||||
]
|
||||
(ptk/emit! store
|
||||
(dwl/delete-component {:id (thp/id :component1)})
|
||||
:the/end))))
|
||||
|
||||
|
@ -404,18 +405,18 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1 #--> Rect 1
|
||||
; Rect 1 ---> Rect 1
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1 #--> Rect 1
|
||||
;; Rect 1 ---> Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [[[instance1 shape2] [c-instance1 c-shape2] component1]
|
||||
(thl/resolve-instance-and-main
|
||||
new-state
|
||||
|
@ -457,18 +458,18 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
; Rect 1 #--> Rect 1
|
||||
; Rect 1 ---> Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1 #--> Rect 1
|
||||
;; Rect 1 ---> Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [new-instance-id (-> new-state
|
||||
wsh/lookup-selected
|
||||
first)
|
||||
|
@ -513,13 +514,13 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1 #--> <Library 1> Rect 1
|
||||
; Rect 1 ---> <Library 1> Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1 #--> <Library 1> Rect 1
|
||||
;; Rect 1 ---> <Library 1> Rect 1
|
||||
;;
|
||||
(let [new-instance-id (-> new-state
|
||||
wsh/lookup-selected
|
||||
first)
|
||||
|
@ -561,18 +562,18 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [[instance2 shape1]
|
||||
(thl/resolve-noninstance
|
||||
new-state
|
||||
|
@ -596,20 +597,20 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Group
|
||||
; Rect 1
|
||||
; Rect 1
|
||||
;
|
||||
; [Rect 1]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
; [Group]
|
||||
; page1 / Group
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Group
|
||||
;; Rect 1
|
||||
;; Rect 1
|
||||
;;
|
||||
;; [Rect 1]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
;; [Group]
|
||||
;; page1 / Group
|
||||
;;
|
||||
(let [page (thp/current-page new-state)
|
||||
shape1 (thp/get-shape new-state :shape1)
|
||||
parent1 (ctn/get-shape page (:parent-id shape1))
|
||||
|
@ -656,23 +657,23 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; 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]
|
||||
; page1 / Rect 1
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; 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]
|
||||
;; page1 / Rect 1
|
||||
;;
|
||||
(let [new-instance-id (-> new-state
|
||||
wsh/lookup-selected
|
||||
first)
|
||||
|
@ -684,7 +685,7 @@
|
|||
new-state
|
||||
new-instance-id)]
|
||||
|
||||
; TODO: get and check the instance inside component [Rect-2]
|
||||
;; TODO: get and check the instance inside component [Rect-2]
|
||||
|
||||
(t/is (not= (:id main1) (:id instance1)))
|
||||
(t/is (= (:id component) component-id))
|
||||
|
@ -722,17 +723,17 @@
|
|||
|
||||
store (the/prepare-store state done
|
||||
(fn [new-state]
|
||||
; Expected shape tree:
|
||||
;
|
||||
; [Page]
|
||||
; Root Frame
|
||||
; Group
|
||||
; Rect 1 #--> <Library 1> Rect 1
|
||||
; Rect 1 ---> <Library 1> Rect 1
|
||||
;
|
||||
; [Group]
|
||||
; page1 / Group
|
||||
;
|
||||
;; Expected shape tree:
|
||||
;;
|
||||
;; [Page]
|
||||
;; Root Frame
|
||||
;; Group
|
||||
;; Rect 1 #--> <Library 1> Rect 1
|
||||
;; Rect 1 ---> <Library 1> Rect 1
|
||||
;;
|
||||
;; [Group]
|
||||
;; page1 / Group
|
||||
;;
|
||||
(let [instance1 (thp/get-shape new-state :instance1)
|
||||
|
||||
[[group1 shape1 shape2] [c-group1 c-shape1 c-shape2] _component]
|
||||
|
|
Loading…
Add table
Reference in a new issue