(ns arthur.events.lane-test (:require [cljs.test :refer [deftest is]] [arthur.domain.clip :as clip] [arthur.domain.creation :as creation] [arthur.domain.history :as history] [arthur.domain.leaf :as leaf] [arthur.domain.node :as node] [arthur.domain.palette :as pal] [arthur.domain.sequence-test :as fixture] [arthur.domain.span :as span] [arthur.events.ui :as ui] [arthur.footage.store :as store] [arthur.ui.timeline :as timeline] [re-frame.core :as rf] [re-frame.db :as rf-db])) (deftest symbol-and-lane-creation-are-distinct-explicit-commands (letfn [(run [event key] (let [doc (clip/blank) id (store/install! {:clip doc :store {}} key)] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 6}}) (rf/dispatch-sync event) (let [db @rf-db/app-db saved (:clip (store/entry id)) [_ _ instance-id] (get-in db [:ui :selection]) sid (get-in saved [:symbols :main :nodes instance-id :source :symbol])] {:db db :document saved :instance-id instance-id :symbol (clip/symbol saved sid)})))] (let [{ordinary :symbol} (run [::ui/new-symbol :inside] "explicit-symbol") {lane :symbol lane-db :db document :document instance-id :instance-id} (run [::ui/new-lane] "explicit-lane")] (is (nil? (:display ordinary)) "new symbol means ordinary symbol") (is (= :lane (:display lane)) "only the lane command creates a lane") (is (= [0 (clip/frames document :main)] (node/placed-span (get-in document [:symbols :main :nodes instance-id]))) "a lane exists across the open symbol, independent of the playhead") (let [longer (assoc-in document [:symbols :main :frames] 300) fitted (:clip (span/finish longer :main (get-in longer [:symbols :main :nodes]) nil :keep)) lane-id (node/source (get-in fitted [:symbols :main :nodes instance-id]))] (is (= [0 300] (node/placed-span (get-in fitted [:symbols :main :nodes instance-id]))) "the lane follows a later change to its parent's extent") (is (= 300 (clip/frames fitted lane-id)))) (is (= :lane (:kind (creation/target document {} :main (get-in lane-db [:ui :selection]) 6))) "the new lane is the active creation row")))) (deftest a-new-symbol-on-a-lane-is-a-one-frame-cel (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "one-frame-new-symbol")] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main :selection [:node :main nil []]} :playback {:frame 5}}) (rf/dispatch-sync [::ui/new-symbol :inside]) (let [db @rf-db/app-db saved (:clip (store/entry id)) [_ sid instance-id] (get-in db [:ui :selection]) instance (get-in saved [:symbols sid :nodes instance-id]) source (node/source instance)] (is (= :main sid)) (is (= [5 6] (node/placed-span instance))) (is (= 1 (clip/frames saved source))) (is (= source (:sid (creation/target saved {} :main (get-in db [:ui :selection]) 5))) "an explicitly created cel is immediately its own creation target") (is (every? (fn [other] (or (= instance-id (:id other)) (let [[a b] (node/placed-span other)] (or (<= b 5) (<= 6 a))))) (filter node/placed-span (vals (get-in saved [:symbols :main :nodes])))) "claiming the frame leaves no overlapping cel")))) (deftest double-click-creation-uses-the-lane-and-the-frame-double-clicked (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "double-click-new-symbol")] ;; THE PLAYHEAD IS SOMEWHERE ELSE, deliberately: the gesture names a frame ;; as well as a lane, and the empty space double-clicked is where the new ;; symbol goes. (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 9}}) (rf/dispatch-sync [::ui/new-symbol-at 5 [:node :main nil []]]) (let [saved (:clip (store/entry id)) [_ sid instance-id] (get-in @rf-db/app-db [:ui :selection]) selection (get-in @rf-db/app-db [:ui :selection]) instance (get-in saved [:symbols sid :nodes instance-id])] (is (= :main sid)) (is (= [5 6] (node/placed-span instance))) (is (= 1 (clip/frames saved (node/source instance)))) (is (= (node/source instance) (:sid (creation/target saved {} :main selection 5))) "the new cel can immediately be selected as the creation target") (is (= 9 (get-in @rf-db/app-db [:playback :frame])) "creating in a lane does not move the playhead")))) (deftest the-palette-row-is-a-lane-row-whether-or-not-its-track-exists (let [empty-row (first (timeline/palette-track-rows (clip/blank) :main 120 #{} nil)) filled (-> (clip/blank) (assoc-in [:symbols :main :palette-track] :track) (assoc-in [:symbols :track] {:id :track :type :palette-track :display :lane :frames 120 :nodes {}})) filled-row (first (timeline/palette-track-rows filled :main 120 #{} nil))] ;; The double-click that creates in a lane asks nothing else of a row. (is (:lane? empty-row)) (is (:lane? filled-row)) (is (= [:node :track nil []] (:select filled-row)) "a track that exists is addressed as the lane it is"))) (deftest the-palette-row-opens-onto-the-selected-transition-like-any-lane (let [doc (-> (clip/blank) (assoc-in [:symbols :main :palette-track] :track) (assoc-in [:symbols :night] {:id :night :type :palette :frames 1 :nodes {}}) (assoc-in [:symbols :track] {:id :track :type :palette-track :display :lane :frames 120 :nodes {:p {:id :p :kind :instance :source :night :span [10 40] :time {:mode :map :at 10 :rate 1} :channels {[:pos] {:keys {0 [0 0] 12 [5 0]}}}}}})) closed (timeline/palette-track-rows doc :main 120 #{} [:p]) [lane portal & channels] (timeline/palette-track-rows doc :main 120 #{[:arthur.ui.timeline/palette-track] [:p]} [:p])] (is (= 1 (count closed))) (is (:expandable? (first closed)) "the palette lane has a disclosure like any lane") (is (:expanded? lane)) (is (= [:p] (:path portal)) "the portal is the selected transition, by its own path") (is (= [:node :track :p [:p]] (:select portal))) (is (= :track (:owner portal)) "dragging its bar slides it in the track") (is (= [10 22] (:keys portal)) "its keys are on this ruler") (is (= [:p [:pos]] (:path (first channels))) "and it opens onto its channels") (is (not (contains? #{[:arthur.ui.timeline/lane]} (:path lane))) "the palette lane never shares the open lane's expansion"))) (deftest the-same-double-click-command-creates-a-palette-symbol-on-the-palette-row (let [doc (clip/blank) id (store/install! {:clip doc :store {}} "double-click-palette-symbol")] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 9}}) (rf/dispatch-sync [::ui/new-symbol-at 5 [:arthur.ui.timeline/palette-track :main]]) (let [saved (:clip (store/entry id)) track-id (get-in saved [:symbols :main :palette-track]) [_ sid instance-id] (get-in @rf-db/app-db [:ui :selection]) instance (get-in saved [:symbols sid :nodes instance-id]) source (node/source instance)] (is (= track-id sid)) (is (= :palette-track (get-in saved [:symbols track-id :type]))) (is (= :palette (get-in saved [:symbols source :type]))) (is (= [5 6] (node/placed-span instance))) (is (= pal/inherit (get-in instance [:channels [:palette] :value]))) ;; ONCE THE TRACK EXISTS ITS ROW IS AN ORDINARY LANE ROW, which is the ;; address the pane then hands back: the second transition is created by ;; the same command resolving the same way as any other lane's. (rf/dispatch-sync [::ui/new-symbol-at 20 [:node track-id nil []]]) (let [saved (:clip (store/entry id)) [_ sid2 id2] (get-in @rf-db/app-db [:ui :selection]) second-clip (get-in saved [:symbols sid2 :nodes id2])] (is (= track-id sid2) "it lands in the same palette track") (is (= :palette (get-in saved [:symbols (node/source second-clip) :type]))) (is (= [20 21] (node/placed-span second-clip))) (is (= pal/inherit (get-in second-clip [:channels [:palette] :value]))))))) (deftest a-new-lane-uses-the-symbol-selected-at-the-playhead (let [doc (clip/blank) id (store/install! {:clip doc :store {}} "nested-new-lane")] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 6}}) (rf/dispatch-sync [::ui/new-symbol :inside]) (let [parent-instance (nth (get-in @rf-db/app-db [:ui :selection]) 2) parent-sid (node/source (get-in (:clip (store/entry id)) [:symbols :main :nodes parent-instance]))] (rf/dispatch-sync [::ui/new-lane]) (let [db @rf-db/app-db saved (:clip (store/entry id)) [_ host lane-instance] (get-in db [:ui :selection]) lane-sid (node/source (get-in saved [:symbols host :nodes lane-instance]))] (is (= parent-sid host) "the lane is created inside the selected symbol") (is (= :lane (get-in saved [:symbols lane-sid :display]))) (is (= [0 (clip/frames saved host)] (node/placed-span (get-in saved [:symbols host :nodes lane-instance])))) (is (nil? (get-in saved [:symbols :main :nodes lane-instance])) "it does not bypass the target and land in the tab root"))))) (deftest selecting-the-root-clears-the-active-row (let [db {:ui {:selection [:node :main :shape [:lane :shape]] :selections [[:node :main :shape [:lane :shape]]]}} after (ui/selected db nil)] (is (nil? (get-in after [:ui :selection]))) (is (empty? (get-in after [:ui :selections]))))) (deftest an-explicit-lane-is-one-row-of-clips (let [doc (fixture/document) rows (timeline/rows doc :main #{}) lane (first (filter :lane? rows))] (is (= 2 (count rows)) "the lane row plus the span-less plate") (is (= [[0 4] [4 8] [8 12]] (mapv :span (:cels lane)))) (is (= [[:node :main :a [:a]] [:node :main :b [:b]] [:node :main :insert [:insert]]] (mapv :select (:cels lane)))))) (deftest a-nested-lane-at-a-speed-is-drawn-in-the-open-symbols-frames (let [child {:id :cel :kind :instance :z "a" :span [0 2] :time {:at 4 :rate 1} :source {:symbol :drawing} :playback {:in 0 :speed 0 :end :stop}} placed {:id :take :kind :instance :z "a" :span [0 12] :time {:at 0 :rate 1} :source {:symbol :lane} :playback {:in 0 :speed 2 :end :stop}} doc (-> (clip/blank) (assoc-in [:symbols :main :frames] 12) (assoc-in [:symbols :main :nodes] {:take placed}) (assoc-in [:symbols :lane] {:id :lane :frames 24 :display :lane :nodes {:cel child}}) (assoc-in [:symbols :drawing] {:id :drawing :frames 1 :nodes {}})) lane (first (filter :lane? (timeline/rows doc :main #{})))] (is (= [[2 3]] (mapv :span (:cels lane))) "a lane placed at twice the speed draws its frames 4–6 on ruler frames 2–3"))) (deftest an-ordinary-symbol-keeps-a-row-per-node (let [doc (update-in (fixture/document) [:symbols :main] dissoc :display) rows (timeline/rows doc :main #{})] (is (empty? (filter :lane? rows))) (is (= #{[:a] [:b] [:insert] [:plate]} (set (map :path rows)))))) (deftest a-nested-selection-converts-the-open-playhead-to-its-owner (let [doc (assoc-in (fixture/document) [:symbols :outer] {:id :outer :frames 30 :nodes {:take {:id :take :kind :instance :z "a" :time {:at 10 :rate 1} :span [0 12] :source {:symbol :main} :playback {:in 0 :speed 1 :end :stop}}}})] (is (= 2 (ui/selection-frame doc nil :outer [:node :main :a [:take :a]] 12))) (is (= 12 (ui/selection-frame doc nil :main [:node :main :a [:a]] 12))))) (deftest creation-walks-to-the-nearest-valid-parent-at-the-playhead (let [doc (-> (fixture/document) (assoc-in [:symbols :shot] {:id :shot :frames 12 :nodes {:girl {:id :girl :kind :instance :z "a" :span [0 12] :time {:mode :map :at 0 :rate 1} :source {:symbol :main} :playback {:in 0 :speed 1 :end :stop}}}}) (assoc-in [:symbols :outer] {:id :outer :frames 30 :nodes {:take {:id :take :kind :instance :z "a" :span [0 12] :time {:mode :map :at 10 :rate 1} :source {:symbol :shot} :playback {:in 0 :speed 1 :end :stop}}}})) selection [:node :main :a [:take :girl :a]] at #(select-keys (creation/target doc nil :outer selection %) [:kind :sid :path :frame])] (is (= {:kind :symbol :sid :drawing-a :path [:take :girl :a] :frame 0} (at 12)) "the selected cel is the parent while every enclosing occurrence is active") (is (= {:kind :lane :sid :main :path [:take :girl] :frame 5} (at 15)) "past the cel, its containing lane is the nearest valid insertion surface") (is (= {:kind :symbol :sid :outer :path [] :frame 25} (at 25)) "a lane behind an inactive parent occurrence is not valid"))) (deftest creation-uses-the-occurrence-path-at-arbitrary-depth (let [instance (fn [id source span] {:id id :kind :instance :z "a" :span span :time {:mode :map :at 0 :rate 1} :source {:symbol source} :playback {:in 0 :speed 1 :end :stop}}) doc {:fps 24 :width 20 :height 20 :symbols {:main {:id :main :frames 20 :nodes {:outer (instance :outer :ordinary [0 20])}} :ordinary {:id :ordinary :frames 20 :nodes {:lane (instance :lane :symbol-7 [0 20])}} :symbol-7 {:id :symbol-7 :name "symbol-7" :display :lane :frames 20 :nodes {:cel (instance :cel :symbol-8 [4 10])}} :symbol-8 {:id :symbol-8 :name "symbol-8" :frames 6 :nodes {}}}} lane-selection [:node :ordinary :lane [:outer :lane]] ;; The path, rather than these redundant owner fields, is authoritative ;; for creation. A row address may name the occurrence from an outer ;; view; resolution must still enter the terminal cel. cel-selection [:node :ordinary :lane [:outer :lane :cel]] pick #(select-keys (creation/target doc nil :main % 5) [:kind :sid :path :frame])] (is (= {:kind :lane :sid :symbol-7 :path [:outer :lane] :frame 5} (pick lane-selection)) "the nested lane header remains the lane insertion surface") (is (= {:kind :symbol :sid :symbol-8 :path [:outer :lane :cel] :frame 5} (pick cel-selection)) "the cel enters its symbol no matter how deeply the lane is nested"))) (deftest creation-walks-out-of-an-instance-past-its-window (let [doc {:fps 24 :width 20 :height 20 :symbols {:main {:id :main :frames 40 :nodes {:drawing {:id :drawing :kind :instance :z "a" :span [0 10] :time {:at 0 :rate 1} :source {:symbol :inside} :playback {:in 0 :speed 1 :end :stop}}}} :inside {:id :inside :frames 10 :nodes {}}}} db {:ui {:open :main :selection [:node :main :drawing [:drawing]]} :playback {:frame 20}}] (is (= {:sid :main :path [] :frame 20} (select-keys (ui/paste-destination db doc nil) [:sid :path :frame])) "an inactive selected symbol falls back to the open symbol"))) (deftest multi-paste-uses-one-current-primary-target-and-selects-the-batch (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "multi-paste-target") a [:node :main :a [:a]] insert [:node :main :insert [:insert]]] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main :selection insert :selections [a insert]} :playback {:frame 4}}) (rf/dispatch-sync [::ui/copy]) ;; Changing selection after copy changes the destination, not the payload. (rf/dispatch-sync [::ui/select [:node :main nil []]]) (rf/dispatch-sync [::ui/paste]) (let [db @rf-db/app-db saved (:clip (store/entry id)) selections (get-in db [:ui :selections]) [a2 insert2] (map #(nth % 2) selections)] (is (= 2 (count selections))) (is (= (peek selections) (get-in db [:ui :selection])) "the last pasted root is the new primary creation anchor") (is (= [4 8] (node/placed-span (get-in saved [:symbols :main :nodes a2])))) (is (= [12 16] (node/placed-span (get-in saved [:symbols :main :nodes insert2])))) (is (= 1 (count (get-in (store/entry id) [:history :done]))) "the complete batch is one edit")))) (deftest polygon-landing-obeys-the-destination-symbol-mode (let [lane (fixture/document) ordinary (update-in lane [:symbols :main] dissoc :display) db {:ui {:open :main :selection [:node :main :plate [:plate]]} :playback {:frame 5}}] (is (true? (:lane? (ui/polygon-landing lane {} db)))) (is (false? (:lane? (ui/polygon-landing ordinary {} db)))))) (deftest beginning-a-polygon-does-not-invent-a-lane (let [doc (clip/blank) id (store/install! {:clip doc :store {}} "polygon-no-implicit-lane") db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 6}} after (ui/beginning-polygon db) saved (:clip (store/entry (:clip/current after)))] (is (= [] (get-in after [:ui :draft])) "a draft is begun") (is (= {} (get-in saved [:symbols :main :nodes]))) (is (nil? (get-in saved [:symbols :main :display]))) (is (nil? (get-in (store/entry (:clip/current after)) [:history :done]))))) (deftest drawing-with-the-lane-row-active-creates-a-new-cel (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "draw-new-lane-cel") db {:clip/current id :paint/revision 0 :ui {:open :main :selection [:node :main nil []]} :playback {:frame 1}} after (ui/beginning-polygon db) [_ sid cel-id] (get-in after [:ui :selection]) saved (:clip (store/entry id))] (is (= :main sid)) (is (not= :a cel-id) "the occupied cel is not reused") (is (= [1 2] (node/placed-span (get-in saved [:symbols sid :nodes cel-id])))) (is (= 1 (clip/frames saved (node/source (get-in saved [:symbols sid :nodes cel-id]))))) (is (= [] (get-in after [:ui :draft]))))) (deftest sequence-commands-use-isolated-history-transactions (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "sequence-command-test") db {:clip/current id :paint/revision 0 :ui {:open :main :selection [:node :main :a [:a]]}} refused (ui/apply-command db :main (span/extend-hold doc :main :a 1 {}) [:retry])] (is (= doc (:clip (store/entry id)))) (is (= [:retry] (get-in refused [:ui :retry]))) (let [r1 (span/extend-hold doc :main :a 1 {:extent :grow-symbol}) db1 (ui/apply-command db :main r1 nil) r2 (span/extend-hold (:clip r1) :main :a 1 {:extent :grow-symbol}) db2 (ui/apply-command db1 :main r2 nil) h (:history (store/entry id)) undo (history/undo h (leaf/leaves "u" (:clip r2))) undo2 (history/undo (:history undo) (:leaves undo))] (is (= 2 (count (:done h)))) (is (= (:clip r1) (leaf/clip "u" (:leaves undo)))) (is (= doc (leaf/clip "u" (:leaves undo2)))) (is (= [:node :main :a [:a]] (get-in db2 [:ui :selection])))))) (deftest an-expanded-lane-opens-the-selected-clip (let [doc (fixture/document) rows (timeline/rows doc :main #{[:arthur.ui.timeline/lane] [:insert]} [:insert]) portal (first (filter :portal? rows))] (is (= [:insert] (:path portal))) (is (= [:node :main :insert [:insert]] (:select portal))) (is (some #{"mark"} (map :label rows))))) (deftest a-lane-of-sounds-is-not-flattened-twice (let [base (:clip (span/draw-as-lane (clip/blank) :main true {})) doc (clip/place-sound base :main {:sound "s1"} "voice" 6 1 2 :vo) lane (first (filter :lane? (timeline/rows doc :main #{} nil)))] (is (= [:vo] (mapv :id (:cels lane)))) (is (empty? (timeline/sound-rows doc :main #{}))))) (deftest selecting-the-open-lanes-own-row-is-the-lane-target ;; `rows` names the open symbol's own lane row `[:node sid nil []]`, and ;; `selected` used to open the rows above a selection with `(pop path)` — ;; which THROWS on `[]`, aborting the whole event. Nothing was selected, ;; nothing was selected, and the next polygon used stale creation state. (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "select-the-open-lane") db {:clip/current id :paint/revision 0 :ui {:open :main} :playback {:frame 0}} lane (first (filter :lane? (timeline/rows doc :main #{}))) after (ui/selected db (:select lane))] (is (= [:node :main nil []] (:select lane))) (is (= [:node :main nil []] (get-in after [:ui :selection]))) (is (= :lane (:kind (creation/target doc {} :main (get-in after [:ui :selection]) 0)))) (is (empty? (get-in after [:ui :expanded])) "and there are no rows above the top to open"))) (deftest a-primary-selection-also-starts-the-stage-selection-set (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "primary-stage-selection") address [:node :main :insert [:insert]] after (ui/selected {:clip/current id :ui {}} address)] (is (= address (get-in after [:ui :selection]))) (is (= [address] (get-in after [:ui :selections]))))) (deftest selecting-or-trimming-a-nested-lane-item-does-not-open-its-row (let [selection [:node :inner :clip [:lane :clip]] before {:ui {:expanded #{[:already-open]}}} after (ui/selected before selection)] (is (= selection (get-in after [:ui :selection]))) (is (= #{[:already-open]} (get-in after [:ui :expanded])) "disclosure is changed only by the twist control"))) (deftest disclosure-sets-the-state-painted-by-the-button ;; A move can reveal a destination after the old, closed button has already ;; received pointer-down. Its eventual click must keep the row open instead ;; of toggling the newer state closed again. (reset! rf-db/app-db {:ui {:expanded #{[:destination]}}}) (rf/dispatch-sync [::ui/set-row-expanded [:destination] true]) (is (= #{[:destination]} (get-in @rf-db/app-db [:ui :expanded]))) (rf/dispatch-sync [::ui/set-row-expanded [:destination] false]) (is (empty? (get-in @rf-db/app-db [:ui :expanded])))) (deftest finishing-a-polygon-opens-no-rows ;; Expansion is the twist triangle's business. Finishing a shape used to open ;; every row down to it, which inside a lane meant tearing its one row into a ;; portal, that clip's channels and every shape already in the drawing. (let [doc (fixture/document) id (store/install! {:clip doc :store {}} "finish-opens-nothing") db {:clip/current id :paint/revision 0 :ui {:open :main :tool :polygon :selection [:node :main :a [:a]] :draft [10 10 40 10 40 40]} :playback {:frame 1}}] (reset! rf-db/app-db db) (rf/dispatch-sync [::ui/finish-polygon]) (let [after @rf-db/app-db [kind sid shape-id path] (get-in after [:ui :selection])] (is (= :node kind)) (is (= :drawing-a sid) "the shape went into the drawing the selected clip places") (is (= [:a shape-id] path)) (is (empty? (get-in after [:ui :expanded]))) (is (empty? (get-in after [:ui :draft])) "the pen stays the tool, with nothing drafted")))) (deftest a-clip-made-for-a-drawing-is-selected-in-the-symbol-it-lives-in ;; The clip `beginning-polygon` materializes lives in the symbol the LANE ;; draws. Naming the open one instead left a selection that looked up to ;; nothing, so the inspector, the breadcrumb and every span command went blank ;; on a drawing that had just been created. (let [doc (-> (fixture/document) ;; The last of the lane's three clips taken out, so frames 8 ;; to 12 are a gap and drawing there makes the held clip that ;; was missing rather than landing in one that is there. (update-in [:symbols :main :nodes] dissoc :insert) (assoc-in [:symbols :shot] {:id :shot :frames 12 :nodes {:girl {:id :girl :kind :instance :z "b" :span [0 12] :time {:mode :map :at 0 :rate 1} :source {:symbol :main} :playback {:in 0 :speed 1 :end :stop}}}})) id (store/install! {:clip doc :store {}} "clip-selected-where-it-lives") db {:clip/current id :paint/revision 0 :ui {:open :shot :selection [:node :shot :girl [:girl]]} :playback {:frame 9}} after (ui/beginning-polygon db) [_ sid clip-id path] (get-in after [:ui :selection]) saved (:clip (store/entry id))] (is (= :main sid) "the lane's symbol, not the open one") (is (= [:girl clip-id] path)) (is (some? (get-in saved [:symbols :main :nodes clip-id])) "and that is where the node actually is"))) (deftest restacking-a-selection-keeps-all-members-selected (let [doc (update-in (fixture/document) [:symbols :main] dissoc :display) id (store/install! {:clip doc :store {}} "restack-many-test") selections [[:node :main :a [:a]] [:node :main :b [:b]]]] (reset! rf-db/app-db {:clip/current id :paint/revision 0 :ui {:open :main :selection (peek selections) :selections selections} :playback {:frame 6}}) (rf/dispatch-sync [::ui/restack-nodes selections [:insert] true]) (let [after (:clip (store/entry (:clip/current @rf-db/app-db))) z #(get-in after [:symbols :main :nodes % :z])] (is (pos? (compare (z :a) (z :insert)))) (is (pos? (compare (z :b) (z :a)))) (is (= selections (get-in @rf-db/app-db [:ui :selections]))) (is (= [0 4] (mapv #(get-in after [:symbols :main :nodes % :time :at]) [:a :b]))))))