mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Updates docs version for parse-graph integration tests
This commit is contained in:
committed by
Gabriel Horner
parent
7b1c377e3a
commit
eac3c273ca
2
.gitignore
vendored
2
.gitignore
vendored
@@ -48,7 +48,7 @@ ios/App/App/capacitor.config.json
|
|||||||
startup.png
|
startup.png
|
||||||
|
|
||||||
/src/main/frontend/tldraw-logseq.js
|
/src/main/frontend/tldraw-logseq.js
|
||||||
/src/test/docs
|
/src/test/docs*
|
||||||
~*~
|
~*~
|
||||||
|
|
||||||
ios/App/App/capacitor.config.json
|
ios/App/App/capacitor.config.json
|
||||||
|
|||||||
2
deps/graph-parser/.gitignore
vendored
2
deps/graph-parser/.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
/.clj-kondo/.cache
|
/.clj-kondo/.cache
|
||||||
cljs-test-runner-out
|
cljs-test-runner-out
|
||||||
/test/docs
|
/test/docs*
|
||||||
|
|||||||
@@ -65,6 +65,8 @@
|
|||||||
(is (= (->> files
|
(is (= (->> files
|
||||||
;; logseq files aren't saved under :block/file
|
;; logseq files aren't saved under :block/file
|
||||||
(remove #(string/includes? % (str "/" gp-config/app-name "/")))
|
(remove #(string/includes? % (str "/" gp-config/app-name "/")))
|
||||||
|
;; edn files being listed in docs by parse-graph aren't graph files
|
||||||
|
(remove #(and (not (gp-config/whiteboard? %)) (string/ends-with? % ".edn")))
|
||||||
set)
|
set)
|
||||||
(->> (d/q '[:find (pull ?b [* {:block/file [:file/path]}])
|
(->> (d/q '[:find (pull ?b [* {:block/file [:file/path]}])
|
||||||
:where [?b :block/name] [?b :block/file]]
|
:where [?b :block/name] [?b :block/file]]
|
||||||
@@ -83,7 +85,7 @@
|
|||||||
ffirst))
|
ffirst))
|
||||||
"Journal page count on disk equals count in db")
|
"Journal page count on disk equals count in db")
|
||||||
|
|
||||||
(is (= {"CANCELED" 2 "DONE" 6 "LATER" 4 "NOW" 5}
|
(is (= {"CANCELED" 2 "DONE" 6 "LATER" 4 "NOW" 5 "TODO" 22}
|
||||||
(->> (d/q '[:find (pull ?b [*]) :where [?b :block/marker]]
|
(->> (d/q '[:find (pull ?b [*]) :where [?b :block/marker]]
|
||||||
db)
|
db)
|
||||||
(map first)
|
(map first)
|
||||||
@@ -92,29 +94,30 @@
|
|||||||
(into {})))
|
(into {})))
|
||||||
"Task marker counts")
|
"Task marker counts")
|
||||||
|
|
||||||
(is (= {:markdown 3143 :org 460} ;; 2 pages for namespaces are not parsed
|
(is (= {:markdown 5495 :org 457} ;; 2 pages for namespaces are not parsed
|
||||||
(get-block-format-counts db))
|
(get-block-format-counts db))
|
||||||
"Block format counts")
|
"Block format counts")
|
||||||
|
|
||||||
(is (= {:title 98 :id 98
|
(is (= {:description 81, :updated-at 46, :tags 5, :logseq.macro-arguments 104
|
||||||
:updated-at 47 :created-at 47
|
:logseq.tldraw.shape 79, :card-last-score 6, :card-repeats 6,
|
||||||
:card-last-score 6 :card-repeats 6 :card-next-schedule 6
|
:card-next-schedule 6, :ls-type 79, :card-last-interval 6, :type 107,
|
||||||
:card-last-interval 6 :card-ease-factor 6 :card-last-reviewed 6
|
:template 5, :title 114, :alias 41, :supports 5, :id 145, :url 5,
|
||||||
:alias 6 :logseq.macro-arguments 94 :logseq.macro-name 94 :heading 64}
|
:card-ease-factor 6, :logseq.macro-name 104, :created-at 46,
|
||||||
|
:card-last-reviewed 6, :platforms 51, :initial-version 8, :heading 226}
|
||||||
(get-top-block-properties db))
|
(get-top-block-properties db))
|
||||||
"Counts for top block properties")
|
"Counts for top block properties")
|
||||||
|
|
||||||
(is (= {:title 98
|
(is (= {:description 77, :tags 5, :permalink 1, :ls-type 1, :type 104,
|
||||||
:alias 6
|
:related 1, :source 1, :title 113, :author 1, :sample 1, :alias 41,
|
||||||
:tags 2 :permalink 2
|
:logseq.tldraw.page 1, :supports 5, :url 5, :platforms 50,
|
||||||
:name 1 :type 1 :related 1 :sample 1 :click 1 :id 1 :example 1}
|
:initial-version 7, :full-title 1}
|
||||||
(get-all-page-properties db))
|
(get-all-page-properties db))
|
||||||
"Counts for all page properties")
|
"Counts for all page properties")
|
||||||
|
|
||||||
(is (= {:block/scheduled 2
|
(is (= {:block/scheduled 2
|
||||||
:block/priority 4
|
:block/priority 4
|
||||||
:block/deadline 1
|
:block/deadline 1
|
||||||
:block/collapsed? 22
|
:block/collapsed? 80
|
||||||
:block/repeated? 1}
|
:block/repeated? 1}
|
||||||
(->> [:block/scheduled :block/priority :block/deadline :block/collapsed?
|
(->> [:block/scheduled :block/priority :block/deadline :block/collapsed?
|
||||||
:block/repeated?]
|
:block/repeated?]
|
||||||
@@ -125,13 +128,13 @@
|
|||||||
(into {})))
|
(into {})))
|
||||||
"Counts for blocks with common block attributes")
|
"Counts for blocks with common block attributes")
|
||||||
|
|
||||||
(is (= #{"term" "setting" "book" "templates" "Query" "Query/table" "page"}
|
(is (= #{"term" "setting" "book" "templates" "Query table" "page"
|
||||||
|
"Whiteboard" "Whiteboard/Tool" "Community" "Tweet"}
|
||||||
(->> (d/q '[:find (pull ?n [*]) :where [?b :block/namespace ?n]] db)
|
(->> (d/q '[:find (pull ?n [*]) :where [?b :block/namespace ?n]] db)
|
||||||
(map (comp :block/original-name first))
|
(map (comp :block/original-name first))
|
||||||
set))
|
set))
|
||||||
"Has correct namespaces")))
|
"Has correct namespaces")))
|
||||||
|
|
||||||
;; TODO update me to the number of the latest version of doc when namespace is updated
|
|
||||||
(defn docs-graph-assertions
|
(defn docs-graph-assertions
|
||||||
"These are common assertions that should pass in both graph-parser and main
|
"These are common assertions that should pass in both graph-parser and main
|
||||||
logseq app. It is important to run these in both contexts to ensure that the
|
logseq app. It is important to run these in both contexts to ensure that the
|
||||||
@@ -141,15 +144,15 @@
|
|||||||
;; Counts assertions help check for no major regressions. These counts should
|
;; Counts assertions help check for no major regressions. These counts should
|
||||||
;; only increase over time as the docs graph rarely has deletions
|
;; only increase over time as the docs graph rarely has deletions
|
||||||
(testing "Counts"
|
(testing "Counts"
|
||||||
(is (= 211 (count files)) "Correct file count")
|
(is (= 306 (count files)) "Correct file count")
|
||||||
(is (= 42110 (count (d/datoms db :eavt))) "Correct datoms count")
|
(is (= 69679 (count (d/datoms db :eavt))) "Correct datoms count")
|
||||||
|
|
||||||
(is (= 3600
|
(is (= 5866
|
||||||
(ffirst
|
(ffirst
|
||||||
(d/q '[:find (count ?b)
|
(d/q '[:find (count ?b)
|
||||||
:where [?b :block/path-refs ?bp] [?bp :block/name]] db)))
|
:where [?b :block/path-refs ?bp] [?bp :block/name]] db)))
|
||||||
"Correct referenced blocks count")
|
"Correct referenced blocks count")
|
||||||
(is (= 21
|
(is (= 23
|
||||||
(ffirst
|
(ffirst
|
||||||
(d/q '[:find (count ?b)
|
(d/q '[:find (count ?b)
|
||||||
:where [?b :block/content ?content]
|
:where [?b :block/content ?content]
|
||||||
|
|||||||
@@ -6,9 +6,8 @@
|
|||||||
|
|
||||||
;; Integration test that test parsing a large graph like docs
|
;; Integration test that test parsing a large graph like docs
|
||||||
(deftest ^:integration parse-graph
|
(deftest ^:integration parse-graph
|
||||||
(let [graph-dir "test/docs"
|
(let [graph-dir "test/docs-0.9.2"
|
||||||
;; TODO update docs filename rules to the latest version when the namespace PR is released
|
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.9.2")
|
||||||
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.6.7")
|
|
||||||
{:keys [conn files asts]} (gp-cli/parse-graph graph-dir {:verbose false})] ;; legacy parsing
|
{:keys [conn files asts]} (gp-cli/parse-graph graph-dir {:verbose false})] ;; legacy parsing
|
||||||
|
|
||||||
(docs-graph-helper/docs-graph-assertions @conn files)
|
(docs-graph-helper/docs-graph-assertions @conn files)
|
||||||
@@ -19,6 +18,8 @@
|
|||||||
"There's an ast returned for every file processed")
|
"There's an ast returned for every file processed")
|
||||||
(is (empty? (remove #(or
|
(is (empty? (remove #(or
|
||||||
(seq (:ast %))
|
(seq (:ast %))
|
||||||
|
;; edn files don't have ast
|
||||||
|
(string/ends-with? (:file %) ".edn")
|
||||||
;; logseq files don't have ast
|
;; logseq files don't have ast
|
||||||
;; could also used gp-config but API isn't public yet
|
;; could also used gp-config but API isn't public yet
|
||||||
(string/includes? (:file %) (str graph-dir "/logseq/")))
|
(string/includes? (:file %) (str graph-dir "/logseq/")))
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ body"
|
|||||||
(is ["@tag" "tag1" "tag2" "tag3"] (sort (:tags props))))))
|
(is ["@tag" "tag1" "tag2" "tag3"] (sort (:tags props))))))
|
||||||
|
|
||||||
(deftest ^:integration test->edn
|
(deftest ^:integration test->edn
|
||||||
(let [graph-dir "test/docs"
|
(let [graph-dir "test/docs-0.9.2"
|
||||||
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.6.7")
|
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.9.2")
|
||||||
files (gp-cli/build-graph-files graph-dir)
|
files (gp-cli/build-graph-files graph-dir)
|
||||||
asts-by-file (->> files
|
asts-by-file (->> files
|
||||||
(map (fn [{:file/keys [path content]}]
|
(map (fn [{:file/keys [path content]}]
|
||||||
@@ -131,21 +131,20 @@ body"
|
|||||||
(gp-mldoc/->edn content
|
(gp-mldoc/->edn content
|
||||||
(gp-mldoc/default-config format))])))
|
(gp-mldoc/default-config format))])))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(is (= {"CommentBlock" 1,
|
(is (= {"Custom" 50,
|
||||||
"Custom" 41,
|
|
||||||
"Displayed_Math" 1,
|
"Displayed_Math" 1,
|
||||||
"Drawer" 1,
|
"Drawer" 1,
|
||||||
"Example" 20,
|
"Example" 20,
|
||||||
"Footnote_Definition" 2,
|
"Footnote_Definition" 2,
|
||||||
"Heading" 3496,
|
"Heading" 5648,
|
||||||
"Hiccup" 15,
|
"Hiccup" 9,
|
||||||
"List" 37,
|
"List" 22,
|
||||||
"Paragraph" 417,
|
"Paragraph" 573,
|
||||||
"Properties" 91,
|
"Properties" 87,
|
||||||
"Property_Drawer" 201,
|
"Property_Drawer" 423,
|
||||||
"Quote" 9,
|
"Quote" 24,
|
||||||
"Raw_Html" 12,
|
"Raw_Html" 18,
|
||||||
"Src" 56,
|
"Src" 79,
|
||||||
"Table" 4}
|
"Table" 8}
|
||||||
(->> asts-by-file (mapcat val) (map ffirst) frequencies))
|
(->> asts-by-file (mapcat val) (map ffirst) frequencies))
|
||||||
"AST node type counts")))
|
"AST node type counts")))
|
||||||
|
|||||||
@@ -11,11 +11,9 @@
|
|||||||
(use-fixtures :each {:before test-helper/start-test-db!
|
(use-fixtures :each {:before test-helper/start-test-db!
|
||||||
:after test-helper/destroy-test-db!})
|
:after test-helper/destroy-test-db!})
|
||||||
|
|
||||||
;; TODO update docs filename rules to the latest version when the namespace PR is released
|
|
||||||
(deftest ^:integration parse-and-load-files-to-db
|
(deftest ^:integration parse-and-load-files-to-db
|
||||||
(let [graph-dir "src/test/docs"
|
(let [graph-dir "src/test/docs-0.9.2"
|
||||||
;; TODO update me to the latest version of doc when namespace is updated
|
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.9.2")
|
||||||
_ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir "v0.6.7")
|
|
||||||
files (gp-cli/build-graph-files graph-dir)
|
files (gp-cli/build-graph-files graph-dir)
|
||||||
_ (repo-handler/parse-files-and-load-to-db! test-helper/test-db files {:re-render? false :verbose false})
|
_ (repo-handler/parse-files-and-load-to-db! test-helper/test-db files {:re-render? false :verbose false})
|
||||||
db (conn/get-db test-helper/test-db)]
|
db (conn/get-db test-helper/test-db)]
|
||||||
|
|||||||
Reference in New Issue
Block a user