mirror of
https://github.com/penpot/penpot.git
synced 2025-08-04 05:38:23 +02:00
💄 Improve copy child selection and test robustness
This commit is contained in:
parent
caefaf6016
commit
8b4e52a2be
5 changed files with 140 additions and 94 deletions
47
common/test/common_tests/logic/comp_creation_test.cljc
Normal file
47
common/test/common_tests/logic/comp_creation_test.cljc
Normal file
|
@ -0,0 +1,47 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns common-tests.logic.comp-creation-test
|
||||
(:require
|
||||
[app.common.files.changes-builder :as pcb]
|
||||
[app.common.logic.libraries :as cll]
|
||||
[clojure.test :as t]
|
||||
[common-tests.helpers.components :as thc]
|
||||
[common-tests.helpers.files :as thf]
|
||||
[common-tests.helpers.ids-map :as thi]
|
||||
[common-tests.helpers.shapes :as ths]))
|
||||
|
||||
(t/use-fixtures :each thi/test-fixture)
|
||||
|
||||
(t/deftest test-add-component-from-single-shape
|
||||
(let [;; ==== Setup
|
||||
file (-> (thf/sample-file :file1)
|
||||
(ths/add-sample-shape :shape1 :type :frame))
|
||||
|
||||
page (thf/current-page file)
|
||||
shape1 (ths/get-shape file :shape1)
|
||||
|
||||
;; ==== Action
|
||||
[_ component-id changes]
|
||||
(cll/generate-add-component (pcb/empty-changes)
|
||||
[shape1]
|
||||
(:objects page)
|
||||
(:id page)
|
||||
(:id file)
|
||||
true
|
||||
nil
|
||||
nil)
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
|
||||
;; ==== Get
|
||||
component (thc/get-component-by-id file' component-id)
|
||||
root (ths/get-shape-by-id file' (:main-instance-id component))]
|
||||
|
||||
;; ==== Check
|
||||
(t/is (some? component))
|
||||
(t/is (some? root))
|
||||
(t/is (= (:component-id root) (:id component)))))
|
Loading…
Add table
Add a link
Reference in a new issue