mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 21:28:28 +02:00
✨ Tests for remove swap slot on move shapes to frame
This commit is contained in:
parent
e666127b57
commit
7280dfd3f7
3 changed files with 278 additions and 129 deletions
|
@ -60,7 +60,7 @@
|
|||
changes (cflh/generate-relocate-shapes (pcb/empty-changes nil)
|
||||
(:objects page)
|
||||
#{(:parent-id blue1)} ;; parents
|
||||
uuid/zero ;; paremt-id
|
||||
uuid/zero ;; parent-id
|
||||
(:id page) ;; page-id
|
||||
0 ;; to-index
|
||||
#{(:id blue1)}) ;; ids
|
||||
|
@ -77,6 +77,34 @@
|
|||
(t/is (some? blue1'))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1')))))
|
||||
|
||||
(t/deftest test-keep-swap-slot-move-blue1-to-root
|
||||
(let [;; ============================== Setup ===============================
|
||||
file (setup-file)
|
||||
page (thf/current-page file)
|
||||
blue1 (thf/get-shape file :blue1)
|
||||
|
||||
;; ============================== Action ==============================
|
||||
changes (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id blue1)} ;; ids
|
||||
uuid/zero ;; frame-id
|
||||
(:id page) ;; page-id
|
||||
(:objects page) ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
|
||||
;; ============================== Get =================================
|
||||
blue1' (thf/get-shape file' :blue1)]
|
||||
|
||||
;; ================================== Check ===============================
|
||||
;; blue1 had swap-id before move
|
||||
(t/is (some? (ctk/get-swap-slot blue1)))
|
||||
|
||||
;; blue1 has not swap-id after move
|
||||
(t/is (some? blue1'))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1')))))
|
||||
|
||||
|
||||
(t/deftest test-keep-swap-slot-relocating-blue1-to-b2
|
||||
(let [;; ============================== Setup ===============================
|
||||
|
@ -107,6 +135,36 @@
|
|||
(t/is (some? blue1'))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1')))))
|
||||
|
||||
(t/deftest test-keep-swap-slot-move-blue1-to-b2
|
||||
(let [;; ============================== Setup ===============================
|
||||
file (setup-file)
|
||||
page (thf/current-page file)
|
||||
blue1 (thf/get-shape file :blue1)
|
||||
b2 (thf/get-shape file :frame-b2)
|
||||
|
||||
|
||||
;; ============================== Action ==============================
|
||||
changes (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id blue1)} ;; ids
|
||||
(:id b2) ;; frame-id
|
||||
(:id page) ;; page-id
|
||||
(:objects page) ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
|
||||
;; ============================== Get =================================
|
||||
blue1' (thf/get-shape file' :blue1)]
|
||||
|
||||
;; ================================== Check ===============================
|
||||
;; blue1 had swap-id before move
|
||||
(t/is (some? (ctk/get-swap-slot blue1)))
|
||||
|
||||
;; blue1 has not swap-id after move
|
||||
(t/is (some? blue1'))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1')))))
|
||||
|
||||
(t/deftest test-keep-swap-slot-relocating-yellow-to-root
|
||||
(let [;; ============================== Setup ===============================
|
||||
file (setup-file)
|
||||
|
@ -149,6 +207,48 @@
|
|||
(t/is (some? blue1''))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1'')))))
|
||||
|
||||
(t/deftest test-keep-swap-slot-move-yellow-to-root
|
||||
(let [;; ============================== Setup ===============================
|
||||
file (setup-file)
|
||||
page (thf/current-page file)
|
||||
blue1 (thf/get-shape file :blue1)
|
||||
yellow (thf/get-shape file :frame-yellow)
|
||||
|
||||
;; ============================== Action ==============================
|
||||
;; Move blue1 into yellow
|
||||
changes (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id blue1)} ;; ids
|
||||
(:id yellow) ;; frame-id
|
||||
(:id page) ;; page-id
|
||||
(:objects page) ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
page' (thf/current-page file')
|
||||
yellow' (thf/get-shape file' :frame-yellow)
|
||||
|
||||
;; Move yellow into root
|
||||
changes' (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id yellow')} ;; ids
|
||||
uuid/zero ;; frame-id
|
||||
(:id page') ;; page-id
|
||||
(:objects page') ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
file'' (thf/apply-changes file' changes')
|
||||
|
||||
;; ============================== Get =================================
|
||||
blue1'' (thf/get-shape file'' :blue1)]
|
||||
|
||||
;; ================================== Check ===============================
|
||||
;; blue1 had swap-id before move
|
||||
(t/is (some? (ctk/get-swap-slot blue1)))
|
||||
|
||||
;; blue1 has not swap-id after move
|
||||
(t/is (some? blue1''))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1'')))))
|
||||
|
||||
|
||||
(t/deftest test-keep-swap-slot-relocating-yellow-to-b2
|
||||
(let [;; ============================== Setup ===============================
|
||||
|
@ -192,3 +292,47 @@
|
|||
;; blue1 has not swap-id after move
|
||||
(t/is (some? blue1''))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1'')))))
|
||||
|
||||
(t/deftest test-keep-swap-slot-move-yellow-to-b2
|
||||
(let [;; ============================== Setup ===============================
|
||||
file (setup-file)
|
||||
page (thf/current-page file)
|
||||
blue1 (thf/get-shape file :blue1)
|
||||
yellow (thf/get-shape file :frame-yellow)
|
||||
|
||||
;; ============================== Action ==============================
|
||||
;; Move blue1 into yellow
|
||||
changes (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id blue1)} ;; ids
|
||||
(:id yellow) ;; frame-id
|
||||
(:id page) ;; page-id
|
||||
(:objects page) ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
page' (thf/current-page file')
|
||||
yellow' (thf/get-shape file' :frame-yellow)
|
||||
b2' (thf/get-shape file' :frame-b2)
|
||||
|
||||
;; Move yellow into b2
|
||||
changes' (cflh/generate-move-shapes-to-frame (pcb/empty-changes nil)
|
||||
#{(:id yellow')} ;; ids
|
||||
(:id b2') ;; frame-id
|
||||
(:id page') ;; page-id
|
||||
(:objects page') ;; objects
|
||||
0 ;; drop-index
|
||||
nil) ;; cell
|
||||
|
||||
file'' (thf/apply-changes file' changes')
|
||||
|
||||
;; ============================== Get =================================
|
||||
blue1'' (thf/get-shape file'' :blue1)]
|
||||
|
||||
;; ================================== Check ===============================
|
||||
;; blue1 had swap-id before move
|
||||
(t/is (some? (ctk/get-swap-slot blue1)))
|
||||
|
||||
;; blue1 has not swap-id after move
|
||||
(t/is (some? blue1''))
|
||||
(t/is (nil? (ctk/get-swap-slot blue1'')))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue