test(rtc,e2e): add paste-multiple-blocks-test

This commit is contained in:
rcmerci
2025-12-18 18:27:00 +08:00
parent cec20a543c
commit 5918429db1
2 changed files with 50 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
(w/grant-permissions :clipboard-write :clipboard-read)
(binding [custom-report/*pw-contexts* #{(.context (w/get-page))}
custom-report/*pw-page->console-logs* (atom {})]
(w/grant-permissions :clipboard-write :clipboard-read)
(w/navigate (pw-page/get-test-url port))
(settings/developer-mode)
(w/refresh)
@@ -50,6 +51,7 @@
w/*page* (delay (throw (ex-info "Don't use *page*, use *page1* and *page2* instead" {})))]
(run!
#(w/with-page %
(w/grant-permissions :clipboard-write :clipboard-read)
(w/navigate (pw-page/get-test-url port))
(settings/developer-mode)
(w/refresh)

View File

@@ -53,3 +53,51 @@ wait for 5-10 seconds, will found that \"aaa/bbb\" became \"aaa/<encrypted-strin
(page/goto-page "aaa/bbb"))
(rtc/validate-graphs-in-2-pw-pages)))
(deftest paste-multiple-blocks-test
(testing "
1. create 3 blocks
- block1
- block2
- block3
2. copy these 3 blocks
3. when cursor at block3, press <enter> to create a new block
4. paste them at current position 5 times
5. validate blocks are same on both clients"
(w/with-page @*page1
(b/new-blocks ["block1" "block2" "block3"])
(util/exit-edit)
(b/select-blocks 2)
(b/copy)
(b/jump-to-block "block3")
(util/repeat-keyboard 1 "Enter"))
(dotimes [_ 5]
(let [{:keys [remote-tx]}
(w/with-page @*page1
(rtc/with-wait-tx-updated
(b/paste)))]
(w/with-page @*page2
(rtc/wait-tx-update-to remote-tx))))
(let [{:keys [remote-tx]}
(w/with-page @*page1
(rtc/with-wait-tx-updated
(b/new-block "sync-trigger")))]
(w/with-page @*page2
(rtc/wait-tx-update-to remote-tx)))
(let [expected (vec (concat ["block1" "block2" "block3"]
(take (* 3 5) (cycle ["block1" "block2" "block3"]))
["sync-trigger"]))]
(w/with-page @*page1
(util/exit-edit)
(is (= expected
(util/get-page-blocks-contents))))
(w/with-page @*page2
(util/exit-edit)
(is (= expected
(util/get-page-blocks-contents)))))
(rtc/validate-graphs-in-2-pw-pages)))