diff --git a/frontend/src/app/plugins/text.cljs b/frontend/src/app/plugins/text.cljs index 26e13b1039..597833619b 100644 --- a/frontend/src/app/plugins/text.cljs +++ b/frontend/src/app/plugins/text.cljs @@ -33,7 +33,7 @@ (def ^:private font-size-re #"^\d*\.?\d*$") (def ^:private line-height-re #"^\d*\.?\d*$") -(def ^:private letter-spacing-re #"^\d*\.?\d*$") +(def ^:private letter-spacing-re #"^-?\d*\.?\d*$") (def ^:private text-transform-re #"uppercase|capitalize|lowercase|none") (def ^:private text-decoration-re #"underline|line-through|none") (def ^:private text-direction-re #"ltr|rtl") diff --git a/frontend/test/frontend_tests/plugins/text_test.cljs b/frontend/test/frontend_tests/plugins/text_test.cljs new file mode 100644 index 0000000000..edcfbf853d --- /dev/null +++ b/frontend/test/frontend_tests/plugins/text_test.cljs @@ -0,0 +1,37 @@ +;; 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 INC + +(ns frontend-tests.plugins.text-test + (:require + [app.plugins.text :as plugins.text] + [cljs.test :as t :include-macros true])) + +;; Regression coverage for issue #9780. +;; +;; `letterSpacing` accepts negative tracking in the product UI (-200..200, +;; see typography.cljs), but the plugin validator regex rejected any leading +;; minus, so negative values were refused. `letter-spacing-re` is the shared +;; predicate behind both the shape- and range-level setters; pin its +;; accept/reject contract here. + +(def ^:private letter-spacing-re @#'plugins.text/letter-spacing-re) + +(defn- valid? [s] (boolean (re-matches letter-spacing-re s))) + +(t/deftest letter-spacing-re-accepts-negative-values + (t/is (valid? "-0.56")) + (t/is (valid? "-12")) + (t/is (valid? "-200"))) + +(t/deftest letter-spacing-re-accepts-non-negative-values + (t/is (valid? "0")) + (t/is (valid? "12")) + (t/is (valid? "1.5"))) + +(t/deftest letter-spacing-re-rejects-non-numeric + (t/is (not (valid? "abc"))) + (t/is (not (valid? "1-2"))) + (t/is (not (valid? "--1")))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index b3b16a2079..154dd95ad9 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -33,6 +33,7 @@ [frontend-tests.plugins.page-active-validation-test] [frontend-tests.plugins.page-test] [frontend-tests.plugins.parser-test] + [frontend-tests.plugins.text-test] [frontend-tests.plugins.tokens-test] [frontend-tests.plugins.utils-test] [frontend-tests.render-wasm.process-objects-test] @@ -89,6 +90,7 @@ frontend-tests.plugins.format-test frontend-tests.plugins.page-test frontend-tests.plugins.parser-test + frontend-tests.plugins.text-test frontend-tests.plugins.tokens-test frontend-tests.plugins.utils-test frontend-tests.svg-fills-test