diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 6fb2391a09..69f72593b3 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -764,7 +764,7 @@ component-id variant-id variant-properties - {}) + []) (dwva/remove-empty-properties variant-id) (dwva/update-error component-id name))))))) diff --git a/frontend/test/frontend_tests/logic/rename_variant_test.cljs b/frontend/test/frontend_tests/logic/rename_variant_test.cljs new file mode 100644 index 0000000000..95c6e95699 --- /dev/null +++ b/frontend/test/frontend_tests/logic/rename_variant_test.cljs @@ -0,0 +1,44 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS SUBSIDIARY SL + +(ns frontend-tests.logic.rename-variant-test + (:require + [app.common.test-helpers.files :as cthf] + [app.common.test-helpers.shapes :as cths] + [app.common.test-helpers.variants :as cthv] + [app.main.data.workspace :as dw] + [cljs.test :as t :include-macros true] + [frontend-tests.helpers.pages :as thp] + [frontend-tests.helpers.state :as ths])) + +(t/use-fixtures :each + {:before thp/reset-idmap!}) + +(t/deftest rename-variant-with-invalid-name + "Renaming a variant in the layers panel to a name that is not a valid + properties formula marks it with :variant-error. Each step of the event + chain is validated, so a validation error here fails the test through the + store error handler." + (t/async + done + (let [;; ==== Setup + file (-> (cthf/sample-file :file1) + (cthv/add-variant-two-properties :v01 :c01 :m01 :c02 :m02)) + store (ths/setup-store file) + main (cths/get-shape file :m01) + + ;; ==== Action + events [(dw/rename-shape-or-variant (:id main) "hola")]] + + (ths/run-store + store done events + (fn [new-state] + (let [;; ==== Get + file' (ths/get-file-from-state new-state) + main' (cths/get-shape file' :m01)] + + ;; ==== Check + (t/is (= "hola" (:variant-error main'))))))))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 7442211027..6ee139f576 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -62,6 +62,7 @@ [frontend-tests.logic.path-helpers-test] [frontend-tests.logic.path-lifecycle-test] [frontend-tests.logic.path-tools-test] + [frontend-tests.logic.rename-variant-test] [frontend-tests.logic.sidebar-transform-coalescing-test] [frontend-tests.logic.transform-in-variant-test] [frontend-tests.logic.update-position-test] @@ -231,6 +232,7 @@ 'frontend-tests.logic.path-helpers-test 'frontend-tests.logic.path-lifecycle-test 'frontend-tests.logic.path-tools-test + 'frontend-tests.logic.rename-variant-test 'frontend-tests.logic.pasting-in-containers-test 'frontend-tests.logic.transform-in-variant-test 'frontend-tests.main.refs-test