From c16b439af9a322bed15fc423001e7964a7d7e9f0 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 30 Sep 2026 16:51:43 +0200 Subject: [PATCH] :wrench: Validate shapes after removing them from a variant generate-make-shapes-no-variant now validates the main instances it takes out of the variant. Only those main instances change. The old container is not validated, as callers such as generate-relocate call this function before they move the shapes out of it. Check with thf/validates-shapes-last? that the function validates the expected page and shapes. AI-assisted-by: claude-opus-5-5 --- .../app/common/logic/variant_properties.cljc | 9 ++++++++- .../logic/variant_properties_test.cljc | 20 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/logic/variant_properties.cljc b/common/src/app/common/logic/variant_properties.cljc index f38b357167..fb168abec8 100644 --- a/common/src/app/common/logic/variant_properties.cljc +++ b/common/src/app/common/logic/variant_properties.cljc @@ -235,7 +235,14 @@ "Extract some components from a variant, removing the variant-id and variant-name from the main instances and the variant-id and variant-properties from the components." [changes shapes] - (reduce generate-make-shape-no-variant changes shapes)) + (if (empty? shapes) + changes + ;; Only the extracted main instances change. The container is not + ;; validated, as the caller may not have moved the shapes out of it yet + (-> (reduce generate-make-shape-no-variant changes shapes) + (pcb/validate-shapes (pcb/get-page-id changes) + (mapv :id shapes) + (str "generate-make-shapes-no-variant: " (mapv :id shapes)))))) (defn- create-new-properties-from-variant [shape min-props data container-name base-properties] diff --git a/common/test/common_tests/logic/variant_properties_test.cljc b/common/test/common_tests/logic/variant_properties_test.cljc index 2880ad1a93..67f225bc79 100644 --- a/common/test/common_tests/logic/variant_properties_test.cljc +++ b/common/test/common_tests/logic/variant_properties_test.cljc @@ -655,7 +655,25 @@ (t/is (nil? (:variant-id comp01'))) (t/is (nil? (:variant-properties comp01'))) (t/is (nil? (:variant-id main01'))) - (t/is (nil? (:variant-name main01'))))) + (t/is (nil? (:variant-name main01'))) + (t/is (thf/validates-shapes-last? changes (:id page) [(:id main01)])))) + +(t/deftest test-make-shapes-no-variant-validates-shapes + (let [file (-> (thf/sample-file :file1) + (thv/add-variant :v01 :c01 :m01 :c02 :m02)) + page (thf/current-page file) + main01 (ths/get-shape file :m01) + main02 (ths/get-shape file :m02) + + changes (-> (pcb/empty-changes nil) + (pcb/with-page-id (:id page)) + (pcb/with-library-data (:data file)) + (pcb/with-objects (:objects page)) + (clvp/generate-make-shapes-no-variant [main01 main02]))] + + ;; Only the extracted main instances change. The container is not + ;; validated, as the caller may not have moved the shapes out of it yet + (t/is (thf/validates-shapes-last? changes (:id page) [(:id main01) (:id main02)])))) ;; ============================================================================= ;; generate-make-shapes-variant tests