test(e2e): update logseq.e2e.rtc-extra-test

This commit is contained in:
rcmerci
2025-05-21 17:33:25 +08:00
parent b55a60dbd7
commit 87482b9534
3 changed files with 30 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
(ns logseq.e2e.assert
(:import [com.microsoft.playwright.assertions PlaywrightAssertions])
(:require [wally.main :as w]))
(:require [clojure.test :as t]
[wally.main :as w]))
(def assert-that PlaywrightAssertions/assertThat)
@@ -47,3 +48,13 @@
(defn assert-selected-block-text
[text]
(assert-is-visible (format ".ls-block.selected :text('%s')" text)))
(defn assert-graph-summary-equal
"`summary` is returned by `validate-graph`"
[summary1 summary2]
(let [compare-keys [:blocks :pages :classes :properties ;; :entities
]]
(t/is (= (select-keys summary1 compare-keys)
(select-keys summary2 compare-keys))
[summary1 summary2])))

View File

@@ -1,7 +1,10 @@
(ns logseq.e2e.graph
(:require [logseq.e2e.assert :as assert]
(:require [clojure.edn :as edn]
[clojure.string :as string]
[logseq.e2e.assert :as assert]
[logseq.e2e.util :as util]
[wally.main :as w]))
[wally.main :as w]
[logseq.e2e.locator :as loc]))
(defn- refresh-all-remote-graphs
[]
@@ -56,5 +59,8 @@
(defn validate-graph
[]
(util/search-and-click "(Dev) Validate current graph")
(assert/assert-is-visible ".notifications :has-text('Your graph is valid')")
(w/click ".notifications .ls-icon-x"))
(assert/assert-is-visible (loc/and ".notifications div" (w/get-by-text "Your graph is valid")))
(let [content (.textContent (loc/and ".notifications div" (w/get-by-text "Your graph is valid")))
summary (edn/read-string (subs content (string/index-of content "{")))]
(w/click ".notifications .ls-icon-x")
summary))

View File

@@ -2,6 +2,7 @@
(:require
[clojure.test :refer [deftest testing is use-fixtures run-tests]]
[com.climate.claypoole :as cp]
[logseq.e2e.assert :as assert]
[logseq.e2e.block :as b]
[logseq.e2e.fixtures :as fixtures :refer [*page1 *page2]]
[logseq.e2e.graph :as graph]
@@ -60,8 +61,10 @@
(util/exit-edit))
(w/with-page @*page1
(rtc/rtc-start)
(repl/pause)
(rtc/wait-tx-update-to @*latest-remote-tx)
;; TODO: check blocks exist
)))))
(rtc/wait-tx-update-to @*latest-remote-tx))
(let [[p1-summary p2-summary]
(map (fn [p]
(w/with-page p
(graph/validate-graph)))
[@*page1 @*page2])]
(assert/assert-graph-summary-equal p1-summary p2-summary))))))