Bladeren bron

test(e2e): add ns logseq.e2e.assert

rcmerci 6 maanden geleden
bovenliggende
commit
0b59755a21

+ 4 - 0
clj-e2e/dev/user.clj

@@ -65,5 +65,9 @@
     (w/wait-for (first (util/get-edit-block-container))
                 {:state :detached}))
 
+  (run-tests 'logseq.e2e.editor-test
+             'logseq.e2e.multi-tabs-test
+             'logseq.e2e.outliner-test
+             'logseq.e2e.rtc-basic-test)
   ;;
   )

+ 22 - 0
clj-e2e/src/logseq/e2e/assert.clj

@@ -0,0 +1,22 @@
+(ns logseq.e2e.assert
+  (:import [com.microsoft.playwright.assertions PlaywrightAssertions])
+  (:require [wally.main :as w]))
+
+(def assert-that PlaywrightAssertions/assertThat)
+
+(defn assert-is-visible
+  [q]
+  (-> (w/-query q) assert-that .isVisible))
+
+(defn assert-is-hidden
+  [q]
+  (-> (w/-query q) assert-that .isHidden))
+
+(defn assert-in-normal-mode?
+  "- not editing mode
+  - no action bar
+  - no search(cmdk) modal"
+  []
+  (assert-is-hidden (w/get-by-label "editing block"))
+  (assert-is-hidden ".selection-action-bar")
+  (assert-is-visible "#search-button"))

+ 2 - 0
clj-e2e/src/logseq/e2e/playwright_page.clj

@@ -1,4 +1,5 @@
 (ns logseq.e2e.playwright-page
+  "operations on playwright pages."
   (:require [logseq.e2e.config :as config]
             [wally.main :as w]))
 
@@ -7,6 +8,7 @@
   (.pages pw-ctx))
 
 (defn open-pages
+  "Pages in same pw-ctx share cookies and storages"
   [pw-ctx n]
   (let [url (str "http://localhost:" @config/*port)]
     (dotimes [_i n]

+ 4 - 5
clj-e2e/src/logseq/e2e/util.clj

@@ -2,14 +2,11 @@
   (:refer-clojure :exclude [type])
   (:require [clojure.string :as string]
             [clojure.test :refer [is]]
+            [logseq.e2e.assert :as assert]
             [logseq.e2e.keyboard :as k]
             [wally.main :as w]
-            [wally.repl :as repl]
             [wally.selectors :as ws])
-  (:import [com.microsoft.playwright TimeoutError]
-           [com.microsoft.playwright.assertions PlaywrightAssertions]))
-
-(def assert-that PlaywrightAssertions/assertThat)
+  (:import [com.microsoft.playwright TimeoutError]))
 
 (defn wait-timeout
   [ms]
@@ -49,6 +46,7 @@
 (defn search
   [text]
   (double-esc)
+  (assert/assert-in-normal-mode?)
   (w/click :#search-button)
   (w/fill ".cp__cmdk-search-input" text))
 
@@ -131,6 +129,7 @@
 (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