From c16ef39abfdb93857deb0a0d2b4106381d76ae9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Fri, 10 May 2024 19:02:55 +0200 Subject: [PATCH] :recycle: Make test helpers globally usable --- .../app/common/test_helpers}/components.cljc | 10 +++---- .../common/test_helpers}/compositions.cljc | 6 ++--- .../app/common/test_helpers}/files.cljc | 4 +-- .../app/common/test_helpers}/ids_map.cljc | 2 +- .../app/common/test_helpers}/shapes.cljc | 8 +++--- .../logic/chained_propagation_test.cljc | 27 ++++++------------- .../logic/comp_creation_test.cljc | 12 ++++----- .../logic/comp_remove_swap_slots_test.cljc | 11 ++++---- .../common_tests/logic/comp_reset_test.cljc | 12 ++++----- .../common_tests/logic/comp_sync_test.cljc | 15 +++++------ .../common_tests/logic/comp_touched_test.cljc | 12 ++++----- .../logic/swap_and_reset_test.cljc | 12 ++++----- .../types/types_libraries_test.cljc | 12 ++++----- 13 files changed, 64 insertions(+), 79 deletions(-) rename common/{test/common_tests/helpers => src/app/common/test_helpers}/components.cljc (96%) rename common/{test/common_tests/helpers => src/app/common/test_helpers}/compositions.cljc (98%) rename common/{test/common_tests/helpers => src/app/common/test_helpers}/files.cljc (98%) rename common/{test/common_tests/helpers => src/app/common/test_helpers}/ids_map.cljc (96%) rename common/{test/common_tests/helpers => src/app/common/test_helpers}/shapes.cljc (95%) diff --git a/common/test/common_tests/helpers/components.cljc b/common/src/app/common/test_helpers/components.cljc similarity index 96% rename from common/test/common_tests/helpers/components.cljc rename to common/src/app/common/test_helpers/components.cljc index 81d331660..b1c9c0513 100644 --- a/common/test/common_tests/helpers/components.cljc +++ b/common/src/app/common/test_helpers/components.cljc @@ -4,22 +4,22 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.helpers.components +(ns app.common.test-helpers.components (:require [app.common.data.macros :as dm] [app.common.files.changes-builder :as pcb] [app.common.files.helpers :as cfh] [app.common.geom.point :as gpt] [app.common.logic.libraries :as cll] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] [app.common.types.container :as ctn] [app.common.types.file :as ctf] [app.common.types.pages-list :as ctpl] - [app.common.types.shape-tree :as ctst] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [app.common.types.shape-tree :as ctst])) (defn make-component [file label root-label & {:keys [] :as params}] diff --git a/common/test/common_tests/helpers/compositions.cljc b/common/src/app/common/test_helpers/compositions.cljc similarity index 98% rename from common/test/common_tests/helpers/compositions.cljc rename to common/src/app/common/test_helpers/compositions.cljc index 21f4217d0..72ab0073f 100644 --- a/common/test/common_tests/helpers/compositions.cljc +++ b/common/src/app/common/test_helpers/compositions.cljc @@ -4,11 +4,11 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.helpers.compositions +(ns app.common.test-helpers.compositions (:require [app.common.data :as d] - [common-tests.helpers.components :as thc] - [common-tests.helpers.shapes :as ths])) + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.shapes :as ths])) (defn add-rect [file rect-label & {:keys [] :as params}] diff --git a/common/test/common_tests/helpers/files.cljc b/common/src/app/common/test_helpers/files.cljc similarity index 98% rename from common/test/common_tests/helpers/files.cljc rename to common/src/app/common/test_helpers/files.cljc index 31a887481..59b166555 100644 --- a/common/test/common_tests/helpers/files.cljc +++ b/common/src/app/common/test_helpers/files.cljc @@ -4,19 +4,19 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.helpers.files +(ns app.common.test-helpers.files (:require [app.common.data :as d] [app.common.features :as ffeat] [app.common.files.changes :as cfc] [app.common.files.validate :as cfv] [app.common.pprint :refer [pprint]] + [app.common.test-helpers.ids-map :as thi] [app.common.types.component :as ctk] [app.common.types.file :as ctf] [app.common.types.page :as ctp] [app.common.types.pages-list :as ctpl] [app.common.uuid :as uuid] - [common-tests.helpers.ids-map :as thi] [cuerdas.core :as str])) ;; ----- Files diff --git a/common/test/common_tests/helpers/ids_map.cljc b/common/src/app/common/test_helpers/ids_map.cljc similarity index 96% rename from common/test/common_tests/helpers/ids_map.cljc rename to common/src/app/common/test_helpers/ids_map.cljc index ccbbdb542..603229d9e 100644 --- a/common/test/common_tests/helpers/ids_map.cljc +++ b/common/src/app/common/test_helpers/ids_map.cljc @@ -4,7 +4,7 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.helpers.ids-map +(ns app.common.test-helpers.ids-map (:require [app.common.uuid :as uuid])) diff --git a/common/test/common_tests/helpers/shapes.cljc b/common/src/app/common/test_helpers/shapes.cljc similarity index 95% rename from common/test/common_tests/helpers/shapes.cljc rename to common/src/app/common/test_helpers/shapes.cljc index 53521cbe5..28e8c5d2c 100644 --- a/common/test/common_tests/helpers/shapes.cljc +++ b/common/src/app/common/test_helpers/shapes.cljc @@ -4,10 +4,12 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.helpers.shapes +(ns app.common.test-helpers.shapes (:require [app.common.colors :as clr] [app.common.files.helpers :as cfh] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] [app.common.types.color :as ctc] [app.common.types.colors-list :as ctcl] [app.common.types.file :as ctf] @@ -15,9 +17,7 @@ [app.common.types.shape :as cts] [app.common.types.shape-tree :as ctst] [app.common.types.typographies-list :as cttl] - [app.common.types.typography :as ctt] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi])) + [app.common.types.typography :as ctt])) (defn sample-shape [label & {:keys [type] :as params}] diff --git a/common/test/common_tests/logic/chained_propagation_test.cljc b/common/test/common_tests/logic/chained_propagation_test.cljc index f1db114a7..dc9a5ac91 100644 --- a/common/test/common_tests/logic/chained_propagation_test.cljc +++ b/common/test/common_tests/logic/chained_propagation_test.cljc @@ -6,21 +6,16 @@ (ns common-tests.logic.chained-propagation-test (:require - [app.common.files.changes :as ch] [app.common.files.changes-builder :as pcb] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] - [app.common.pprint :as pp] - [app.common.types.component :as ctk] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.container :as ctn] - [app.common.types.file :as ctf] - [app.common.uuid :as uuid] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) @@ -55,8 +50,6 @@ (step-update-color-comp-2 [file] (let [page (thf/current-page file) - file-id (:id file) - page-id (:id page) ;; Changes to update the color of the contained rectangle in component comp-2 changes-update-color-comp-1 @@ -75,7 +68,6 @@ (step-propagate-comp-2 [file] (let [page (thf/current-page file) file-id (:id file) - page-id (:id page) ;; Changes to propagate the color changes of component comp-1 changes-sync-comp-1 (-> (pcb/empty-changes) @@ -108,8 +100,7 @@ (:objects page) {}) - file' (thf/apply-changes file changes-update-color-comp-3) - page' (thf/current-page file')] + file' (thf/apply-changes file changes-update-color-comp-3)] (t/is (= (first-child-fill-color file' :comp-1-comp-2) "#00FF00")) file')) @@ -168,7 +159,6 @@ (step-update-color-comp-4 [file] (let [page (thf/current-page file) - file-id (:id file) ;; Changes to update the color of the contained rectangle in component comp-4 changes-update-color-comp-4 (cls/generate-update-shapes (pcb/empty-changes nil (:id page)) @@ -184,8 +174,7 @@ file')) (step-propagate-comp-4 [file] - (let [page (thf/current-page file) - file-id (:id file) + (let [file-id (:id file) ;; Changes to propagate the color changes of component comp-4 changes-sync-comp-4 (-> (pcb/empty-changes) (cll/generate-sync-file-changes diff --git a/common/test/common_tests/logic/comp_creation_test.cljc b/common/test/common_tests/logic/comp_creation_test.cljc index 6d3280533..c59c14bc1 100644 --- a/common/test/common_tests/logic/comp_creation_test.cljc +++ b/common/test/common_tests/logic/comp_creation_test.cljc @@ -12,15 +12,15 @@ [app.common.geom.point :as gpt] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] [app.common.types.shape-tree :as ctst] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) diff --git a/common/test/common_tests/logic/comp_remove_swap_slots_test.cljc b/common/test/common_tests/logic/comp_remove_swap_slots_test.cljc index 51a0fa008..f5cb012b4 100644 --- a/common/test/common_tests/logic/comp_remove_swap_slots_test.cljc +++ b/common/test/common_tests/logic/comp_remove_swap_slots_test.cljc @@ -10,19 +10,18 @@ [app.common.geom.point :as gpt] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.component :as ctk] [app.common.uuid :as uuid] [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths] [cuerdas.core :as str])) (t/use-fixtures :each thi/test-fixture) - ;; Related .penpot file: common/test/cases/remove-swap-slots.penpot (defn- setup-file [] diff --git a/common/test/common_tests/logic/comp_reset_test.cljc b/common/test/common_tests/logic/comp_reset_test.cljc index 3b7551a9f..d7f441ed9 100644 --- a/common/test/common_tests/logic/comp_reset_test.cljc +++ b/common/test/common_tests/logic/comp_reset_test.cljc @@ -9,12 +9,12 @@ [app.common.files.changes-builder :as pcb] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) diff --git a/common/test/common_tests/logic/comp_sync_test.cljc b/common/test/common_tests/logic/comp_sync_test.cljc index 1f3b8b4c2..75abacea3 100644 --- a/common/test/common_tests/logic/comp_sync_test.cljc +++ b/common/test/common_tests/logic/comp_sync_test.cljc @@ -8,19 +8,16 @@ (:require [app.common.data :as d] [app.common.files.changes-builder :as pcb] - [app.common.files.shapes-helpers :as cfsh] - [app.common.geom.point :as gpt] [app.common.logic.libraries :as cll] [app.common.logic.shapes :as cls] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.component :as ctk] - [app.common.types.components-list :as ctkl] [app.common.types.shape-tree :as ctst] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) diff --git a/common/test/common_tests/logic/comp_touched_test.cljc b/common/test/common_tests/logic/comp_touched_test.cljc index 1d21eae08..a0907e37c 100644 --- a/common/test/common_tests/logic/comp_touched_test.cljc +++ b/common/test/common_tests/logic/comp_touched_test.cljc @@ -8,12 +8,12 @@ (:require [app.common.files.changes-builder :as pcb] [app.common.logic.shapes :as cls] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) diff --git a/common/test/common_tests/logic/swap_and_reset_test.cljc b/common/test/common_tests/logic/swap_and_reset_test.cljc index 40d3c7ef8..c27a5b99e 100644 --- a/common/test/common_tests/logic/swap_and_reset_test.cljc +++ b/common/test/common_tests/logic/swap_and_reset_test.cljc @@ -8,14 +8,14 @@ (:require [app.common.files.changes-builder :as pcb] [app.common.logic.libraries :as cll] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.types.component :as ctk] [app.common.types.file :as ctf] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture) diff --git a/common/test/common_tests/types/types_libraries_test.cljc b/common/test/common_tests/types/types_libraries_test.cljc index 744a39518..ab13cf868 100644 --- a/common/test/common_tests/types/types_libraries_test.cljc +++ b/common/test/common_tests/types/types_libraries_test.cljc @@ -7,6 +7,11 @@ (ns common-tests.types.types-libraries-test (:require [app.common.data :as d] + [app.common.test-helpers.components :as thc] + [app.common.test-helpers.compositions :as tho] + [app.common.test-helpers.files :as thf] + [app.common.test-helpers.ids-map :as thi] + [app.common.test-helpers.shapes :as ths] [app.common.text :as txt] [app.common.types.colors-list :as ctcl] [app.common.types.component :as ctk] @@ -14,12 +19,7 @@ [app.common.types.file :as ctf] [app.common.types.pages-list :as ctpl] [app.common.types.typographies-list :as ctyl] - [clojure.test :as t] - [common-tests.helpers.components :as thc] - [common-tests.helpers.compositions :as tho] - [common-tests.helpers.files :as thf] - [common-tests.helpers.ids-map :as thi] - [common-tests.helpers.shapes :as ths])) + [clojure.test :as t])) (t/use-fixtures :each thi/test-fixture)