瀏覽代碼

Fix frontend and graph-parser tests

A number of outliner tests were failing which is distracting when trying
to separate out outliner namespaces. Most failures were caused by
introduction of state/get-selection-blocks into outliner layer. A few
are caused by trivial count change in datoms. Removed config/test? from
outliner as it's unused
Gabriel Horner 2 年之前
父節點
當前提交
ea8d6679de

+ 1 - 1
deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs

@@ -161,7 +161,7 @@
   ;; only increase over time as the docs graph rarely has deletions
   (testing "Counts"
     (is (= 303 (count files)) "Correct file count")
-    (is (= 63731 (count (d/datoms db :eavt))) "Correct datoms count")
+    (is (= 63733 (count (d/datoms db :eavt))) "Correct datoms count")
 
     (is (= 5866
            (ffirst

+ 2 - 0
src/test/frontend/handler/editor_test.cljs

@@ -270,6 +270,8 @@
                   gdom/getElement (constantly #js {:id block-dom-id})
                 ;; stub since not testing moving
                   editor/edit-block! (constantly nil)
+                  ;; stub b/c of js/document
+                  state/get-selection-blocks (constantly [])
                   util/get-blocks-noncollapse (constantly (mapv
                                                            (fn [m]
                                                              #js {:id (:id m)

+ 1 - 1
src/test/frontend/handler/repo_conversion_test.cljs

@@ -98,7 +98,7 @@
   ;; only increase over time as the docs graph rarely has deletions
   (testing "Counts"
     (is (= 211 (count files)) "Correct file count")
-    (is (= 38819 (count (d/datoms db :eavt))) "Correct datoms count")
+    (is (= 38823 (count (d/datoms db :eavt))) "Correct datoms count")
 
     (is (= 3600
            (ffirst

+ 8 - 1
src/test/frontend/modules/outliner/core_test.cljs

@@ -11,12 +11,19 @@
             [logseq.graph-parser.block :as gp-block]
             [datascript.core :as d]
             [frontend.test.helper :as test-helper :refer [load-test-files]]
+            [frontend.state :as state]
             [clojure.set :as set]))
 
 (def test-db test-helper/test-db)
 
+(defn disable-browser-fns
+  [f]
+  ;; get-selection-blocks has a js/document reference
+  (with-redefs [state/get-selection-blocks (constantly [])]
+    (f)))
+
 (use-fixtures :each
-  fixtures/load-test-env
+  disable-browser-fns
   fixtures/react-components
   fixtures/reset-db)
 

+ 0 - 5
src/test/frontend/test/fixtures.cljs

@@ -1,16 +1,11 @@
 (ns frontend.test.fixtures
   (:require [datascript.core :as d]
-            [frontend.config :as config]
             [logseq.db.schema :as db-schema]
             [frontend.db.conn :as conn]
             [frontend.db.react :as react]
             [frontend.state :as state]
             [frontend.test.helper :as test-helper]))
 
-(defn load-test-env
-  [f]
-  (with-redefs [config/test? true] (f)))
-
 (defn react-components
   [f]
   (reset! react/query-state {})