mirror of
https://github.com/logseq/logseq.git
synced 2026-04-27 23:54:55 +00:00
fix: graph parser tests
This commit is contained in:
@@ -132,6 +132,13 @@
|
||||
_ (gp-exporter/export-doc-files conn files' <read-file doc-options)]
|
||||
{:import-state (:import-state doc-options)}))
|
||||
|
||||
(defn- remove-block-ns-properties
|
||||
[m]
|
||||
(->> (remove (fn [[k _v]]
|
||||
(and (= "block" (namespace k))
|
||||
(not (contains? #{:block/tags :block/alias} k)))) m)
|
||||
(into {})))
|
||||
|
||||
(defn- readable-properties
|
||||
[db query-ent]
|
||||
(->> (db-property/properties query-ent)
|
||||
@@ -146,7 +153,8 @@
|
||||
(db-property/ref->property-value-contents db v)
|
||||
v))
|
||||
(db-property/ref->property-value-contents db v))])))
|
||||
(into {})))
|
||||
(into {})
|
||||
(remove-block-ns-properties)))
|
||||
|
||||
;; Tests
|
||||
;; =====
|
||||
@@ -245,8 +253,9 @@
|
||||
(is (= {:user.property/prop-bool true
|
||||
:user.property/prop-num 5
|
||||
:user.property/prop-string "woot"}
|
||||
(update-vals (db-property/properties (find-block-by-content @conn "b1"))
|
||||
(fn [v] (if (map? v) (db-property/ref->property-value-content @conn v) v))))
|
||||
(->> (update-vals (db-property/properties (find-block-by-content @conn "b1"))
|
||||
(fn [v] (if (map? v) (db-property/ref->property-value-content @conn v) v)))
|
||||
(remove-block-ns-properties)))
|
||||
"Basic block has correct properties")
|
||||
(is (= #{"prop-num" "prop-string" "prop-bool"}
|
||||
(->> (d/entity @conn (:db/id (find-block-by-content @conn "b1")))
|
||||
@@ -457,7 +466,8 @@
|
||||
"tag page is not a class")
|
||||
|
||||
(is (= {:logseq.property/page-tags #{"Movie"}}
|
||||
(readable-properties @conn tagged-page))
|
||||
(-> (readable-properties @conn tagged-page)
|
||||
(dissoc :block/type)))
|
||||
"tagged page has existing page imported as a tag to page-tags")
|
||||
(is (= #{"LargeLanguageModel" "fun" "ai"}
|
||||
(:logseq.property/page-tags (readable-properties @conn (find-page-by-name @conn "chat-gpt"))))
|
||||
@@ -504,7 +514,8 @@
|
||||
"unconfigured tag page is not a class")
|
||||
|
||||
(is (= {:block/tags [:user.class/Movie]}
|
||||
(readable-properties @conn (find-page-by-name @conn "Interstellar")))
|
||||
(-> (readable-properties @conn (find-page-by-name @conn "Interstellar"))
|
||||
(dissoc :block/type)))
|
||||
"tagged page has configured tag imported as a class"))))
|
||||
|
||||
(deftest-async export-files-with-property-classes-option
|
||||
@@ -587,4 +598,4 @@
|
||||
_ (gp-exporter/export-config-file conn "logseq/config.edn" read-file {})]
|
||||
(is (= "yyyy-MM-dd"
|
||||
(:logseq.property.journal/title-format (d/entity @conn :logseq.class/Journal)))
|
||||
"title format set correctly by config")))
|
||||
"title format set correctly by config")))
|
||||
|
||||
Reference in New Issue
Block a user