diff --git a/src/test/frontend/fs_test.cljs b/src/test/frontend/fs_test.cljs index c4204d81f5..fed880a2c6 100644 --- a/src/test/frontend/fs_test.cljs +++ b/src/test/frontend/fs_test.cljs @@ -1,6 +1,6 @@ (ns frontend.fs-test (:require [clojure.test :refer [is use-fixtures]] - [frontend.test.fixtures :as fixtures] + [frontend.test.node-fixtures :as node-fixtures] [frontend.test.helper :as test-helper :include-macros true :refer [deftest-async]] [frontend.test.node-helper :as test-node-helper] [frontend.fs :as fs] @@ -8,7 +8,7 @@ ["fs" :as fs-node] ["path" :as node-path])) -(use-fixtures :once fixtures/redef-get-fs) +(use-fixtures :once node-fixtures/redef-get-fs) (deftest-async create-if-not-exists-creates-correctly ;; dir needs to be an absolute path for fn to work correctly diff --git a/src/test/frontend/handler/plugin_config_test.cljs b/src/test/frontend/handler/plugin_config_test.cljs index 0bcdae4178..dc2006e11f 100644 --- a/src/test/frontend/handler/plugin_config_test.cljs +++ b/src/test/frontend/handler/plugin_config_test.cljs @@ -3,6 +3,7 @@ [frontend.test.helper :as test-helper :include-macros true :refer [deftest-async]] [frontend.test.node-helper :as test-node-helper] [frontend.test.fixtures :as fixtures] + [frontend.test.node-fixtures :as node-fixtures] [frontend.handler.plugin-config :as plugin-config-handler] [frontend.handler.global-config :as global-config-handler] [frontend.schema.handler.plugin-config :as plugin-config-schema] @@ -14,7 +15,7 @@ [clojure.string :as string] [frontend.handler.notification :as notification])) -(use-fixtures :once fixtures/redef-get-fs) +(use-fixtures :once node-fixtures/redef-get-fs) (defn- create-global-config-dir [] diff --git a/src/test/frontend/modules/outliner/core_test.cljs b/src/test/frontend/modules/outliner/core_test.cljs index d377ea0feb..9dc311c9fc 100644 --- a/src/test/frontend/modules/outliner/core_test.cljs +++ b/src/test/frontend/modules/outliner/core_test.cljs @@ -333,15 +333,12 @@ (deftest test-paste-into-empty-block (testing " Paste a block into the first block (its content is empty) - [[22 [[2 [[3 [[4] - [5]]] - [6 [[7 [[8]]]]] - [9 [[10] - [11]]]]] - [12 [[13] - [14] - [15]]] - [16 [[17]]]]]] + [[22 [[2 [[3 [[4] [5]]] + [6 [[7 + [[8]]]]] + [9 [[10] [11]]]]] + [12 [[13] [14] [15]]] + [16 [[17]]]]]] " (transact-tree! tree) (db/transact! test-db [{:block/uuid 22 @@ -349,9 +346,9 @@ (let [target-block (get-block 22)] (outliner-tx/transact! {:graph test-db} - (outliner-core/insert-blocks! [{:block/left [:block/uuid 1] + (outliner-core/insert-blocks! [{:block/left 1 :block/content "test" - :block/parent [:block/uuid 1] + :block/parent 1 :block/page 1}] target-block {:sibling? false diff --git a/src/test/frontend/test/fixtures.cljs b/src/test/frontend/test/fixtures.cljs index 618c6963de..838de9b3fe 100644 --- a/src/test/frontend/test/fixtures.cljs +++ b/src/test/frontend/test/fixtures.cljs @@ -4,11 +4,8 @@ [logseq.db.schema :as db-schema] [frontend.db.conn :as conn] [frontend.db.react :as react] - [frontend.fs.test-node :as test-node] - [frontend.fs :as fs] [frontend.state :as state] - [frontend.test.helper :as test-helper] - [cljs.test :refer [async]])) + [frontend.test.helper :as test-helper])) (defn load-test-env [f] @@ -34,13 +31,3 @@ (reset-datascript repo) (let [r (f)] (reset-datascript repo) r))) - -(let [get-fs-fn (atom nil)] - (def redef-get-fs - "Redef fs/get-fs to an implementation that is valid for node tests" - {:before (fn [] - (async done - (reset! get-fs-fn fs/get-fs) - (set! fs/get-fs (constantly (test-node/->NodeTestfs))) - (done))) - :after (fn [] (set! fs/get-fs @get-fs-fn))})) diff --git a/src/test/frontend/test/helper.cljs b/src/test/frontend/test/helper.cljs index 820026e4f3..a98192b34a 100644 --- a/src/test/frontend/test/helper.cljs +++ b/src/test/frontend/test/helper.cljs @@ -11,7 +11,10 @@ [datascript.core :as d] [logseq.graph-parser.text :as text])) -(defonce test-db (if (some? js/process.env.DB_GRAPH) "logseq_db_test-db" "test-db")) +(def node? (exists? js/process)) + +(defonce test-db + (if (and node? (some? js/process.env.DB_GRAPH)) "logseq_db_test-db" "test-db")) (defn start-test-db! [] diff --git a/src/test/frontend/test/node_fixtures.cljs b/src/test/frontend/test/node_fixtures.cljs new file mode 100644 index 0000000000..7c7747f665 --- /dev/null +++ b/src/test/frontend/test/node_fixtures.cljs @@ -0,0 +1,14 @@ +(ns frontend.test.node-fixtures + (:require [cljs.test :refer [async]] + [frontend.fs :as fs] + [frontend.fs.test-node :as test-node])) + +(let [get-fs-fn (atom nil)] + (def redef-get-fs + "Redef fs/get-fs to an implementation that is valid for node tests" + {:before (fn [] + (async done + (reset! get-fs-fn fs/get-fs) + (set! fs/get-fs (constantly (test-node/->NodeTestfs))) + (done))) + :after (fn [] (set! fs/get-fs @get-fs-fn))}))