|
|
@@ -5,7 +5,9 @@
|
|
|
[datascript.core :as d]
|
|
|
[logseq.db.sqlite.common-db :as sqlite-common-db]
|
|
|
[logseq.db.frontend.schema :as db-schema]
|
|
|
- [logseq.db.sqlite.db :as sqlite-db]))
|
|
|
+ [logseq.common.util.date-time :as date-time-util]
|
|
|
+ [logseq.db.sqlite.db :as sqlite-db]
|
|
|
+ [clojure.string :as string]))
|
|
|
|
|
|
(use-fixtures
|
|
|
:each
|
|
|
@@ -40,16 +42,20 @@
|
|
|
"Correct file with content is found"))))
|
|
|
|
|
|
(deftest restore-initial-data
|
|
|
- (testing "Restore a journal page with its block"
|
|
|
+ (testing "Restore a journal page"
|
|
|
(create-graph-dir "tmp/graphs" "test-db")
|
|
|
(let [conn* (sqlite-db/open-db! "tmp/graphs" "test-db")
|
|
|
page-uuid (random-uuid)
|
|
|
block-uuid (random-uuid)
|
|
|
created-at (js/Date.now)
|
|
|
+ date-int (date-time-util/date->int (js/Date.))
|
|
|
+ date-title (date-time-util/int->journal-title date-int "MMM do, yyyy")
|
|
|
blocks [{:db/id 100001
|
|
|
:block/uuid page-uuid
|
|
|
- :block/journal-day 20230629
|
|
|
- :block/name "jun 29th, 2023"
|
|
|
+ :block/journal? true
|
|
|
+ :block/journal-day date-int
|
|
|
+ :block/name (string/lower-case date-title)
|
|
|
+ :block/original-name date-title
|
|
|
:block/created-at created-at
|
|
|
:block/updated-at created-at}
|
|
|
{:db/id 100002
|
|
|
@@ -62,9 +68,9 @@
|
|
|
;; Simulate getting data from sqlite and restoring it for frontend
|
|
|
conn (-> (sqlite-common-db/get-initial-data @conn*)
|
|
|
(sqlite-common-db/restore-initial-data db-schema/schema-for-db-based-graph))]
|
|
|
- (is (= blocks
|
|
|
+ (is (= (take 1 blocks)
|
|
|
(->> (d/q '[:find (pull ?b [*])
|
|
|
:where [?b :block/created-at]]
|
|
|
@conn)
|
|
|
(map first)))
|
|
|
- "Datascript db matches data inserted into sqlite"))))
|
|
|
+ "Journal page is included in initial restore while its block is not"))))
|