fix: db import failing on namespace pages with built-in name

e.g. term/alias in docs graph. Also added some basic namespace import
tests. Part of logseq/db-test#136 and part of LOG-3230
This commit is contained in:
Gabriel Horner
2024-10-18 09:46:21 -04:00
parent 28457cd02b
commit 3e05347379
4 changed files with 53 additions and 39 deletions

View File

@@ -329,6 +329,23 @@
(:block/title (find-block-by-content @conn #"tasks with")))
"Advanced query has custom title migrated"))
(testing "namespaces"
(let [expand-children (fn expand-children [ent parent]
(if-let [children (:logseq.property/_parent ent)]
(cons {:parent (:block/title parent) :child (:block/title ent)}
(mapcat #(expand-children % ent) children))
[{:parent (:block/title parent) :child (:block/title ent)}]))]
(is (= [{:parent "n1" :child "x"}
{:parent "x" :child "z"}
{:parent "x" :child "y"}]
(rest (expand-children (d/entity @conn (:db/id (find-page-by-name @conn "n1"))) nil)))
"First namespace tests duplicate parent page name")
(is (= [{:parent "n2" :child "x"}
{:parent "x" :child "z"}
{:parent "n2" :child "alias"}]
(rest (expand-children (d/entity @conn (:db/id (find-page-by-name @conn "n2"))) nil)))
"First namespace tests duplicate child page name and built-in page name")))
(testing "db attributes"
(is (= true
(:block/collapsed? (find-block-by-content @conn "collapsed block")))