mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
test(rtc): add basic-edits-test
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
|
||||
:rtc-e2e-test {:target :browser-test
|
||||
:test-dir "static/rtc-e2e-test"
|
||||
:closure-defines {frontend.worker.rtc.const/RTC-E2E-TEST true}
|
||||
:closure-defines {frontend.worker.rtc.const/RTC-E2E-TEST* true}
|
||||
:devtools {:enabled false}
|
||||
:compiler-options {:infer-externs :auto
|
||||
:output-feature-set :es-next-in
|
||||
|
||||
@@ -83,6 +83,12 @@ generate asset-change events.")
|
||||
(when (seq blocks-to-add)
|
||||
(.search-upsert-blocks wo repo (bean/->js blocks-to-add))))))))))
|
||||
|
||||
(comment
|
||||
(defmethod listen-db-changes :debug-listen-db-changes
|
||||
[_ {:keys [tx-data tx-meta]}]
|
||||
(prn :debug-listen-db-changes)
|
||||
(prn :tx-data tx-data)
|
||||
(prn :tx-meta tx-meta)))
|
||||
|
||||
(defn listen-db-changes!
|
||||
[repo conn & {:keys [handler-keys]}]
|
||||
@@ -90,7 +96,7 @@ generate asset-change events.")
|
||||
(select-keys (methods listen-db-changes) handler-keys)
|
||||
(methods listen-db-changes))]
|
||||
(d/unlisten! conn ::listen-db-changes!)
|
||||
(prn :listen-db-changes! (keys handlers))
|
||||
(prn :listen-db-changes! (keys handlers) :repo repo)
|
||||
(d/listen! conn ::listen-db-changes!
|
||||
(fn [{:keys [tx-data _db-before _db-after tx-meta] :as tx-report}]
|
||||
(let [tx-meta (merge (batch-tx/get-batch-opts) tx-meta)
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
[malli.transform :as mt]
|
||||
[malli.util :as mu]))
|
||||
|
||||
(goog-define RTC-E2E-TEST false)
|
||||
(goog-define RTC-E2E-TEST* false)
|
||||
(def RTC-E2E-TEST RTC-E2E-TEST*)
|
||||
|
||||
(def block-pos-schema
|
||||
[:catn
|
||||
|
||||
45
src/rtc_e2e_test/basic_edits_test.cljs
Normal file
45
src/rtc_e2e_test/basic_edits_test.cljs
Normal file
@@ -0,0 +1,45 @@
|
||||
(ns basic-edits-test
|
||||
(:require [cljs.test :as t :refer [deftest testing is]]
|
||||
[fixture]
|
||||
[helper]
|
||||
[frontend.worker.rtc.client-op :as client-op]
|
||||
[const]
|
||||
[datascript.core :as d]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.outliner.batch-tx :as batch-tx]))
|
||||
|
||||
(t/use-fixtures :once
|
||||
fixture/install-some-consts
|
||||
fixture/install-example-db-fixture
|
||||
fixture/clear-test-remote-graphs-fixture
|
||||
fixture/build-two-conns-by-download-example-graph-fixture)
|
||||
|
||||
(deftest basic-edits-test
|
||||
(let [conn1 (helper/get-downloaded-test-conn)
|
||||
conn2 (helper/get-downloaded-test-conn2)
|
||||
[page-uuid1 block-uuid1] (repeatedly random-uuid)]
|
||||
(testing "create page first"
|
||||
(let [tx-data [{:db/id "page"
|
||||
:block/name "basic-edits-test"
|
||||
:block/title "basic-edits-test"
|
||||
:block/uuid page-uuid1
|
||||
:block/created-at 1724836490809
|
||||
:block/updated-at 1724836490809
|
||||
:block/type "page"
|
||||
:block/format :markdown}
|
||||
{:block/uuid block-uuid1
|
||||
:block/updated-at 1724836490810
|
||||
:block/created-at 1724836490810
|
||||
:block/format :markdown
|
||||
:block/title "block1"
|
||||
:block/parent "page"
|
||||
:block/order "a0"
|
||||
:block/page "page"}]]
|
||||
(batch-tx/with-batch-tx-mode conn1 {:e2e-test const/downloaded-test-repo}
|
||||
(d/transact! conn1 tx-data))
|
||||
(is (=
|
||||
#{[:update page-uuid1] [:update-page page-uuid1] [:move block-uuid1] [:update block-uuid1]}
|
||||
(set (map (juxt first (comp :block-uuid last)) (client-op/get-all-ops const/downloaded-test-repo)))))
|
||||
(prn :all-ops
|
||||
(client-op/get-all-ops const/downloaded-test-repo)
|
||||
(client-op/get-local-tx const/downloaded-test-repo))))))
|
||||
@@ -1,12 +0,0 @@
|
||||
(ns block-update-test
|
||||
(:require [cljs.test :as t :refer [deftest]]
|
||||
[fixture]))
|
||||
|
||||
(t/use-fixtures :once
|
||||
fixture/install-some-consts
|
||||
fixture/install-example-db-fixture
|
||||
fixture/clear-test-remote-graphs-fixture
|
||||
fixture/build-two-conns-by-download-example-graph-fixture)
|
||||
|
||||
(deftest insert-blocks-test
|
||||
)
|
||||
@@ -5,6 +5,7 @@
|
||||
[example]
|
||||
[frontend.common.missionary-util :as c.m]
|
||||
[frontend.worker.rtc.client-op :as client-op]
|
||||
[frontend.worker.rtc.db-listener]
|
||||
[frontend.worker.state :as worker-state]
|
||||
[helper]
|
||||
[missionary.core :as m]))
|
||||
@@ -42,6 +43,9 @@
|
||||
(c.m/run-task-throw
|
||||
(m/sp
|
||||
(swap! worker-state/*datascript-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2)
|
||||
(swap! worker-state/*client-ops-conns assoc
|
||||
const/downloaded-test-repo (d/create-conn client-op/schema-in-db)
|
||||
const/downloaded-test-repo2 (d/create-conn client-op/schema-in-db))
|
||||
(let [{:keys [graph-uuid]} (m/? helper/new-task--upload-example-graph)]
|
||||
(m/? (helper/new-task--wait-creating-graph graph-uuid))
|
||||
(m/? (helper/new-task--download-graph graph-uuid const/downloaded-test-graph-name))
|
||||
@@ -49,4 +53,5 @@
|
||||
(done)))
|
||||
:build-two-conns-by-download-example-graph-fixture))
|
||||
:after
|
||||
#(swap! worker-state/*datascript-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2)})
|
||||
#(do (swap! worker-state/*datascript-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2)
|
||||
(swap! worker-state/*client-ops-conns dissoc const/downloaded-test-repo const/downloaded-test-repo2))})
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
[]
|
||||
(worker-state/get-datascript-conn const/downloaded-test-repo))
|
||||
|
||||
(defn get-downloaded-test-conn2
|
||||
[]
|
||||
(worker-state/get-datascript-conn const/downloaded-test-repo2))
|
||||
|
||||
(defn get-example-test-conn
|
||||
[]
|
||||
(worker-state/get-datascript-conn const/test-repo))
|
||||
|
||||
Reference in New Issue
Block a user