mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🔧 Validate only after propagation in tests
This commit is contained in:
@@ -274,7 +274,7 @@
|
|||||||
file-id
|
file-id
|
||||||
{file-id file}
|
{file-id file}
|
||||||
file-id))]
|
file-id))]
|
||||||
(thf/apply-changes file changes)))
|
(thf/apply-changes file changes :validate? false)))
|
||||||
|
|
||||||
(defn swap-component
|
(defn swap-component
|
||||||
"Swap the specified shape by the component specified by component-tag"
|
"Swap the specified shape by the component specified by component-tag"
|
||||||
@@ -305,12 +305,13 @@
|
|||||||
[changes nil])
|
[changes nil])
|
||||||
|
|
||||||
|
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(when new-shape-label
|
(when new-shape-label
|
||||||
(thi/rm-id! (:id new-shape))
|
(thi/rm-id! (:id new-shape))
|
||||||
(thi/set-id! new-shape-label (:id new-shape)))
|
(thi/set-id! new-shape-label (:id new-shape)))
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
(defn swap-component-in-shape [file shape-tag component-tag & {:keys [page-label propagate-fn]}]
|
(defn swap-component-in-shape [file shape-tag component-tag & {:keys [page-label propagate-fn]}]
|
||||||
@@ -339,9 +340,10 @@
|
|||||||
(assoc shape :fills (ths/sample-fills-color :fill-color color)))
|
(assoc shape :fills (ths/sample-fills-color :fill-color color)))
|
||||||
(:objects page)
|
(:objects page)
|
||||||
{})
|
{})
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
(defn update-bottom-color
|
(defn update-bottom-color
|
||||||
@@ -357,9 +359,10 @@
|
|||||||
(assoc shape :fills (ths/sample-fills-color :fill-color color)))
|
(assoc shape :fills (ths/sample-fills-color :fill-color color)))
|
||||||
(:objects page)
|
(:objects page)
|
||||||
{})
|
{})
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
(defn reset-overrides [file shape & {:keys [page-label propagate-fn]}]
|
(defn reset-overrides [file shape & {:keys [page-label propagate-fn]}]
|
||||||
@@ -374,9 +377,10 @@
|
|||||||
{file-id file}
|
{file-id file}
|
||||||
(ctn/make-container container :page)
|
(ctn/make-container container :page)
|
||||||
(:id shape)))
|
(:id shape)))
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
(defn reset-overrides-in-first-child [file shape-tag & {:keys [page-label propagate-fn]}]
|
(defn reset-overrides-in-first-child [file shape-tag & {:keys [page-label propagate-fn]}]
|
||||||
@@ -398,9 +402,10 @@
|
|||||||
#{(-> (ths/get-shape file shape-tag :page-label page-label)
|
#{(-> (ths/get-shape file shape-tag :page-label page-label)
|
||||||
:id)}
|
:id)}
|
||||||
{})
|
{})
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
(defn duplicate-shape [file shape-tag & {:keys [page-label propagate-fn]}]
|
(defn duplicate-shape [file shape-tag & {:keys [page-label propagate-fn]}]
|
||||||
@@ -419,8 +424,9 @@
|
|||||||
(:id file)) ;; file-id
|
(:id file)) ;; file-id
|
||||||
(cll/generate-duplicate-changes-update-indices (:objects page) ;; objects
|
(cll/generate-duplicate-changes-update-indices (:objects page) ;; objects
|
||||||
#{(:id shape)}))
|
#{(:id shape)}))
|
||||||
file' (thf/apply-changes file changes)]
|
file' (thf/apply-changes file changes :validate? (not propagate-fn))]
|
||||||
(if propagate-fn
|
(if propagate-fn
|
||||||
(propagate-fn file')
|
(-> (propagate-fn file')
|
||||||
|
(thf/validate-file!))
|
||||||
file')))
|
file')))
|
||||||
|
|
||||||
|
|||||||
@@ -54,12 +54,14 @@
|
|||||||
([file] (validate-file! file {}))
|
([file] (validate-file! file {}))
|
||||||
([file libraries]
|
([file libraries]
|
||||||
(cfv/validate-file-schema! file)
|
(cfv/validate-file-schema! file)
|
||||||
(cfv/validate-file! file libraries)))
|
(cfv/validate-file! file libraries)
|
||||||
|
file))
|
||||||
|
|
||||||
(defn apply-changes
|
(defn apply-changes
|
||||||
[file changes]
|
[file changes & {:keys [validate?] :or {validate? true}}]
|
||||||
(let [file' (ctf/update-file-data file #(cfc/process-changes % (:redo-changes changes) true))]
|
(let [file' (ctf/update-file-data file #(cfc/process-changes % (:redo-changes changes) true))]
|
||||||
(validate-file! file')
|
(when validate?
|
||||||
|
(validate-file! file'))
|
||||||
file'))
|
file'))
|
||||||
|
|
||||||
(defn apply-undo-changes
|
(defn apply-undo-changes
|
||||||
|
|||||||
@@ -465,9 +465,10 @@
|
|||||||
page
|
page
|
||||||
{(:id file) file}
|
{(:id file) file}
|
||||||
(thi/id :nested-h-ellipse))
|
(thi/id :nested-h-ellipse))
|
||||||
file' (-> (thf/apply-changes file changes)
|
file' (-> (thf/apply-changes file changes :validate? false)
|
||||||
(tho/propagate-component-changes :c-board-with-ellipse)
|
(tho/propagate-component-changes :c-board-with-ellipse)
|
||||||
(tho/propagate-component-changes :c-big-board))
|
(tho/propagate-component-changes :c-big-board)
|
||||||
|
(thf/validate-file!))
|
||||||
|
|
||||||
;; ==== Get
|
;; ==== Get
|
||||||
nested2-h-ellipse (ths/get-shape file' :nested-h-ellipse)
|
nested2-h-ellipse (ths/get-shape file' :nested-h-ellipse)
|
||||||
|
|||||||
@@ -64,9 +64,8 @@
|
|||||||
|
|
||||||
(reset-all-overrides [file]
|
(reset-all-overrides [file]
|
||||||
(-> file
|
(-> file
|
||||||
(tho/reset-overrides-in-first-child :frame-board-1 :page-label :page-1)
|
(tho/reset-overrides-in-first-child :frame-board-1 :page-label :page-1 :propagate-fn propagate-all-component-changes)
|
||||||
(tho/reset-overrides-in-first-child :copy-board-1 :page-label :page-2)
|
(tho/reset-overrides-in-first-child :copy-board-1 :page-label :page-2 :propagate-fn propagate-all-component-changes)))
|
||||||
(propagate-all-component-changes)))
|
|
||||||
|
|
||||||
(fill-colors [file]
|
(fill-colors [file]
|
||||||
[(tho/bottom-fill-color file :frame-ellipse-1 :page-label :page-1)
|
[(tho/bottom-fill-color file :frame-ellipse-1 :page-label :page-1)
|
||||||
|
|||||||
@@ -56,10 +56,9 @@
|
|||||||
|
|
||||||
(reset-all-overrides [file]
|
(reset-all-overrides [file]
|
||||||
(-> file
|
(-> file
|
||||||
(tho/reset-overrides (ths/get-shape file :copy-simple-1))
|
(tho/reset-overrides (ths/get-shape file :copy-simple-1 :propagate-fn propagate-all-component-changes))
|
||||||
(tho/reset-overrides (ths/get-shape file :copy-frame-composed-1))
|
(tho/reset-overrides (ths/get-shape file :copy-frame-composed-1 :propagate-fn propagate-all-component-changes))
|
||||||
(tho/reset-overrides (ths/get-shape file :composed-1-composed-2-copy))
|
(tho/reset-overrides (ths/get-shape file :composed-1-composed-2-copy :propagate-fn propagate-all-component-changes))))
|
||||||
(propagate-all-component-changes)))
|
|
||||||
|
|
||||||
(fill-colors [file]
|
(fill-colors [file]
|
||||||
[(tho/bottom-fill-color file :frame-simple-1)
|
[(tho/bottom-fill-color file :frame-simple-1)
|
||||||
|
|||||||
@@ -6,20 +6,12 @@
|
|||||||
|
|
||||||
(ns common-tests.logic.swap-as-override-test
|
(ns common-tests.logic.swap-as-override-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.files.changes :as ch]
|
[app.common.data :as d]
|
||||||
[app.common.files.changes-builder :as pcb]
|
|
||||||
[app.common.logic.libraries :as cll]
|
|
||||||
[app.common.logic.shapes :as cls]
|
|
||||||
[app.common.pprint :as pp]
|
|
||||||
[app.common.test-helpers.components :as thc]
|
[app.common.test-helpers.components :as thc]
|
||||||
[app.common.test-helpers.compositions :as tho]
|
[app.common.test-helpers.compositions :as tho]
|
||||||
[app.common.test-helpers.files :as thf]
|
[app.common.test-helpers.files :as thf]
|
||||||
[app.common.test-helpers.ids-map :as thi]
|
[app.common.test-helpers.ids-map :as thi]
|
||||||
[app.common.test-helpers.shapes :as ths]
|
[app.common.test-helpers.shapes :as ths]
|
||||||
[app.common.types.component :as ctk]
|
|
||||||
[app.common.types.container :as ctn]
|
|
||||||
[app.common.types.file :as ctf]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[clojure.test :as t]))
|
[clojure.test :as t]))
|
||||||
|
|
||||||
(t/use-fixtures :each thi/test-fixture)
|
(t/use-fixtures :each thi/test-fixture)
|
||||||
@@ -27,23 +19,40 @@
|
|||||||
(defn- setup []
|
(defn- setup []
|
||||||
(-> (thf/sample-file :file1)
|
(-> (thf/sample-file :file1)
|
||||||
|
|
||||||
(tho/add-simple-component :component-1 :frame-component-1 :child-component-1 :child-params {:name "child-component-1" :type :rect :fills (ths/sample-fills-color :fill-color "#111111")})
|
(tho/add-simple-component :component-1 :frame-component-1 :child-component-1
|
||||||
(tho/add-simple-component :component-2 :frame-component-2 :child-component-2 :child-params {:name "child-component-2" :type :rect :fills (ths/sample-fills-color :fill-color "#222222")})
|
:root-params {:name "component-1"}
|
||||||
(tho/add-simple-component :component-3 :frame-component-3 :child-component-3 :child-params {:name "child-component-3" :type :rect :fills (ths/sample-fills-color :fill-color "#333333")})
|
:child-params {:name "child-component-1"
|
||||||
|
:type :rect
|
||||||
|
:fills (ths/sample-fills-color :fill-color "#111111")})
|
||||||
|
(tho/add-simple-component :component-2 :frame-component-2 :child-component-2
|
||||||
|
:root-params {:name "component-2"}
|
||||||
|
:child-params {:name "child-component-2"
|
||||||
|
:type :rect
|
||||||
|
:fills (ths/sample-fills-color :fill-color "#222222")})
|
||||||
|
(tho/add-simple-component :component-3 :frame-component-3 :child-component-3
|
||||||
|
:root-params {:name "component-3"}
|
||||||
|
:child-params {:name "child-component-3"
|
||||||
|
:type :rect
|
||||||
|
:fills (ths/sample-fills-color :fill-color "#333333")})
|
||||||
|
|
||||||
(tho/add-frame :frame-icon-and-text)
|
(tho/add-frame :frame-icon-and-text :name "copy-component-1")
|
||||||
(thc/instantiate-component :component-1 :copy-component-1 :parent-label :frame-icon-and-text :children-labels [:component-1-icon-and-text])
|
(thc/instantiate-component :component-1 :copy-component-1
|
||||||
|
:parent-label :frame-icon-and-text
|
||||||
|
:children-labels [:component-1-icon-and-text])
|
||||||
(ths/add-sample-shape :text
|
(ths/add-sample-shape :text
|
||||||
{:type :text
|
{:type :text
|
||||||
:name "icon+text"
|
:name "icon+text"
|
||||||
:parent-label :frame-icon-and-text})
|
:parent-label :frame-icon-and-text})
|
||||||
(thc/make-component :icon-and-text :frame-icon-and-text)
|
(thc/make-component :icon-and-text :frame-icon-and-text)
|
||||||
|
|
||||||
(tho/add-frame :frame-panel)
|
(tho/add-frame :frame-panel :name "icon-and-text")
|
||||||
(thc/instantiate-component :icon-and-text :copy-icon-and-text :parent-label :frame-panel :children-labels [:icon-and-text-panel])
|
(thc/instantiate-component :icon-and-text :copy-icon-and-text
|
||||||
|
:parent-label :frame-panel
|
||||||
|
:children-labels [:icon-and-text-panel])
|
||||||
(thc/make-component :panel :frame-panel)
|
(thc/make-component :panel :frame-panel)
|
||||||
|
|
||||||
(thc/instantiate-component :panel :copy-panel :children-labels [:copy-icon-and-text-panel])))
|
(thc/instantiate-component :panel :copy-panel
|
||||||
|
:children-labels [:copy-icon-and-text-panel])))
|
||||||
|
|
||||||
(defn- propagate-all-component-changes [file]
|
(defn- propagate-all-component-changes [file]
|
||||||
(-> file
|
(-> file
|
||||||
|
|||||||
Reference in New Issue
Block a user