|
|
@@ -1,5 +1,6 @@
|
|
|
(ns logseq.graph-parser-test
|
|
|
(:require [cljs.test :refer [deftest testing is]]
|
|
|
+ [clojure.string :as string]
|
|
|
[logseq.graph-parser :as graph-parser]
|
|
|
[logseq.db :as ldb]
|
|
|
[logseq.graph-parser.block :as gp-block]
|
|
|
@@ -41,3 +42,29 @@
|
|
|
(catch :default _)))
|
|
|
(is (= nil @deleted-page)
|
|
|
"Page should not be deleted when there is unexpected failure"))))
|
|
|
+
|
|
|
+(defn- test-property-order [num-properties]
|
|
|
+ (let [conn (ldb/start-conn)
|
|
|
+ properties (mapv #(keyword (str "p" %)) (range 0 num-properties))
|
|
|
+ text (->> properties
|
|
|
+ (map #(str (name %) ":: " (name %) "-value"))
|
|
|
+ (string/join "\n"))
|
|
|
+ ;; Test page properties and block properties
|
|
|
+ body (str text "\n- " text)
|
|
|
+ _ (graph-parser/parse-file conn "foo.md" body {})
|
|
|
+ properties-orders (->> (d/q '[:find (pull ?b [*])
|
|
|
+ :in $
|
|
|
+ :where [?b :block/content] [(missing? $ ?b :block/name)]]
|
|
|
+ @conn)
|
|
|
+ (map first)
|
|
|
+ (map :block/properties-order))]
|
|
|
+ (is (every? vector? properties-orders)
|
|
|
+ "Order is persisted as a vec to avoid edn serialization quirks")
|
|
|
+ (is (= [properties properties] properties-orders)
|
|
|
+ "Property order")))
|
|
|
+
|
|
|
+(deftest properties-order
|
|
|
+ (testing "Sort order and persistence of a few properties"
|
|
|
+ (test-property-order 4))
|
|
|
+ (testing "Sort order and persistence of 10 properties"
|
|
|
+ (test-property-order 10)))
|