2026-10-04 02:12:06 -04:00
|
|
|
(ns arthur.events.instance-playback-test
|
|
|
|
|
(:require [cljs.test :refer [deftest is]]
|
|
|
|
|
[arthur.domain.clip :as clip]
|
|
|
|
|
[arthur.events.project :as project]
|
|
|
|
|
[arthur.footage.store :as store]
|
|
|
|
|
[re-frame.core :as rf]
|
|
|
|
|
[re-frame.db :as rf-db]))
|
|
|
|
|
|
|
|
|
|
(deftest playback-controls-change-only-the-selected-instance
|
|
|
|
|
(let [n {:id :wheel :kind :instance :source {:symbol :spin}
|
|
|
|
|
:span [0 240] :playback {:in 0 :speed 2 :end :stop
|
|
|
|
|
:tracks {:mouth []}}}
|
|
|
|
|
document (-> (clip/blank)
|
2026-10-10 15:13:21 -04:00
|
|
|
(assoc-in [:symbols :spin] {:frames 24 :nodes {}})
|
2026-10-04 02:12:06 -04:00
|
|
|
(assoc-in [:symbols :main :nodes :wheel] n)
|
|
|
|
|
(assoc-in [:symbols :main :nodes :other] (assoc n :id :other)))
|
|
|
|
|
id (store/install! {:clip document :store {}} "instance-playback-controls")
|
|
|
|
|
current #(get-in (:clip (store/entry (:clip/current @rf-db/app-db)))
|
|
|
|
|
[:symbols :main :nodes :wheel])]
|
|
|
|
|
(reset! rf-db/app-db {:clip/current id :paint/revision 0})
|
|
|
|
|
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :loop])
|
2026-10-10 15:13:21 -04:00
|
|
|
(is (= 0 (:frame (clip/placed-frame document (current) 24))))
|
2026-10-04 02:12:06 -04:00
|
|
|
(is (= :loop (get-in (current) [:playback :end])))
|
|
|
|
|
(is (= 2 (get-in (current) [:playback :speed])))
|
|
|
|
|
(rf/dispatch-sync [::project/instance-playback :main :wheel :in 5])
|
|
|
|
|
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :frame])
|
2026-10-10 15:13:21 -04:00
|
|
|
(is (= 5 (:frame (clip/placed-frame document (current) 100))))
|
2026-10-04 02:12:06 -04:00
|
|
|
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :once])
|
2026-10-10 15:13:21 -04:00
|
|
|
(is (nil? (clip/placed-frame document (current) 100)))
|
2026-10-04 02:12:06 -04:00
|
|
|
(is (= [0 240] (:span (current))))
|
|
|
|
|
(is (= {:mouth []} (get-in (current) [:playback :tracks])))
|
|
|
|
|
(let [before (current)]
|
|
|
|
|
(doseq [[field value] [[:in -1] [:speed js/Infinity] [:mode :invalid]]]
|
|
|
|
|
(rf/dispatch-sync [::project/instance-playback :main :wheel field value]))
|
|
|
|
|
(is (= before (current))))
|
|
|
|
|
(is (= n (assoc (get-in (:clip (store/entry (:clip/current @rf-db/app-db)))
|
|
|
|
|
[:symbols :main :nodes :other]) :id :wheel)))
|
|
|
|
|
(is (= 24 (get-in (:clip (store/entry (:clip/current @rf-db/app-db)))
|
|
|
|
|
[:symbols :spin :frames])))))
|