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 e267337d4c..81ef0740d1 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 @@ -194,7 +194,11 @@ (and (map? expected) (map? actual) (= (set (keys expected)) (set (keys actual)))) (every? (fn [key] - (same-state? (cond-> (get expected key) + (or + ;; a bool computes its segments from its children, in an order + ;; that depends on how it computed them; its children are compared + (and (= :content key) (= :bool (:type expected)) (contains? expected :parent-id)) + (same-state? (cond-> (get expected key) (and (= :points key) (= :bool (:type expected)) (contains? expected :parent-id)) corner-order) (cond-> (get actual key) @@ -210,7 +214,7 @@ (or (contains? #{:x :y :width :height :rotation :points :selrect :transform :transform-inverse} key) ;; the segments of a bool or path are its geometry - (and (= :content key) (#{:bool :path} (:type expected)))))))) + (and (= :content key) (#{:bool :path} (:type expected))))))))) (keys expected)) (and (sequential? expected) (sequential? actual) (= (count expected) (count actual))) diff --git a/common/src/app/common/test_helpers/composable/gen.cljc b/common/src/app/common/test_helpers/composable/gen.cljc index 5e8d512587..7e8d2dbd64 100644 --- a/common/src/app/common/test_helpers/composable/gen.cljc +++ b/common/src/app/common/test_helpers/composable/gen.cljc @@ -1030,8 +1030,12 @@ :resize (ctm/change-size shape nil (:value op)) :rotate (n/geometry-modifiers shape :rotate (:angle op)) (:transform :library-transform) (n/geometry-modifiers shape (:action op) (:value op))) - tree (gm/set-objects-modifiers {(:id shape) {:modifiers modifiers}} objects)] - (gsh/transform-shape shape (get-in tree [(:id shape) :modifiers])))) + parent (get objects (:parent-id shape)) + ;; the mask of a group passes its change to the group and back, so + ;; the tree would apply it twice; only its group places it + mask? (and (:masked-group parent) (= (:id shape) (first (:shapes parent)))) + tree (when-not mask? (gm/set-objects-modifiers {(:id shape) {:modifiers modifiers}} objects))] + (gsh/transform-shape shape (if mask? modifiers (get-in tree [(:id shape) :modifiers]))))) (defn- kind-file "The file an operation edits: the library `library-id`, or the current one." diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index 87a12519a5..32506ac0ac 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -628,8 +628,16 @@ (fn [result id groups] (let [old (get before id) shape (get after id) - parent (get before (:parent-id old)) - new-parent (get after (:parent-id shape))] + ;; a group or bool takes its bounds and turn from its children, + ;; so they take their place from the board around it + board (fn [objects shape] + (let [parent (get objects (:parent-id shape)) + frame (get objects (:frame-id shape))] + (if (and (#{:group :bool} (:type parent)) (not (ctl/any-layout? frame))) + frame + parent))) + parent (when old (board before old)) + new-parent (when shape (board after shape))] (if (and (:geometry-group groups) old shape (= (:parent-id old) (:parent-id shape)) parent new-parent) (if-let [expected (authored-placement (:geometry-group groups) new-parent)] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 18311a8d96..28932efbce 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2530,6 +2530,11 @@ :ops [[:remove-child 9] [:add-child 7] [:delete 7] [:add-child] [:undo] [:structure 10 1] [:transform 10 5 0 2]]})))) +(t/deftest undoing-an-update-main-compares-a-bool-by-its-children-not-its-segments + (t/is (map? (cg/run {:world [1 1 {:variants false :rich-variants false :text false :layout nil + :layout-copies false :layout-children false}] + :ops [[:transform 0 5 0 3] [:structure 0 5] [:update-main]]})))) + (t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place (t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid :layout-copies true :layout-children true}]