diff --git a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc index 555f64807d..1cd2e765fc 100644 --- a/common/src/app/common/test_helpers/composable/comp/undo_check.cljc +++ b/common/src/app/common/test_helpers/composable/comp/undo_check.cljc @@ -169,6 +169,12 @@ (into (entities-signature :component (:components ed) (:components ad) #{} (constantly nil))))))) +(defn- corner-order + "The corners of a bool by their rounded position: a bool computes them + again from its children, in any order." + [points] + (sort-by (juxt #(Math/round (* 100.0 (:x %))) #(Math/round (* 100.0 (:y %)))) points)) + (defn same-state? "Compare exact data with an absolute tolerance only in shape geometry. Undo defaults to 1e-10; design equivalence can supply its own tolerance." @@ -188,7 +194,12 @@ (and (map? expected) (map? actual) (= (set (keys expected)) (set (keys actual)))) (every? (fn [key] - (same-state? (get expected key) (get actual key) + (same-state? (cond-> (get expected key) + (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) + corner-order) + (cond-> (get actual key) + (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) + corner-order) ;; a bool or path stores its segments in single precision, and ;; a bool computes them again from its children (if (and (contains? expected :parent-id) (#{:bool :path} (:type expected))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 292d776ab9..7eacbb786b 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2360,6 +2360,12 @@ :grid-empty false :layout-copies false :text false}] :ops [[:nest 4] [:resize 1] [:style 15 9 3]]})))) +(t/deftest undoing-an-edit-compares-the-corners-of-a-copy-bool-in-any-order + (t/is (map? (cg/run {:world [3 1 {:variants true :rich-variants true :text true :layout nil + :layout-copies true :layout-children false}] + :ops [[:detach 0 0 0 0] [:detach 14 0 0 0] [:add-child 0] [:structure 9 4 0] + [:transform 7 16 0 4] [:edit 21 0 1 1] [:update-main 21]]})))) + (t/deftest unmasking-in-a-flex-main-leaves-its-layout-as-the-unmask-event-does (t/is (map? (cg/run {:world [2 0 {:variants false :rich-variants false :text true :layout :flex :layout-copies false :layout-children true}]