mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 06:20:32 +00:00
🔧 Validate shapes after setting a variant error
generate-set-variant-error now validates the main instance of the component once its :variant-error is set or cleared. The change only touches that main instance, so there is no need to validate the whole variant container. Check with thf/validates-shapes-last? that the function validates the expected page and shapes. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
c034838a42
commit
116ca85ea2
@ -119,7 +119,11 @@
|
||||
(-> changes
|
||||
(pcb/update-shapes [main-id] (if (nil? value)
|
||||
#(dissoc % :variant-error)
|
||||
#(assoc % :variant-error value)))))
|
||||
#(assoc % :variant-error value)))
|
||||
(pcb/validate-shapes (pcb/get-page-id changes)
|
||||
[main-id]
|
||||
(str "generate-set-variant-error: " component-id
|
||||
" value: " value))))
|
||||
changes))))
|
||||
|
||||
(defn generate-reorder-variant-poperties
|
||||
|
||||
@ -335,7 +335,8 @@
|
||||
|
||||
main01' (ths/get-shape file' :m01)]
|
||||
|
||||
(t/is (= "MyError" (:variant-error main01')))))
|
||||
(t/is (= "MyError" (:variant-error main01')))
|
||||
(t/is (thf/validates-shapes-last? changes (:id page) [(:main-instance-id comp01)]))))
|
||||
|
||||
(t/deftest test-set-variant-error-add-and-clear
|
||||
(let [file (-> (thf/sample-file :file1)
|
||||
@ -356,7 +357,24 @@
|
||||
|
||||
main01' (ths/get-shape file' :m01)]
|
||||
|
||||
(t/is (nil? (:variant-error main01')))))
|
||||
(t/is (nil? (:variant-error main01')))
|
||||
;; The last call, which clears the error, validates the same main instance
|
||||
(t/is (thf/validates-shapes-last? changes (:id page) [(:main-instance-id comp01)]))))
|
||||
|
||||
(t/deftest test-set-variant-error-validates-main
|
||||
(let [file (-> (thf/sample-file :file1)
|
||||
(thv/add-variant :v01 :c01 :m01 :c02 :m02))
|
||||
page (thf/current-page file)
|
||||
comp01 (thc/get-component file :c01)
|
||||
|
||||
changes (-> (pcb/empty-changes nil)
|
||||
(pcb/with-page-id (:id page))
|
||||
(pcb/with-library-data (:data file))
|
||||
(pcb/with-objects (:objects page))
|
||||
(clvp/generate-set-variant-error (:id comp01) "MyError"))]
|
||||
|
||||
;; Only the main instance of the component changes
|
||||
(t/is (thf/validates-shapes-last? changes (:id page) [(:main-instance-id comp01)]))))
|
||||
|
||||
;; =============================================================================
|
||||
;; generate-reorder-variant-poperties tests
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user