finlly fixed it

This commit is contained in:
Olive Vaughn 2026-10-10 17:48:54 -04:00
parent a10d7b2d9f
commit e2ca251ef4
8 changed files with 184 additions and 70 deletions

View file

@ -0,0 +1,33 @@
(ns arthur.events.vertex-test
(:require [cljs.test :refer [deftest is]]
[arthur.domain.clip :as clip]
[arthur.domain.paint :as paint]
[arthur.events.ui :as ui]
[arthur.footage.store :as store]
[re-frame.core :as rf]
[re-frame.db :as rf-db]))
(deftest delete-takes-the-picked-point-and-then-the-one-before
(let [doc (paint/new-shape (clip/blank) :main :s 0 [0 0 10 0 20 10 10 20 0 20] 1)
id (store/install! {:clip doc :store {}} "vertex-delete")
pts #(-> (store/entry id) :clip
(get-in [:symbols :main :nodes :s :channels paint/geometry :keys 0]))
n #(quot (count (pts)) 2)]
(reset! rf-db/app-db {:clip/current id :paint/revision 0
:ui {:open :main :tool :pen :selection [:node :main :s [:s]]}
:playback {:frame 0}})
(let [before (pts)]
(rf/dispatch-sync [::ui/pick-vertex :main :s 2])
(rf/dispatch-sync [::ui/delete-selected])
(is (= 4 (n)))
(is (= (into (subvec before 0 4) (subvec before 6)) (pts)) "point 2 is the one gone")
(is (= [:main :s 1] (get-in @rf-db/app-db [:ui :vertex])) "the one before it is picked"))
(rf/dispatch-sync [::ui/delete-selected])
(rf/dispatch-sync [::ui/delete-selected])
(is (= 3 (n)) "a triangle keeps its three")
(is (some? (get-in (:clip (store/entry id)) [:symbols :main :nodes :s]))
"and Delete never falls through to the shape")
(swap! rf-db/app-db assoc-in [:ui :tool] :select)
(rf/dispatch-sync [::ui/delete-selected])
(is (nil? (get-in (:clip (store/entry id)) [:symbols :main :nodes :s]))
"off the pen, Delete is the shape's")))