mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
test(e2e): split ns logseq.e2e.block
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
(def assert-that PlaywrightAssertions/assertThat)
|
||||
|
||||
(defn assert-is-visible
|
||||
"Multiple elements may match `q`, check and wait for the first element to be visible."
|
||||
[q]
|
||||
(-> (w/-query q) assert-that .isVisible)
|
||||
(-> q w/query first assert-that .isVisible)
|
||||
true)
|
||||
|
||||
(defn assert-is-hidden
|
||||
@@ -23,3 +24,7 @@
|
||||
(assert-is-hidden ".selection-action-bar")
|
||||
(assert-is-visible "#search-button")
|
||||
true)
|
||||
|
||||
(defn assert-graph-loaded?
|
||||
[]
|
||||
(assert-is-visible "span.block-title-wrap"))
|
||||
|
||||
41
clj-e2e/src/logseq/e2e/block.clj
Normal file
41
clj-e2e/src/logseq/e2e/block.clj
Normal file
@@ -0,0 +1,41 @@
|
||||
(ns logseq.e2e.block
|
||||
(:require [logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.keyboard :as k]
|
||||
[logseq.e2e.util :as util]
|
||||
[wally.main :as w]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn open-last-block
|
||||
[]
|
||||
(util/double-esc)
|
||||
(assert/assert-in-normal-mode?)
|
||||
(w/click (last (w/query ".ls-page-blocks .ls-block .block-content"))))
|
||||
|
||||
(defn new-block
|
||||
[title]
|
||||
(k/enter)
|
||||
(util/input title))
|
||||
|
||||
(defn save-block
|
||||
[text]
|
||||
(util/input text))
|
||||
|
||||
(defn delete-blocks
|
||||
"Delete the current block if in editing mode, otherwise, delete all the selected blocks."
|
||||
[]
|
||||
(let [editor (util/get-editor)]
|
||||
(when editor (util/exit-edit))
|
||||
(k/backspace)))
|
||||
|
||||
;; TODO: support tree
|
||||
(defn new-blocks
|
||||
[titles]
|
||||
(open-last-block)
|
||||
(let [value (util/get-edit-content)]
|
||||
(if (string/blank? value) ; empty block
|
||||
(do
|
||||
(save-block (first titles))
|
||||
(doseq [title (rest titles)]
|
||||
(new-block title)))
|
||||
(doseq [title titles]
|
||||
(new-block title)))))
|
||||
@@ -1,11 +1,17 @@
|
||||
(ns logseq.e2e.graph
|
||||
(:require [logseq.e2e.util :as util]
|
||||
(:require [logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.util :as util]
|
||||
[wally.main :as w]))
|
||||
|
||||
(defn- refresh-all-remote-graphs
|
||||
[]
|
||||
(w/click "span:text(\"Refresh\")"))
|
||||
|
||||
(defn goto-all-graphs
|
||||
[]
|
||||
(util/search "go to all graphs")
|
||||
(w/click (w/get-by-label "Go to all graphs")))
|
||||
|
||||
(defn new-graph
|
||||
[graph-name enable-sync?]
|
||||
(util/search "add a db graph")
|
||||
@@ -21,14 +27,19 @@
|
||||
|
||||
(defn wait-for-remote-graph
|
||||
[graph-name]
|
||||
(util/search "go to all graphs")
|
||||
(w/click (w/get-by-label "Go to all graphs"))
|
||||
(goto-all-graphs)
|
||||
(util/repeat-until-visible 5
|
||||
(format "div[aria-label='e2e %s']" graph-name)
|
||||
(format "div[aria-label='e2e logseq_db_%s']" graph-name)
|
||||
refresh-all-remote-graphs))
|
||||
|
||||
(defn remove-remote-graph
|
||||
[graph-name]
|
||||
(wait-for-remote-graph graph-name)
|
||||
(w/click (format "div[aria-label='e2e %s'] a:has-text(\"Remove (server)\")" graph-name))
|
||||
(w/click (format "div[aria-label='e2e logseq_db_%s'] a:has-text(\"Remove (server)\")" graph-name))
|
||||
(w/click "div[role='alertdialog'] button:text('ok')"))
|
||||
|
||||
(defn switch-graph
|
||||
[to-graph-name]
|
||||
(goto-all-graphs)
|
||||
(w/click (format "div[aria-label='e2e logseq_db_%1$s'] span:text('%1$s')" to-graph-name))
|
||||
(assert/assert-graph-loaded?))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns logseq.e2e.playwright-page
|
||||
"operations on playwright pages."
|
||||
(:require [logseq.e2e.config :as config]
|
||||
(:require [logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.config :as config]
|
||||
[wally.main :as w]))
|
||||
|
||||
(defn get-pages
|
||||
@@ -16,7 +17,7 @@
|
||||
(.navigate page url)
|
||||
;; wait the demo graph loaded
|
||||
(w/with-page page
|
||||
(w/wait-for "span.block-title-wrap"))))))
|
||||
(assert/assert-graph-loaded?))))))
|
||||
|
||||
(defn close-pages
|
||||
[pages]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns logseq.e2e.util
|
||||
(:refer-clojure :exclude [type])
|
||||
(:require [clojure.string :as string]
|
||||
[clojure.test :refer [is]]
|
||||
(:require [clojure.test :refer [is]]
|
||||
[logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.keyboard :as k]
|
||||
[wally.main :as w]
|
||||
@@ -87,26 +86,10 @@
|
||||
[]
|
||||
(count-elements ".ls-page-blocks .ls-block"))
|
||||
|
||||
(defn new-block
|
||||
[title]
|
||||
(k/enter)
|
||||
(input title))
|
||||
|
||||
(defn save-block
|
||||
[text]
|
||||
(input text))
|
||||
|
||||
(defn exit-edit
|
||||
[]
|
||||
(k/esc))
|
||||
|
||||
(defn delete-blocks
|
||||
"Delete the current block if in editing mode, otherwise, delete all the selected blocks."
|
||||
[]
|
||||
(let [editor (get-editor)]
|
||||
(when editor (exit-edit))
|
||||
(k/backspace)))
|
||||
|
||||
(defn get-text
|
||||
[locator]
|
||||
(if (string? locator)
|
||||
@@ -141,25 +124,6 @@
|
||||
[]
|
||||
(indent-outdent false))
|
||||
|
||||
(defn open-last-block
|
||||
[]
|
||||
(double-esc)
|
||||
(assert/assert-in-normal-mode?)
|
||||
(w/click (last (w/query ".ls-page-blocks .ls-block .block-content"))))
|
||||
|
||||
;; TODO: support tree
|
||||
(defn new-blocks
|
||||
[titles]
|
||||
(open-last-block)
|
||||
(let [value (get-edit-content)]
|
||||
(if (string/blank? value) ; empty block
|
||||
(do
|
||||
(save-block (first titles))
|
||||
(doseq [title (rest titles)]
|
||||
(new-block title)))
|
||||
(doseq [title titles]
|
||||
(new-block title)))))
|
||||
|
||||
(defn repeat-keyboard
|
||||
[n shortcut]
|
||||
(dotimes [_i n]
|
||||
|
||||
Reference in New Issue
Block a user