0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

♻️ Refactor tests directory structure

This commit is contained in:
Andrey Antukh 2022-11-08 10:40:19 +01:00 committed by Andrés Moya
parent 12e2d3ad96
commit 3ef99c287e
45 changed files with 170 additions and 116 deletions

View file

@ -62,19 +62,19 @@ jobs:
name: common tests
command: |
yarn install
yarn run compile-test
node target/test.js
clojure -X:dev:test :patterns '["common-tests.test-.*"]'
yarn test
clojure -X:dev:test :patterns '["common-tests.*-test"]'
environment:
PATH: /usr/local/nodejs/bin/:/usr/local/bin:/bin:/usr/bin
JVM_OPTS: -Xmx4g
NODE_OPTIONS: --max-old-space-size=4096
- run:
name: backend test
working_directory: "./backend"
command: |
clojure -X:dev:test :patterns '["app-tests.test-.*"]'
clojure -X:dev:test :patterns '["backend-tests.*-test"]'
environment:
PENPOT_TEST_DATABASE_URI: "postgresql://localhost/penpot_test"
@ -88,11 +88,11 @@ jobs:
working_directory: "./frontend"
command: |
yarn install
clojure -M:dev:shadow-cljs compile test
node target/tests.js
yarn test
environment:
PATH: /usr/local/nodejs/bin/:/usr/local/bin:/bin:/usr/bin
NODE_OPTIONS: --max-old-space-size=4096
- save_cache:
paths:

View file

@ -63,7 +63,7 @@
;; --- Development Stuff
(defn- run-tests
([] (run-tests #"^backend-tests.test-.*$"))
([] (run-tests #"^backend-tests.*-test$"))
([o]
(repl/refresh)
(cond

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-bounce-handling
(ns backend-tests.bounce-handling-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.db :as db]
[app.emails :as emails]
[app.http.awsns :as awsns]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-email-sending
(ns backend-tests.email-sending-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.db :as db]
[app.emails :as emails]
[clojure.test :as t]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-helpers
(ns backend-tests.helpers
(:require
[app.common.data :as d]
[app.common.flags :as flags]
@ -65,7 +65,7 @@
:name "test"
:file-uri "test"
:thumbnail-uri "test"
:path (-> "app_tests/test_files/template.penpot" io/resource fs/path)}]
:path (-> "backend_tests/test_files/template.penpot" io/resource fs/path)}]
system (-> (merge main/system-config main/worker-config)
(assoc-in [:app.redis/redis :uri] (:redis-uri config))
(assoc-in [:app.db/pool :uri] (:database-uri config))

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-file
(ns backend-tests.rpc-file-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.db.sql :as sql]
@ -124,7 +124,7 @@
(t/deftest file-gc-task
(letfn [(create-file-media-object [{:keys [profile-id file-id]}]
(let [mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}
params {::th/type :upload-file-media-object

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-font
(ns backend-tests.rpc-font-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]
@ -24,7 +24,7 @@
proj-id (:default-project-id prof)
font-id (uuid/custom 10 1)
ttfdata (-> (io/resource "app_tests/test_files/font-1.ttf")
ttfdata (-> (io/resource "backend_tests/test_files/font-1.ttf")
io/input-stream
io/read-as-bytes)
@ -59,7 +59,7 @@
proj-id (:default-project-id prof)
font-id (uuid/custom 10 1)
data (-> (io/resource "app_tests/test_files/font-1.woff")
data (-> (io/resource "backend_tests/test_files/font-1.woff")
io/input-stream
io/read-as-bytes)

View file

@ -4,10 +4,10 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-management
(ns backend-tests.rpc-management-test
(:require
[backend-tests.test-storage :refer [configure-storage-backend]]
[backend-tests.test-helpers :as th]
[backend-tests.storage-test :refer [configure-storage-backend]]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-media
(ns backend-tests.rpc-media-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.storage :as sto]
@ -60,7 +60,7 @@
:project-id (:default-project-id prof)
:is-shared false})
mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}
@ -99,7 +99,7 @@
:project-id (:default-project-id prof)
:is-shared false})
mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-profile
(ns backend-tests.rpc-profile-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.db :as db]
@ -110,7 +110,7 @@
:profile-id (:id profile)
:file {:filename "sample.jpg"
:size 123123
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"}}
out (th/mutation! data)]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-project
(ns backend-tests.rpc-project-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-team
(ns backend-tests.rpc-team-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[app.http :as http]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-rpc-viewer
(ns backend-tests.rpc-viewer-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.uuid :as uuid]
[app.db :as db]
[clojure.test :as t]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-storage
(ns backend-tests.storage-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.exceptions :as ex]
[app.common.uuid :as uuid]
[app.db :as db]
@ -126,7 +126,7 @@
:is-shared false})
mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}
@ -196,12 +196,12 @@
:project-id proj-id
:is-shared false})
ttfdata (-> (io/resource "app_tests/test_files/font-1.ttf")
ttfdata (-> (io/resource "backend_tests/test_files/font-1.ttf")
io/input-stream
io/read-as-bytes)
mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}
@ -267,7 +267,7 @@
:project-id (:default-project-id prof)
:is-shared false})
mfile {:filename "sample.jpg"
:path (th/tempfile "app_tests/test_files/sample.jpg")
:path (th/tempfile "backend_tests/test_files/sample.jpg")
:mtype "image/jpeg"
:size 312043}

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-telemetry-task
(ns backend-tests.tasks-telemetry-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.db :as db]
[app.emails :as emails]
[app.util.time :as dt]

Binary file not shown.

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-util-objects-map
(ns backend-tests.util-objects-map-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.spec :as us]
[app.common.transit :as transit]
[app.common.types.shape :as cts]

View file

@ -4,9 +4,9 @@
;;
;; Copyright (c) KALEIDOS INC
(ns backend-tests.test-util-pointer-map
(ns backend-tests.util-pointer-map-test
(:require
[backend-tests.test-helpers :as th]
[backend-tests.helpers :as th]
[app.common.spec :as us]
[app.common.transit :as transit]
[app.common.types.shape :as cts]

View file

@ -8,7 +8,7 @@
{:target :node-test
:output-to "target/test.js"
:output-dir "target/test/"
:ns-regexp "^common-tests.test-.*$"
:ns-regexp "^common-tests.*-test$"
:autorun true
:compiler-options

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-data
(ns common-tests.data-test
(:require
[app.common.data :as d]
[clojure.test :as t]))

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-geom-shapes
(ns common-tests.geom-shapes-test
(:require
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-geom
(ns common-tests.geom-test
(:require
[clojure.test :as t]
[app.common.math :as mth]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-helpers.components
(ns common-tests.helpers.components
(:require
[clojure.test :as t]
[app.common.pages.helpers :as cph]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-helpers.files
(ns common-tests.helpers.files
(:require
[app.common.files.features :as ffeat]
[app.common.geom.point :as gpt]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-pages-helpers
(ns common-tests.pages-helpers-test
(:require
[clojure.test :as t]
[clojure.pprint :refer [pprint]]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-pages-migrations
(ns common-tests.pages-migrations-test
(:require
[clojure.test :as t]
[clojure.pprint :refer [pprint]]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-pages
(ns common-tests.pages-test
(:require
[app.common.files.features :as ffeat]
[app.common.pages :as cp]

View file

@ -1,6 +1,6 @@
(ns app.init-test
(ns common-tests.setup
(:require
[cljs.test :as t :include-macros true]))
[clojure.test :as t]))
(defmethod t/report [:cljs.test/default :end-run-tests]
[m]

View file

@ -1,10 +0,0 @@
(ns common-tests.test-setup
(:require
[clojure.test :as t]))
#?(:cljs
(defmethod t/report [:cljs.test/default :end-run-tests]
[m]
(if (t/successful? m)
(set! (.-exitCode js/process) 0)
(set! (.-exitCode js/process) 1))))

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-text
(ns common-tests.text-test
(:require
[app.common.data :as d]
[app.common.text :as txt]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-types-file
(ns common-tests.types-file-test
(:require
[app.common.data :as d]
[app.common.geom.point :as gpt]
@ -21,8 +21,8 @@
[app.common.uuid :as uuid]
[clojure.pprint :refer [pprint]]
[clojure.test :as t]
[common-tests.test-helpers.components :as thk]
[common-tests.test-helpers.files :as thf]
[common-tests.helpers.components :as thk]
[common-tests.helpers.files :as thf]
[cuerdas.core :as str]))
(t/use-fixtures :each thf/reset-idmap!)

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-types-shape-interactions
(ns common-tests.types-shape-interactions-test
(:require
[app.common.exceptions :as ex]
[app.common.geom.point :as gpt]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-types
(ns common-tests.types-test
(:require
[clojure.spec.alpha :as s]
[clojure.test :as t]

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns common-tests.test-uuid
(ns common-tests.uuid-test
(:require
[app.common.spec :as us]
[app.common.uuid :as uuid]

View file

@ -86,7 +86,7 @@
{:target :node-test
:output-to "target/tests.js"
:output-dir "target/test/"
:ns-regexp "^app.*-test$"
:ns-regexp "^frontend-tests.*-test$"
:autorun true
:compiler-options

View file

@ -1,14 +1,20 @@
(ns app.test-helpers.events
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.helpers.events
(:require
[app.common.uuid :as uuid]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages :as cp]
[app.common.pages.helpers :as cph]
[app.common.uuid :as uuid]
[app.main.data.workspace :as dw]
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]
[beicon.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[potok.core :as ptk]))
;; ---- Helpers to manage global events

View file

@ -1,12 +1,18 @@
(ns app.test-helpers.libraries
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.helpers.libraries
(:require
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.main.data.workspace.state-helpers :as wsh]
[app.test-helpers.pages :as thp]))
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[frontend-tests.helpers.pages :as thp]))
;; ---- Helpers to manage libraries and synchronization
@ -150,7 +156,7 @@
[shapes-inst shapes-main component]))
(defn resolve-component
"Get the component with the given id and all its shapes."
"Get the component with the given id and all its shapes."
[state component-id]
(let [page (thp/current-page state)
libs (wsh/get-libraries state)

View file

@ -1,20 +1,26 @@
(ns app.test-helpers.pages
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.helpers.pages
(:require
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]
[beicon.core :as rx]
[potok.core :as ptk]
[app.common.uuid :as uuid]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages :as cp]
[app.common.pages.helpers :as cph]
[app.common.types.shape :as cts]
[app.common.uuid :as uuid]
[app.main.data.workspace :as dw]
[app.main.data.workspace.groups :as dwg]
[app.main.data.workspace.layout :as layout]
[app.main.data.workspace.libraries-helpers :as dwlh]
[app.main.data.workspace.state-helpers :as wsh]))
[app.main.data.workspace.state-helpers :as wsh]
[beicon.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[potok.core :as ptk]))
;; ---- Helpers to manage pages and objects

View file

@ -1,17 +1,23 @@
(ns app.shapes-test
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.helpers-shapes-test
(:require
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.geom.point :as gpt]
[app.common.pages.helpers :as cph]
[app.main.data.workspace.libraries :as dwl]
[app.test-helpers.events :as the]
[app.test-helpers.libraries :as thl]
[app.test-helpers.pages :as thp]
[beicon.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[clojure.stacktrace :as stk]
[frontend-tests.helpers.events :as the]
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[linked.core :as lks]
[potok.core :as ptk]))

View file

@ -0,0 +1,22 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.setup
(:require
[cljs.test :as t :include-macros true]))
#_(enable-console-print!)
(defmethod t/report [:cljs.test/default :end-run-tests]
[m]
(if (t/successful? m)
(set! (.-exitCode js/process) 0)
(set! (.-exitCode js/process) 1)))
#_(set! *main-cli-fn*
#(t/run-tests 'frontend-tests.test-snap-data
'frontend-tests.test-simple-math
'frontend-tests.test-range-tree))

View file

@ -1,4 +1,10 @@
(ns app.components-sync-test
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.state-components-sync-test
(:require
[app.common.colors :as clr]
[app.common.data :as d]
@ -7,16 +13,16 @@
[app.common.types.container :as ctn]
[app.main.data.workspace :as dw]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.libraries-helpers :as dwlh]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.state-helpers :as wsh]
[app.test-helpers.events :as the]
[app.test-helpers.libraries :as thl]
[app.test-helpers.pages :as thp]
[beicon.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[frontend-tests.helpers.events :as the]
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[linked.core :as lks]
[potok.core :as ptk]))

View file

@ -1,4 +1,4 @@
(ns app.components-basic-test
(ns frontend-tests.state-components-test
(:require
[app.common.data :as d]
[app.common.geom.point :as gpt]
@ -10,13 +10,13 @@
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.libraries-helpers :as dwlh]
[app.main.data.workspace.state-helpers :as wsh]
[app.test-helpers.events :as the]
[app.test-helpers.libraries :as thl]
[app.test-helpers.pages :as thp]
[beicon.core :as rx]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]
[clojure.stacktrace :as stk]
[frontend-tests.helpers.events :as the]
[frontend-tests.helpers.libraries :as thl]
[frontend-tests.helpers.pages :as thp]
[linked.core :as lks]
[potok.core :as ptk]))

View file

@ -1,9 +1,15 @@
(ns app.util.range-tree-test
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.util-range-tree-test
(:require
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]
[app.common.geom.point :as gpt]
[app.util.range-tree :as rt]))
[app.util.range-tree :as rt]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]))
(defn check-max-height [tree num-nodes])
(defn check-sorted [tree])

View file

@ -1,4 +1,10 @@
(ns app.util.simple-math-test
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS INC
(ns frontend-tests.util-simple-math-test
(:require
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]

View file

@ -4,13 +4,13 @@
;;
;; Copyright (c) KALEIDOS INC
(ns app.util.snap-data-test
(ns frontend-tests.util-snap-data-test
(:require
[app.common.uuid :as uuid]
[cljs.test :as t :include-macros true]
[cljs.pprint :refer [pprint]]
[app.common.file-builder :as fb]
[app.util.snap-data :as sd]))
[app.common.uuid :as uuid]
[app.util.snap-data :as sd]
[cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true]))
(t/deftest test-create-index
(t/testing "Create empty data"