|
|
@@ -33,14 +33,14 @@
|
|
|
(d/q '[:find [(pull ?b [*]) ...]
|
|
|
:in $ ?pattern
|
|
|
:where [?b :block/title ?content]
|
|
|
- [(missing? $ ?b :block/type)]
|
|
|
+ [(missing? $ ?b :block/tags)]
|
|
|
[(re-find ?pattern ?content)]]
|
|
|
db)
|
|
|
first)
|
|
|
(->> content
|
|
|
(d/q '[:find [(pull ?b [*]) ...]
|
|
|
:in $ ?content
|
|
|
- :where [?b :block/title ?content] [(missing? $ ?b :block/type)]]
|
|
|
+ :where [?b :block/title ?content] [(missing? $ ?b :block/tags)]]
|
|
|
db)
|
|
|
first)))
|
|
|
|
|
|
@@ -195,7 +195,6 @@
|
|
|
|
|
|
;; Counts
|
|
|
;; Includes journals as property values e.g. :logseq.task/deadline
|
|
|
- (is (= 24 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
|
|
|
(is (= 24 (count (d/q '[:find ?b :where [?b :block/tags :logseq.class/Journal]] @conn))))
|
|
|
|
|
|
(is (= 4 (count (d/q '[:find ?b :where [?b :block/tags :logseq.class/Task]] @conn))))
|
|
|
@@ -204,16 +203,16 @@
|
|
|
|
|
|
;; Don't count pages like url.md that have properties but no content
|
|
|
(is (= 10
|
|
|
- (count (->> (d/q '[:find [(pull ?b [:block/title :block/type]) ...]
|
|
|
+ (count (->> (d/q '[:find [(pull ?b [:block/title :block/tags]) ...]
|
|
|
:where [?b :block/title] [_ :block/page ?b] (not [?b :logseq.property/built-in?])] @conn)
|
|
|
(filter ldb/internal-page?))))
|
|
|
"Correct number of pages with block content")
|
|
|
(is (= 11 (->> @conn
|
|
|
(d/q '[:find [?ident ...]
|
|
|
- :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
+ :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
count))
|
|
|
"Correct number of user classes")
|
|
|
- (is (= 4 (count (d/datoms @conn :avet :block/type "whiteboard"))))
|
|
|
+ (is (= 4 (count (d/datoms @conn :avet :block/tags :logseq.class/Whiteboard))))
|
|
|
(is (= 0 (count @(:ignored-properties import-state))) ":filters should be the only ignored property")
|
|
|
(is (= 1 (count @assets))))
|
|
|
|
|
|
@@ -236,7 +235,7 @@
|
|
|
(is (= 18
|
|
|
(->> @conn
|
|
|
(d/q '[:find [(pull ?b [:db/ident]) ...]
|
|
|
- :where [?b :block/type "property"]])
|
|
|
+ :where [?b :block/tags :logseq.class/Property]])
|
|
|
(remove #(db-malli-schema/internal-ident? (:db/ident %)))
|
|
|
count))
|
|
|
"Correct number of user properties")
|
|
|
@@ -248,7 +247,7 @@
|
|
|
{:db/ident :user.property/startedat :block/schema {:type :date}}}
|
|
|
(->> @conn
|
|
|
(d/q '[:find [(pull ?b [:db/ident :block/schema]) ...]
|
|
|
- :where [?b :block/type "property"]])
|
|
|
+ :where [?b :block/tags :logseq.class/Property]])
|
|
|
(filter #(contains? #{:prop-bool :prop-string :prop-num :rangeincludes :sameas :startedat}
|
|
|
(keyword (name (:db/ident %)))))
|
|
|
set))
|
|
|
@@ -362,8 +361,12 @@
|
|
|
(:db/ident (find-page-by-name @conn "life")))
|
|
|
"Namespaced tag's ident has hierarchy to make it unique")
|
|
|
|
|
|
- (is (= [{:block/type "class"}]
|
|
|
- (d/q '[:find [(pull ?b [:block/type]) ...] :where [?b :block/name "life"]] @conn))
|
|
|
+ (is (= ["Tag"]
|
|
|
+ (d/q '[:find [?t-title ...]
|
|
|
+ :where
|
|
|
+ [?b :block/name "life"]
|
|
|
+ [?b :block/tags ?t]
|
|
|
+ [?t :block/title ?t-title]] @conn))
|
|
|
"When a class is used and referenced on the same page, there should only be one instance of it")
|
|
|
|
|
|
(is (= ["life"]
|
|
|
@@ -442,8 +445,11 @@
|
|
|
(is (= #{:logseq.property/description :user.property/description}
|
|
|
(set (d/q '[:find [?ident ...] :where [?b :db/ident ?ident] [?b :block/name "description"]] @conn)))
|
|
|
"user description property is separate from built-in one")
|
|
|
- (is (= #{"page" "class"}
|
|
|
- (set (d/q '[:find [?type ...] :where [?b :block/type ?type] [?b :block/name "task"]] @conn)))
|
|
|
+ (is (= #{"Page" "Class"}
|
|
|
+ (set (d/q '[:find [?t-title ...] :where
|
|
|
+ [?b :block/tags ?t]
|
|
|
+ [?b :block/name "task"]
|
|
|
+ [?t :block/title ?t-title]] @conn)))
|
|
|
"user page is separate from built-in class"))
|
|
|
|
|
|
(testing "multiline blocks"
|
|
|
@@ -495,7 +501,7 @@
|
|
|
(is (= 0 (count @(:ignored-properties import-state))) "No ignored properties")
|
|
|
(is (= 0 (->> @conn
|
|
|
(d/q '[:find [?ident ...]
|
|
|
- :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
+ :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
count))
|
|
|
"Correct number of user classes")
|
|
|
|
|
|
@@ -556,7 +562,7 @@
|
|
|
(:block/tags (readable-properties @conn block)))
|
|
|
"tagged block has configured tag imported as a class")
|
|
|
|
|
|
- (is (= "class" (:block/type tag-page))
|
|
|
+ (is (= :logseq.class/Class (:db/ident (first (:block/tags tag-page))))
|
|
|
"configured tag page in :tag-classes is a class")
|
|
|
(is (and another-tag-page (not (ldb/class? another-tag-page)))
|
|
|
"unconfigured tag page is not a class")
|
|
|
@@ -580,7 +586,7 @@
|
|
|
(is (= #{:user.class/Property :user.class/Movie :user.class/Class :user.class/Tool}
|
|
|
(->> @conn
|
|
|
(d/q '[:find [?ident ...]
|
|
|
- :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
+ :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
set))
|
|
|
"All classes are correctly defined by :type")
|
|
|
|
|
|
@@ -602,7 +608,7 @@
|
|
|
"tagged block can have another property that references the same class it is tagged with,
|
|
|
without creating a duplicate class")
|
|
|
|
|
|
- (is (= "class" (:block/type tag-page))
|
|
|
+ (is (= :logseq.class/Class (:db/ident (first (:block/tags tag-page))))
|
|
|
"configured tag page derived from :property-classes is a class")
|
|
|
(is (nil? (find-page-by-name @conn "type"))
|
|
|
"No page exists for configured property")
|
|
|
@@ -648,7 +654,7 @@
|
|
|
:user.class/Class :user.class/Tool :user.class/Whiteboard___Tool}
|
|
|
(->> @conn
|
|
|
(d/q '[:find [?ident ...]
|
|
|
- :where [?b :block/type "class"] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
+ :where [?b :block/tags :logseq.class/Class] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
|
|
|
set))
|
|
|
"All classes are correctly defined by :type")
|
|
|
|