diff --git a/common/src/app/common/logic/variant_properties.cljc b/common/src/app/common/logic/variant_properties.cljc index ad48a06140..40f894ca06 100644 --- a/common/src/app/common/logic/variant_properties.cljc +++ b/common/src/app/common/logic/variant_properties.cljc @@ -95,11 +95,17 @@ props (:variant-properties component) name (-> props (update pos assoc :value value) - ctv/properties-to-name)] + ctv/properties-to-name) + + ids-to-validate [main-id (:variant-id component)]] (-> changes (pcb/update-component component-id #(assoc-in % [:variant-properties pos :value] value) {:apply-changes-local-library? true}) - (pcb/update-shapes [main-id] #(assoc % :variant-name name)))) + (pcb/update-shapes [main-id] #(assoc % :variant-name name)) + (pcb/validate-shapes (pcb/get-page-id changes) + ids-to-validate + (str "generate-update-property-value: " component-id + " pos: " pos " value: " value)))) changes)))) (defn generate-set-variant-error diff --git a/common/test/common_tests/logic/variant_properties_test.cljc b/common/test/common_tests/logic/variant_properties_test.cljc index 404e459d51..78447bf3b8 100644 --- a/common/test/common_tests/logic/variant_properties_test.cljc +++ b/common/test/common_tests/logic/variant_properties_test.cljc @@ -756,3 +756,42 @@ (t/is (str/includes? (:hint error) "generate-remove-property")) (t/is (contains? (error-codes error) :invalid-variant-properties))))) + +#?(:cljs + (t/deftest test-update-property-value-validates-main + (let [file (-> (thf/sample-file :file1) + (thv/add-variant-two-properties :v01 :c01 :m01 :c02 :m02) + (ths/update-shape :m01 :variant-id (uuid/next))) + page (thf/current-page file) + c01-id (:id (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-update-property-value c01-id 0 "NewValue")) + + error (validation-error file changes)] + + (t/is (str/includes? (:hint error) "generate-update-property-value")) + (t/is (contains? (error-codes error) :variant-component-bad-id))))) + +#?(:cljs + (t/deftest test-update-property-value-validates-container + (let [file (-> (thf/sample-file :file1) + (thv/add-variant-two-properties :v01 :c01 :m01 :c02 :m02) + (thc/update-component :c02 {:variant-properties [{:name "Other" :value "p1v2"} + {:name "Property 2" :value "p2v2"}]})) + page (thf/current-page file) + c01-id (:id (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-update-property-value c01-id 0 "NewValue")) + + error (validation-error file changes)] + + (t/is (str/includes? (:hint error) "generate-update-property-value")) + (t/is (contains? (error-codes error) :invalid-variant-properties)))))