|
@@ -5,22 +5,21 @@
|
|
|
[frontend.handler.page :as page-handler]
|
|
[frontend.handler.page :as page-handler]
|
|
|
[frontend.state :as state]
|
|
[frontend.state :as state]
|
|
|
[frontend.test.helper :as test-helper]
|
|
[frontend.test.helper :as test-helper]
|
|
|
- [frontend.worker.rtc.const :as rtc-const]
|
|
|
|
|
[frontend.worker.rtc.client :as r.client]
|
|
[frontend.worker.rtc.client :as r.client]
|
|
|
|
|
+ [frontend.worker.rtc.const :as rtc-const]
|
|
|
[frontend.worker.rtc.fixture :as rtc-fixture]
|
|
[frontend.worker.rtc.fixture :as rtc-fixture]
|
|
|
[frontend.worker.state :as worker-state]
|
|
[frontend.worker.state :as worker-state]
|
|
|
[logseq.common.config :as common-config]
|
|
[logseq.common.config :as common-config]
|
|
|
|
|
+ [logseq.db :as ldb]
|
|
|
[logseq.outliner.core :as outliner-core]
|
|
[logseq.outliner.core :as outliner-core]
|
|
|
- [logseq.outliner.transaction :as outliner-tx]
|
|
|
|
|
- [logseq.db :as ldb]))
|
|
|
|
|
-
|
|
|
|
|
|
|
+ [logseq.outliner.transaction :as outliner-tx]))
|
|
|
|
|
|
|
|
(use-fixtures :each
|
|
(use-fixtures :each
|
|
|
test-helper/db-based-start-and-destroy-db-map-fixture
|
|
test-helper/db-based-start-and-destroy-db-map-fixture
|
|
|
rtc-fixture/listen-test-db-to-gen-rtc-ops-fixture
|
|
rtc-fixture/listen-test-db-to-gen-rtc-ops-fixture
|
|
|
rtc-fixture/clear-op-mem-stores-fixture)
|
|
rtc-fixture/clear-op-mem-stores-fixture)
|
|
|
|
|
|
|
|
-(deftest ^:fix-me local-db-tx->remote-ops-test
|
|
|
|
|
|
|
+(deftest local-db-tx->remote-ops-test
|
|
|
(let [repo (state/get-current-repo)
|
|
(let [repo (state/get-current-repo)
|
|
|
conn (conn/get-db repo false)
|
|
conn (conn/get-db repo false)
|
|
|
[page1-uuid
|
|
[page1-uuid
|
|
@@ -38,10 +37,19 @@
|
|
|
r))]
|
|
r))]
|
|
|
(testing "create a new page"
|
|
(testing "create a new page"
|
|
|
(page-handler/create! page1-name {:redirect? false :create-first-block? false :uuid page1-uuid})
|
|
(page-handler/create! page1-name {:redirect? false :create-first-block? false :uuid page1-uuid})
|
|
|
- (let [ops (gen-ops-fn)]
|
|
|
|
|
|
|
+ (let [ops (gen-ops-fn)
|
|
|
|
|
+ ops* (map
|
|
|
|
|
+ (fn [[op-type op-value]]
|
|
|
|
|
+ [op-type (cond-> op-value
|
|
|
|
|
+ (:av-coll op-value) (assoc :av-coll-keys (map first (:av-coll op-value)))
|
|
|
|
|
+ true (dissoc :av-coll))])
|
|
|
|
|
+ ops)]
|
|
|
(is (= [[:update-page {:block-uuid page1-uuid
|
|
(is (= [[:update-page {:block-uuid page1-uuid
|
|
|
:page-name page1-name
|
|
:page-name page1-name
|
|
|
- :original-name page1-name}]] ops))))
|
|
|
|
|
|
|
+ :original-name page1-name}]
|
|
|
|
|
+ [:update {:block-uuid page1-uuid
|
|
|
|
|
+ :pos [nil :no-parent-sibling]
|
|
|
|
|
+ :av-coll-keys [:block/created-at :block/updated-at]}]] ops*))))
|
|
|
|
|
|
|
|
(testing "insert some blocks"
|
|
(testing "insert some blocks"
|
|
|
(outliner-tx/transact!
|
|
(outliner-tx/transact!
|
|
@@ -49,11 +57,10 @@
|
|
|
(outliner-core/insert-blocks!
|
|
(outliner-core/insert-blocks!
|
|
|
repo
|
|
repo
|
|
|
conn
|
|
conn
|
|
|
- [{:block/uuid uuid1 :block/content "uuid1-client"
|
|
|
|
|
- :block/left [:block/uuid page1-uuid]
|
|
|
|
|
|
|
+ [{:block/uuid uuid1
|
|
|
|
|
+ :block/content "uuid1-client"
|
|
|
:block/parent [:block/uuid page1-uuid]}
|
|
:block/parent [:block/uuid page1-uuid]}
|
|
|
{:block/uuid uuid2 :block/content "uuid2-client"
|
|
{:block/uuid uuid2 :block/content "uuid2-client"
|
|
|
- :block/left [:block/uuid uuid1]
|
|
|
|
|
:block/parent [:block/uuid page1-uuid]}]
|
|
:block/parent [:block/uuid page1-uuid]}]
|
|
|
(ldb/get-page @conn page1-name)
|
|
(ldb/get-page @conn page1-name)
|
|
|
{:sibling? true :keep-uuid? true}))
|
|
{:sibling? true :keep-uuid? true}))
|
|
@@ -62,7 +69,7 @@
|
|
|
[:move uuid2 uuid1]
|
|
[:move uuid2 uuid1]
|
|
|
[:update uuid1 page1-uuid]
|
|
[:update uuid1 page1-uuid]
|
|
|
[:update uuid2 uuid1]}
|
|
[:update uuid2 uuid1]}
|
|
|
- (set (map (juxt first (comp :block-uuid second) (comp :target-uuid second)) ops))))))
|
|
|
|
|
|
|
+ (set (map (juxt first (comp :block-uuid second) (comp first :pos second)) ops))))))
|
|
|
|
|
|
|
|
(testing "remove some blocks"
|
|
(testing "remove some blocks"
|
|
|
(outliner-tx/transact!
|
|
(outliner-tx/transact!
|