🔧 Validate the variant when renaming or removing a property

generate-update-property-name and generate-remove-property change all
the components of the variant, and validated each main instance. The
container validation checks every main instance too, and also that all
the components keep the same property names, which is what these
functions may break. Validate the container instead.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
Eva Marco 2026-10-01 13:47:29 +02:00 committed by Andrés Moya
parent 743431bd42
commit 8a3dd86c72
2 changed files with 10 additions and 8 deletions

View File

@ -42,11 +42,11 @@
changes
related-components)
ids-to-validate (map :main-instance-id related-components)
;; All components of the variant change, so validate the
;; container, which also checks every main instance
changes (pcb/validate-shapes changes
(pcb/get-page-id changes)
ids-to-validate
[variant-id]
(str "generate-update-property-name: " variant-id
" pos: " pos " new-name: " new-name))]
changes)))))))
@ -74,11 +74,11 @@
changes
related-components)
ids-to-validate (map :main-instance-id related-components)
;; All components of the variant change, so validate the
;; container, which also checks every main instance
changes (pcb/validate-shapes changes
(pcb/get-page-id changes)
ids-to-validate
[variant-id]
(str "generate-remove-property: " variant-id " pos: " pos))]
changes)
changes))))

View File

@ -79,7 +79,8 @@
(t/is (= (-> comp01' :variant-properties first :name) "NewName1"))
(t/is (= (-> comp01' :variant-properties last :name) "NewName2"))
(t/is (= (-> comp02' :variant-properties first :name) "NewName1"))
(t/is (= (-> comp02' :variant-properties last :name) "NewName2"))))
(t/is (= (-> comp02' :variant-properties last :name) "NewName2"))
(t/is (thf/validates-shapes-last? changes (:id page) [v-id]))))
(t/deftest test-update-property-name-duplicate
(let [file (-> (thf/sample-file :file1)
@ -188,7 +189,8 @@
(t/is (= (count (:variant-properties comp01')) 1))
(t/is (= (count (:variant-properties comp02)) 2))
(t/is (= (count (:variant-properties comp02')) 1))
(t/is (= (-> comp01' :variant-properties first :name) "Property 2"))))
(t/is (= (-> comp01' :variant-properties first :name) "Property 2"))
(t/is (thf/validates-shapes-last? changes (:id page) [v-id]))))
;; =============================================================================
;; generate-update-property-value tests