diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index b1d9ce0d2a..9a98a73196 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -485,18 +485,19 @@ [group (if (= :geometry-group group) geometry (values shape group))])) placement)) - ;; a main shape the push keeps or adds turns with its main - ;; afterwards; its pushed geometry leaves out the turn its copy - ;; parent shows against its main parent (the root's, against - ;; its main), which an added main shape has only after the push + ;; a main shape the push keeps turns with its main afterwards; + ;; its pushed geometry leaves out the turn its copy parent shows + ;; against its main parent (the root's, against its main). A + ;; main shape the push adds takes its parent's turn after the push (and (:geometry-group groups) (not pushed-swap?)) (update :geometry-group (fn [geometry] (if (= (:id shape) root-id) (in-orientation geometry root main-root) (in-orientation geometry (get before (:parent-id shape)) - (or (get before (:parent-id ref)) - (get after (:parent-id ref)))))))) + (if (contains? before (:id ref)) + (get before (:parent-id ref)) + (get after (:parent-id ref)))))))) ;; a variant main keeps its set's name, and the copy root its own kept-name (when (and (= id root-id) (:variant-id ref)) (:name-group groups)) groups (cond-> groups kept-name (dissoc :name-group)) @@ -815,11 +816,18 @@ :else (same? (get old-placed attr) (get placed attr)))) + ;; the same turn of two mirrors differs where they point + ;; their axes apart + differs? (fn [attr] + (or (not (same? (get old attr) (get placed attr))) + (and (= attr :rotation) (not root?) old-parent new-parent + (mirrored? old) (mirrored? placed) + (not (geom/same-placed-axes? old old-parent new-parent + main (get after (:parent-id main)) new-parent))))) carried (filter (fn [attr] - (let [new-value (get placed attr)] - (and (attribute-applicable? main attr) - (agrees? attr) - (not (same? (get old attr) new-value))))) attrs)] + (and (attribute-applicable? main attr) + (agrees? attr) + (differs? attr))) attrs)] (cond-> result (seq carried) (assoc-in [(:id shape) group] diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 7a53f2e5aa..d5f32d48ba 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2194,6 +2194,21 @@ :layout-children false :grid-empty false :layout-copies false :text true}] :ops [[:swap] [:make-variant 12] [:rotate] [:delete] [:transform 6 5] [:switch]]})))) +(t/deftest switching-a-copy-carries-a-mirrored-turn-that-shares-the-new-copys-rotation + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles false :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies false :text true}] + :ops [[:swap] [:make-variant 12] [:rotate 0 0 1] [:delete] [:transform 6 5] + [:transform 3 9 7 13] [:switch]]})))) + +(t/deftest updating-a-turned-main-from-a-swapped-head-turns-the-new-head-with-its-parent + (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles false :layout :flex :variant-diff false + :layout-item-margins false :grid-square false :rich-variants false + :layout-children false :grid-empty false :layout-copies false :text true}] + :ops [[:combine 10] [:combine 1] [:rotate 8] [:combine 13] [:combine 8] [:switch] + [:combine 18] [:make-variant] [:switch 18] [:combine] [:rotate 8] + [:update-main]]})))) + (t/deftest pushing-a-grid-direction-orders-the-copies-like-the-reflowed-main (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles false :layout :grid :variant-diff false :layout-item-margins false :grid-square true :rich-variants false