Browse Source

chore: add test for block refs

Part of LOG-3092
Gabriel Horner 1 year ago
parent
commit
5b4cb0d213

+ 3 - 1
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -437,6 +437,8 @@
   "Ignore built-in properties that are already imported or not supported in db graphs"
   ;; Already imported via a datascript attribute i.e. have :attribute on property config
   [:tags :alias :collapsed
+   ;; Supported
+   :id
    ;; Not supported as they have been ignored for a long time and cause invalid built-in pages
    :now :later :doing :done :canceled :cancelled :in-progress :todo :wait :waiting
    ;; deprecated in db graphs
@@ -449,7 +451,7 @@
   [properties class-related-properties]
   (let [dissoced-props (concat ignored-built-in-properties
                                ;; TODO: Add import support for these dissoced built-in properties
-                               [:title :id :created-at :updated-at
+                               [:title :created-at :updated-at
                                 :card-last-interval :card-repeats :card-last-reviewed :card-next-schedule
                                 :card-ease-factor :card-last-score]
                                class-related-properties)]

+ 5 - 1
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -141,7 +141,7 @@
 
       ;; Counts
       ;; Includes 2 journals as property values for :logseq.task/deadline
-      (is (= 10 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
+      (is (= 11 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
 
       ;; Don't count pages like url.md that have properties but no content
       (is (= 5
@@ -214,6 +214,10 @@
           "Existing page has correct properties"))
 
     (testing "built-in properties"
+      (is (= [(:db/id (find-block-by-content @conn "original block"))]
+             (mapv :db/id (:block/refs (find-block-by-content @conn #"ref to"))))
+          "block with a block-ref has correct :block/refs")
+
       (is (= 2
              (count (filter #(= :icon (:property %)) @(:ignored-properties import-state))))
           "icon properties are visibly ignored in order to not fail import")

+ 3 - 0
deps/graph-parser/test/resources/exporter-test-graph/journals/2024_02_13.md

@@ -0,0 +1,3 @@
+- original block
+  id:: 65cbb772-fb79-462d-87c8-6f0dad751dee
+- ref to ((65cbb772-fb79-462d-87c8-6f0dad751dee))