From 11d7a630dcd72a6ccebbcd586939670ed430b9c8 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 27 Oct 2026 15:22:28 +0100 Subject: [PATCH] :bug: Restore migration and test compatibility after rebase Keep the container root helper used by the main-instance name migration. Adapt imported-file ids and component swap tests to the current APIs, and check copied swaps through their position refs and swap groups. AI-assisted-by: gpt-6 --- backend/test/backend_tests/binfile_test.clj | 6 ++--- common/src/app/common/types/container.cljc | 4 +++ .../logic/comp_flex_interactions_test.cljc | 25 ++++++------------- .../logic/comp_move_swapped_copies_test.cljs | 16 ++++++------ 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/backend/test/backend_tests/binfile_test.clj b/backend/test/backend_tests/binfile_test.clj index 1e39a80de2..f8fda798f4 100644 --- a/backend/test/backend_tests/binfile_test.clj +++ b/backend/test/backend_tests/binfile_test.clj @@ -13,11 +13,11 @@ [app.common.data :as d] [app.common.features :as cfeat] [app.common.files.changes-builder :as pcb] - [app.common.files.tokens :as cfo] - [app.common.files.validate :as cfv] [app.common.files.comp-processors :as cfcp] [app.common.files.migrations :as fmg] [app.common.files.swap-slots :as cfss] + [app.common.files.tokens :as cfo] + [app.common.files.validate :as cfv] [app.common.pprint :as pp] [app.common.test-helpers.components :as cthc] [app.common.test-helpers.compositions :as ctho] @@ -2960,7 +2960,7 @@ (assoc ::bfc/team-id (:default-team-id profile)) (assoc ::bfc/input input))] (case version - 1 (vec (v1/import-files! cfg)) + 1 (:file-ids (v1/import-files! cfg)) 3 (:file-ids (v3/import-files! cfg))))) (defn- import-error diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 24e23cc28e..65d1a2e664 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -94,6 +94,10 @@ [container shape-id f] (update-in container [:objects shape-id] f)) +(defn get-container-root + [container] + (d/seek #(or (nil? (:parent-id %)) (= (:parent-id %) uuid/zero)) (shapes-seq container))) + (defn get-direct-children [container shape] (map #(get-shape container %) (:shapes shape))) diff --git a/common/test/common_tests/logic/comp_flex_interactions_test.cljc b/common/test/common_tests/logic/comp_flex_interactions_test.cljc index 757c3c7dba..56427c8b40 100644 --- a/common/test/common_tests/logic/comp_flex_interactions_test.cljc +++ b/common/test/common_tests/logic/comp_flex_interactions_test.cljc @@ -11,6 +11,7 @@ [app.common.geom.shapes :as gsh] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] + [app.common.logic.variants :as clv] [app.common.math :as mth] [app.common.test-helpers.components :as thc] [app.common.test-helpers.compositions :as tho] @@ -160,22 +161,12 @@ [file library shape-label new-component-label] (let [shape (ths/get-shape file shape-label) page (thf/current-page file) - keep-props-values (select-keys shape ctk/swap-keep-attrs) libraries {(:id library) library (:id file) file} id-new (:id (thc/get-component library new-component-label)) - [_ _ changes] (cll/generate-component-swap + [_ changes _] (clv/generate-component-swap-in-place (pcb/empty-changes nil (:id page)) - (:objects page) - shape - (:data library) - page - libraries - id-new - 0 - nil - keep-props-values - false)] + page libraries (:data library) shape id-new false)] (thf/apply-changes file changes))) (defn- setup-library-with-absolute-nested-icon @@ -211,13 +202,13 @@ ;; ==== Check (t/is (true? (:layout-item-absolute swapped))) - (t/is (some? (ctk/get-swap-slot swapped))) + (t/is (ctk/swapped? swapped)) (t/is (= (thi/id :icon-b) (:component-id swapped))) - (t/is (some? (ctk/get-swap-slot swapped'))) + (t/is (ctk/swapped? swapped')) (t/is (= (thi/id :icon-b) (:component-id swapped'))) (t/is (true? (:layout-item-absolute swapped'))))) -(t/deftest test-sync-library-propagates-slot-absolute-to-swapped-nested +(t/deftest test-sync-library-propagates-position-absolute-to-swapped-nested (let [;; ==== Setup library (setup-library-with-absolute-nested-icon) file (-> (thf/sample-file :file) @@ -234,7 +225,7 @@ swapped' (ths/get-shape file' :copy-nested-head)] ;; ==== Check - (t/is (some? (ctk/get-swap-slot swapped'))) + (t/is (ctk/swapped? swapped')) (t/is (= (thi/id :icon-b) (:component-id swapped'))) (t/is (not (true? (:layout-item-absolute swapped')))))) @@ -268,4 +259,4 @@ ;; ==== Check (t/is (= margin (:layout-item-margin sibling'))) (t/is (true? (:layout-item-absolute swapped'))) - (t/is (some? (ctk/get-swap-slot swapped'))))) + (t/is (ctk/swapped? swapped')))) diff --git a/frontend/test/frontend_tests/logic/comp_move_swapped_copies_test.cljs b/frontend/test/frontend_tests/logic/comp_move_swapped_copies_test.cljs index 2f650c0ba3..9f38d7fb8f 100644 --- a/frontend/test/frontend_tests/logic/comp_move_swapped_copies_test.cljs +++ b/frontend/test/frontend_tests/logic/comp_move_swapped_copies_test.cljs @@ -872,7 +872,7 @@ (t/is (not (ctk/swapped? copied-blue1'))))))))) -(t/deftest test-keep-inherited-swap-slot-copy-paste-nested-copy-to-root +(t/deftest test-keep-inherited-swap-group-copy-paste-nested-copy-to-root (t/async done (let [;; ==== Setup @@ -934,12 +934,13 @@ ;; ==== Check ;; the copied icon now refers to the icon main, where blue - ;; does not exist, so the copied blue must keep the swap slot - ;; inherited from :blue-copy-title + ;; does not exist, so the copied blue must keep the position + ;; reference inherited from :blue-copy-title and its swap group. (t/is (some? copied-icon')) (t/is (= (:shape-ref copied-icon') (cthi/id :frame-icon))) (t/is (some? copied-blue')) - (t/is (= (ctk/get-swap-slot copied-blue') (cthi/id :red-copy-icon))) + (t/is (= (:shape-ref copied-blue') (cthi/id :red-copy-icon))) + (t/is (ctk/swapped? copied-blue')) ;; the file must be valid after the paste (t/is (nil? errors)))))))) @@ -985,7 +986,7 @@ (t/is (contains? (:touched copied-red') :fill-group)) (t/is (= (:touched red') (:touched copied-red'))))))))) -(t/deftest test-remove-swap-slot-copy-paste-nested-swapped-copy-to-root +(t/deftest test-remove-swap-group-copy-paste-nested-swapped-copy-to-root (t/async done (let [;; ==== Setup (sample file as is) @@ -1014,6 +1015,7 @@ copied-blue' (find-copied-shape blue' page' uuid/zero)] ;; ==== Check - ;; the copied blue has no swap-id + ;; The copied blue refers to its own main and has no swap override. (t/is (some? copied-blue')) - (t/is (nil? (ctk/get-swap-slot copied-blue'))))))))) + (t/is (not (ctk/swapped? copied-blue'))) + (t/is (= (:shape-ref copied-blue') (cthi/id :frame-blue)))))))))