test(e2e,rtc): add rtc-page-test

This commit is contained in:
rcmerci
2025-06-15 13:47:27 +08:00
parent 0feb634198
commit 988d31d830

View File

@@ -286,3 +286,43 @@ page2:
(k/enter)
(b/indent)))
(validate-2-graphs))))
(deftest rtc-page-test
(let [prefix "rtc-page-test-"]
(testing "create same name page in different clients.
- client1: offline, create page1
- client2: offline, create page1
- restart rtc"
(rtc/with-stop-restart-rtc
[@*page1 @*page2]
[@*page1 (rtc/with-wait-tx-updated (b/new-block "pw1-done-1"))
@*page2 (rtc/with-wait-tx-updated (b/new-block "pw2-done-1"))]
(w/with-page @*page1
(page/new-page (str prefix 1)))
(w/with-page @*page2
(page/new-page (str prefix 1))))
(validate-2-graphs))
(testing "
- client1: offline, add blocks on page-2
- client2: offline, delete page-2"
(let [page-name (str prefix 2)]
(let [*latest-remote-tx (atom nil)]
(w/with-page @*page1
(let [{:keys [_local-tx remote-tx]}
(rtc/with-wait-tx-updated
(page/new-page page-name))]
(reset! *latest-remote-tx remote-tx)))
(w/with-page @*page2
(rtc/wait-tx-update-to @*latest-remote-tx)))
(validate-2-graphs)
(rtc/with-stop-restart-rtc
[@*page1 @*page2]
[@*page1 (rtc/with-wait-tx-updated (b/new-block "pw1-done-2"))
@*page2 (rtc/with-wait-tx-updated (b/new-block "pw2-done-2"))]
(w/with-page @*page1
(b/new-blocks (map #(str "block-" %) (range 5))))
(w/with-page @*page2
(page/delete-page page-name)))
(validate-2-graphs)))))