From 8a3dd86c728099bc28b740042db3b0b98918ee90 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Thu, 1 Oct 2026 13:47:29 +0200 Subject: [PATCH] :wrench: 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 --- common/src/app/common/logic/variant_properties.cljc | 12 ++++++------ .../common_tests/logic/variant_properties_test.cljc | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/logic/variant_properties.cljc b/common/src/app/common/logic/variant_properties.cljc index 8bdda182e1..c7c58e8677 100644 --- a/common/src/app/common/logic/variant_properties.cljc +++ b/common/src/app/common/logic/variant_properties.cljc @@ -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)))) diff --git a/common/test/common_tests/logic/variant_properties_test.cljc b/common/test/common_tests/logic/variant_properties_test.cljc index be7a83c411..d300f77349 100644 --- a/common/test/common_tests/logic/variant_properties_test.cljc +++ b/common/test/common_tests/logic/variant_properties_test.cljc @@ -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