test(e2e): add rtc-outliner-test

This commit is contained in:
rcmerci
2025-05-21 22:50:45 +08:00
parent 5b76ee46a3
commit 1a0adf1e51
2 changed files with 51 additions and 6 deletions

View File

@@ -12,14 +12,14 @@
fixtures/new-logseq-page
fixtures/validate-graph)
(deftest create-test-page-and-insert-blocks
(defn create-test-page-and-insert-blocks []
;; a page block and a child block
(is (= 2 (util/blocks-count)))
(b/new-blocks ["first block" "second block"])
(util/exit-edit)
(is (= 3 (util/blocks-count))))
(deftest indent-and-outdent-test
(defn indent-and-outdent []
(b/new-blocks ["b1" "b2"])
(testing "simple indent and outdent"
(b/indent)
@@ -44,7 +44,7 @@
(let [[x2 x3 x4 x5] (map (comp first util/bounding-xy #(w/find-one-by-text "span" %)) ["b2" "b3" "b4" "b5"])]
(is (and (= x2 x4) (= x3 x5) (< x2 x3))))))
(deftest move-up-down-test
(defn move-up-down []
(b/new-blocks ["b1" "b2" "b3" "b4"])
(util/repeat-keyboard 2 "Shift+ArrowUp")
(let [contents (util/get-page-blocks-contents)]
@@ -56,16 +56,16 @@
(let [contents (util/get-page-blocks-contents)]
(is (= contents ["b1" "b2" "b3" "b4"]))))
(deftest delete-test
(defn delete []
(testing "Delete blocks case 1"
(b/new-blocks ["b1" "b2" "b3" "b4"])
(b/delete-blocks) ; delete b4
(b/delete-blocks) ; delete b4
(util/repeat-keyboard 2 "Shift+ArrowUp") ; select b3 and b2
(b/delete-blocks)
(is (= "b1" (util/get-edit-content)))
(is (= 1 (util/page-blocks-count)))))
(deftest delete-test-with-children
(defn delete-test-with-children []
(testing "Delete block with its children"
(b/new-blocks ["b1" "b2" "b3" "b4"])
(b/indent)
@@ -75,3 +75,18 @@
(b/delete-blocks)
(is (= "b1" (util/get-edit-content)))
(is (= 1 (util/page-blocks-count)))))
(deftest create-test-page-and-insert-blocks-test
(create-test-page-and-insert-blocks))
(deftest indent-and-outdent-test
(indent-and-outdent))
(deftest move-up-down-test
(move-up-down))
(deftest delete-test
(delete))
(deftest delete-test-with-children-test
(delete-test-with-children))

View File

@@ -8,6 +8,7 @@
[logseq.e2e.graph :as graph]
[logseq.e2e.keyboard :as k]
[logseq.e2e.locator :as loc]
[logseq.e2e.outliner-basic-test :as outliner-basic-test]
[logseq.e2e.page :as page]
[logseq.e2e.rtc :as rtc]
[logseq.e2e.settings :as settings]
@@ -168,6 +169,35 @@ page1: rtc-start"
(rtc/wait-tx-update-to @*latest-remote-tx))
(validate-2-graphs)))))
(deftest rtc-outliner-test
(doseq [test-fn [outliner-basic-test/create-test-page-and-insert-blocks
outliner-basic-test/indent-and-outdent
outliner-basic-test/move-up-down
outliner-basic-test/delete
outliner-basic-test/delete-test-with-children]]
(let [test-fn-in-page2 (fn [*latest-remote-tx]
(w/with-page @*page2
(let [{:keys [_local-tx remote-tx]}
(rtc/with-wait-tx-updated
(test-fn))]
(reset! *latest-remote-tx remote-tx))))]
;; testing while rtc connected
(let [*latest-remote-tx (atom nil)]
(new-logseq-page)
(test-fn-in-page2 *latest-remote-tx)
(w/with-page @*page1
(rtc/wait-tx-update-to @*latest-remote-tx))
(validate-2-graphs))
;; testing while rtc off then on
(let [*latest-remote-tx (atom nil)]
(new-logseq-page)
(with-stop-restart-rtc @*page1 #(test-fn-in-page2 *latest-remote-tx))
(w/with-page @*page1
(rtc/wait-tx-update-to @*latest-remote-tx))
(validate-2-graphs)))))
(comment
(let [title-prefix "xxxx"
property-type "Text"]