|
@@ -601,7 +601,8 @@
|
|
|
(is (= (expand-classes (:classes original-data)) (:classes imported-nodes)))))
|
|
(is (= (expand-classes (:classes original-data)) (:classes imported-nodes)))))
|
|
|
|
|
|
|
|
(defn- build-original-graph-data
|
|
(defn- build-original-graph-data
|
|
|
- [& {:keys [exclude-namespaces?]}]
|
|
|
|
|
|
|
+ [& {:keys [exclude-namespaces? add-built-in-pages?]
|
|
|
|
|
+ :or {add-built-in-pages? true}}]
|
|
|
(let [internal-block-uuid (random-uuid)
|
|
(let [internal-block-uuid (random-uuid)
|
|
|
favorited-uuid (random-uuid)
|
|
favorited-uuid (random-uuid)
|
|
|
block-pvalue-uuid (random-uuid)
|
|
block-pvalue-uuid (random-uuid)
|
|
@@ -719,30 +720,7 @@
|
|
|
{:page {:block/uuid class2-uuid}
|
|
{:page {:block/uuid class2-uuid}
|
|
|
:blocks [{:block/title "class2 block1"}]}
|
|
:blocks [{:block/title "class2 block1"}]}
|
|
|
{:page {:block/uuid property-uuid}
|
|
{:page {:block/uuid property-uuid}
|
|
|
- :blocks [{:block/title "property block1"}]}
|
|
|
|
|
- ;; built-in pages
|
|
|
|
|
- {:page {:block/title "Library" :build/properties {:logseq.property/built-in? true}}
|
|
|
|
|
- :blocks []}
|
|
|
|
|
- {:page {:block/title "Quick add" :build/properties {:logseq.property/built-in? true
|
|
|
|
|
- :logseq.property/hide? true}}, :blocks []}
|
|
|
|
|
- {:page {:block/title "Contents" :build/properties {:logseq.property/built-in? true}}
|
|
|
|
|
- :blocks [{:block/title "right sidebar"}]}
|
|
|
|
|
- {:page {:block/title common-config/favorites-page-name
|
|
|
|
|
- :build/properties {:logseq.property/built-in? true, :logseq.property/hide? true}}
|
|
|
|
|
- :blocks [(ldb/build-favorite-tx favorited-uuid)]}
|
|
|
|
|
- {:page {:block/title common-config/views-page-name
|
|
|
|
|
- :build/properties {:logseq.property/built-in? true, :logseq.property/hide? true}}
|
|
|
|
|
- :blocks [{:block/title "All"
|
|
|
|
|
- :build/properties {:logseq.property/view-for :logseq.class/Task
|
|
|
|
|
- :logseq.property.view/feature-type :class-objects}}
|
|
|
|
|
- {:block/title "All"
|
|
|
|
|
- :build/properties {:logseq.property/view-for :user.class/MyClass
|
|
|
|
|
- :logseq.property.view/feature-type :class-objects}}
|
|
|
|
|
- {:block/title "Linked references",
|
|
|
|
|
- :build/properties
|
|
|
|
|
- {:logseq.property.view/type :logseq.property.view/type.list,
|
|
|
|
|
- :logseq.property.view/feature-type :linked-references,
|
|
|
|
|
- :logseq.property/view-for [:block/uuid journal-uuid]}}]}]
|
|
|
|
|
|
|
+ :blocks [{:block/title "property block1"}]}]
|
|
|
::sqlite-export/graph-files
|
|
::sqlite-export/graph-files
|
|
|
[{:file/path "logseq/config.edn"
|
|
[{:file/path "logseq/config.edn"
|
|
|
:file/content "{:foo :bar}"}
|
|
:file/content "{:foo :bar}"}
|
|
@@ -754,10 +732,35 @@
|
|
|
:file/content ""}
|
|
:file/content ""}
|
|
|
{:file/path "logseq/publish.js"
|
|
{:file/path "logseq/publish.js"
|
|
|
:file/content ""}]
|
|
:file/content ""}]
|
|
|
- :build-existing-tx? true}]
|
|
|
|
|
- original-data))
|
|
|
|
|
-
|
|
|
|
|
-(deftest import-graph
|
|
|
|
|
|
|
+ :build-existing-tx? true}
|
|
|
|
|
+ built-in-pages
|
|
|
|
|
+ [{:page {:block/title "Library" :build/properties {:logseq.property/built-in? true}}
|
|
|
|
|
+ :blocks []}
|
|
|
|
|
+ {:page {:block/title "Quick add" :build/properties {:logseq.property/built-in? true
|
|
|
|
|
+ :logseq.property/hide? true}}, :blocks []}
|
|
|
|
|
+ {:page {:block/title "Contents" :build/properties {:logseq.property/built-in? true}}
|
|
|
|
|
+ :blocks [{:block/title "right sidebar"}]}
|
|
|
|
|
+ {:page {:block/title common-config/favorites-page-name
|
|
|
|
|
+ :build/properties {:logseq.property/built-in? true, :logseq.property/hide? true}}
|
|
|
|
|
+ :blocks [(ldb/build-favorite-tx favorited-uuid)]}
|
|
|
|
|
+ {:page {:block/title common-config/views-page-name
|
|
|
|
|
+ :build/properties {:logseq.property/built-in? true, :logseq.property/hide? true}}
|
|
|
|
|
+ :blocks [{:block/title "All"
|
|
|
|
|
+ :build/properties {:logseq.property/view-for :logseq.class/Task
|
|
|
|
|
+ :logseq.property.view/feature-type :class-objects}}
|
|
|
|
|
+ {:block/title "All"
|
|
|
|
|
+ :build/properties {:logseq.property/view-for :user.class/MyClass
|
|
|
|
|
+ :logseq.property.view/feature-type :class-objects}}
|
|
|
|
|
+ {:block/title "Linked references",
|
|
|
|
|
+ :build/properties
|
|
|
|
|
+ {:logseq.property.view/type :logseq.property.view/type.list,
|
|
|
|
|
+ :logseq.property.view/feature-type :linked-references,
|
|
|
|
|
+ :logseq.property/view-for [:block/uuid journal-uuid]}}]}]]
|
|
|
|
|
+ (cond-> original-data
|
|
|
|
|
+ add-built-in-pages?
|
|
|
|
|
+ (update :pages-and-blocks into built-in-pages))))
|
|
|
|
|
+
|
|
|
|
|
+(deftest ^:long import-graph
|
|
|
(let [original-data (build-original-graph-data)
|
|
(let [original-data (build-original-graph-data)
|
|
|
conn (db-test/create-conn-with-blocks (dissoc original-data ::sqlite-export/graph-files))
|
|
conn (db-test/create-conn-with-blocks (dissoc original-data ::sqlite-export/graph-files))
|
|
|
;; set to an unobtainable version to test this ident
|
|
;; set to an unobtainable version to test this ident
|
|
@@ -785,7 +788,7 @@
|
|
|
(:kv/value (d/entity @conn2 :logseq.kv/schema-version)))
|
|
(:kv/value (d/entity @conn2 :logseq.kv/schema-version)))
|
|
|
"Ignored :kv/value is not updated")))
|
|
"Ignored :kv/value is not updated")))
|
|
|
|
|
|
|
|
-(deftest import-graph-with-timestamps
|
|
|
|
|
|
|
+(deftest ^:long import-graph-with-timestamps
|
|
|
(let [original-data* (build-original-graph-data)
|
|
(let [original-data* (build-original-graph-data)
|
|
|
original-data (-> original-data*
|
|
original-data (-> original-data*
|
|
|
(update :pages-and-blocks
|
|
(update :pages-and-blocks
|
|
@@ -815,7 +818,7 @@
|
|
|
(is (= (::sqlite-export/graph-files original-data) (::sqlite-export/graph-files imported-graph))
|
|
(is (= (::sqlite-export/graph-files original-data) (::sqlite-export/graph-files imported-graph))
|
|
|
"All :file/path entities are imported")))
|
|
"All :file/path entities are imported")))
|
|
|
|
|
|
|
|
-(deftest import-graph-with-exclude-namespaces
|
|
|
|
|
|
|
+(deftest ^:long import-graph-with-exclude-namespaces
|
|
|
(let [original-data (build-original-graph-data {:exclude-namespaces? true})
|
|
(let [original-data (build-original-graph-data {:exclude-namespaces? true})
|
|
|
conn (db-test/create-conn-with-blocks (dissoc original-data ::sqlite-export/graph-files))
|
|
conn (db-test/create-conn-with-blocks (dissoc original-data ::sqlite-export/graph-files))
|
|
|
_ (d/transact! conn (::sqlite-export/graph-files original-data))
|
|
_ (d/transact! conn (::sqlite-export/graph-files original-data))
|
|
@@ -830,6 +833,21 @@
|
|
|
(is (= (::sqlite-export/graph-files original-data) (::sqlite-export/graph-files imported-graph))
|
|
(is (= (::sqlite-export/graph-files original-data) (::sqlite-export/graph-files imported-graph))
|
|
|
"All :file/path entities are imported")))
|
|
"All :file/path entities are imported")))
|
|
|
|
|
|
|
|
|
|
+(deftest ^:long graph-is-idempotent-across-import-and-export
|
|
|
|
|
+ ;; FIXME: built-in pages should be idempotent across export and import
|
|
|
|
|
+ (let [original-data (build-original-graph-data {:add-built-in-pages? false})
|
|
|
|
|
+ conn (db-test/create-conn-with-blocks (dissoc original-data ::sqlite-export/graph-files))
|
|
|
|
|
+ _ (d/transact! conn (::sqlite-export/graph-files original-data))
|
|
|
|
|
+ export-map (sqlite-export/build-export @conn {:export-type :graph})
|
|
|
|
|
+ valid-result (sqlite-export/validate-export export-map)
|
|
|
|
|
+ _ (assert (not (:error valid-result)) "No error when importing export-map into new graph")
|
|
|
|
|
+ _ (validate-db (:db valid-result))
|
|
|
|
|
+ export-map2 (sqlite-export/build-export (:db valid-result) {:export-type :graph})]
|
|
|
|
|
+ ;; (cljs.pprint/pprint (sqlite-export/diff-exports export-map export-map2))
|
|
|
|
|
+ (is (= nil
|
|
|
|
|
+ (sqlite-export/diff-exports export-map export-map2))
|
|
|
|
|
+ "No diff between original export and export after importing into a new graph")))
|
|
|
|
|
+
|
|
|
(deftest import-graph-with-different-property-value-cases
|
|
(deftest import-graph-with-different-property-value-cases
|
|
|
(let [pvalue-uuid1 (random-uuid)
|
|
(let [pvalue-uuid1 (random-uuid)
|
|
|
original-data
|
|
original-data
|