From aa292e4829d77f72cd5c9a04f05b844700b92ff6 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Tue, 10 Dec 2024 14:04:32 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20active=20sets=20?= =?UTF-8?q?in=20set=20groups=20showing=20partial=20selection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/app/common/types/tokens_lib.cljc | 7 ++++--- common/test/common_tests/types/tokens_lib_test.cljc | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 7495ccac2..484d9c81d 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -882,9 +882,10 @@ Will return a value that matches this schema: (map :name) (into #{})) difference (set/difference path-active-set-names active-set-names)] - (if (empty? difference) - :all - :partial)) + (cond + (empty? difference) :all + (seq (set/intersection path-active-set-names active-set-names)) :partial + :else :none)) :none))) (get-active-themes-set-tokens [this] diff --git a/common/test/common_tests/types/tokens_lib_test.cljc b/common/test/common_tests/types/tokens_lib_test.cljc index 96f124772..f11829d98 100644 --- a/common/test/common_tests/types/tokens_lib_test.cljc +++ b/common/test/common_tests/types/tokens_lib_test.cljc @@ -412,7 +412,9 @@ :sets #{"foo/bar/baz"})) (ctob/add-theme (ctob/make-token-theme :name "all" :sets #{"foo/bar/baz" - "foo/bar/bam"}))) + "foo/bar/bam"})) + (ctob/add-theme (ctob/make-token-theme :name "invalid" + :sets #{"foo/missing"}))) expected-none (-> tokens-lib (ctob/set-active-themes #{"/none"}) @@ -422,10 +424,14 @@ (ctob/sets-at-path-all-active? "G-foo")) expected-partial (-> tokens-lib (ctob/set-active-themes #{"/partial"}) - (ctob/sets-at-path-all-active? "G-foo"))] + (ctob/sets-at-path-all-active? "G-foo")) + expected-invalid-none (-> tokens-lib + (ctob/set-active-themes #{"/invalid"}) + (ctob/sets-at-path-all-active? "G-foo"))] (t/is (= :none expected-none)) (t/is (= :all expected-all)) - (t/is (= :partial expected-partial))))) + (t/is (= :partial expected-partial)) + (t/is (= :none expected-invalid-none))))) (t/deftest token-theme-in-a-lib (t/testing "add-token-theme"