mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: enable repl test on non-node environments
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
[]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))}))
|
||||
|
||||
@@ -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!
|
||||
[]
|
||||
|
||||
14
src/test/frontend/test/node_fixtures.cljs
Normal file
14
src/test/frontend/test/node_fixtures.cljs
Normal file
@@ -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))}))
|
||||
Reference in New Issue
Block a user