mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Merge branch 'master' into refactor/page-parent
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
[logseq.e2e.fixtures :as fixtures]
|
||||
[logseq.e2e.graph :as graph]
|
||||
[logseq.e2e.keyboard :as k]
|
||||
[logseq.e2e.locator :as loc]
|
||||
[logseq.e2e.multi-tabs-basic-test]
|
||||
[logseq.e2e.outliner-basic-test]
|
||||
[logseq.e2e.plugins-basic-test]
|
||||
[logseq.e2e.property-basic-test]
|
||||
[logseq.e2e.reference-basic-test]
|
||||
[logseq.e2e.rtc-basic-test]
|
||||
[logseq.e2e.rtc-extra-test]
|
||||
@@ -21,7 +23,7 @@
|
||||
(reset! config/*port 3001)
|
||||
;; show ui
|
||||
(reset! config/*headless false)
|
||||
(reset! config/*slow-mo 50)
|
||||
(reset! config/*slow-mo 30)
|
||||
|
||||
(def *futures (atom {}))
|
||||
|
||||
@@ -35,6 +37,11 @@
|
||||
(->> (future (run-tests 'logseq.e2e.commands-basic-test))
|
||||
(swap! *futures assoc :commands-test)))
|
||||
|
||||
(defn run-property-basic-test
|
||||
[]
|
||||
(->> (future (run-tests 'logseq.e2e.property-basic-test))
|
||||
(swap! *futures assoc :property-test)))
|
||||
|
||||
(defn run-outliner-test
|
||||
[]
|
||||
(->> (future (run-tests 'logseq.e2e.outliner-basic-test))
|
||||
@@ -72,7 +79,8 @@
|
||||
'logseq.e2e.outliner-basic-test
|
||||
'logseq.e2e.rtc-basic-test
|
||||
'logseq.e2e.plugins-basic-test
|
||||
'logseq.e2e.reference-basic-test))
|
||||
'logseq.e2e.reference-basic-test
|
||||
'logseq.e2e.property-basic-test))
|
||||
|
||||
(defn start
|
||||
[]
|
||||
|
||||
@@ -40,10 +40,7 @@
|
||||
|
||||
(defn assert-editor-mode
|
||||
[]
|
||||
(let [klass ".editor-wrapper textarea"
|
||||
editor (w/-query klass)]
|
||||
(w/wait-for editor)
|
||||
editor))
|
||||
(assert-have-count ".editor-wrapper textarea" 1))
|
||||
|
||||
(defn assert-selected-block-text
|
||||
[text]
|
||||
|
||||
@@ -8,27 +8,38 @@
|
||||
[wally.main :as w]))
|
||||
|
||||
(defn open-last-block
|
||||
"Open the last existing block or pressing add button to create a new block"
|
||||
[]
|
||||
(util/double-esc)
|
||||
(assert/assert-in-normal-mode?)
|
||||
(w/click (last (w/query ".ls-page-blocks .ls-block .block-content"))))
|
||||
(let [blocks-count (util/page-blocks-count)
|
||||
last-block (-> (if (zero? blocks-count)
|
||||
(w/query ".ls-page-blocks .block-add-button")
|
||||
(w/query ".ls-page-blocks .page-blocks-inner .ls-block .block-content"))
|
||||
(last))]
|
||||
(w/click last-block)))
|
||||
|
||||
(defn save-block
|
||||
[text]
|
||||
(assert/assert-have-count util/editor-q 1)
|
||||
(w/click util/editor-q)
|
||||
(w/fill util/editor-q text)
|
||||
(assert/assert-is-visible (loc/filter util/editor-q :has-text text)))
|
||||
|
||||
(defn new-block
|
||||
[title]
|
||||
(let [editor (util/get-editor)
|
||||
blocks-count (util/blocks-count)]
|
||||
(let [editor (util/get-editor)]
|
||||
(when-not editor (open-last-block))
|
||||
(assert/assert-editor-mode)
|
||||
(k/enter)
|
||||
(assert/assert-have-count ".ls-block" (inc blocks-count))
|
||||
(assert/assert-editor-mode)
|
||||
(save-block title)))
|
||||
(let [last-id (.getAttribute (w/-query ".editor-wrapper textarea") "id")]
|
||||
(is (some? last-id))
|
||||
(k/enter)
|
||||
(assert/assert-is-visible
|
||||
(loc/filter ".editor-wrapper"
|
||||
:has "textarea"
|
||||
:has-not (str "#" last-id)))
|
||||
(assert/assert-editor-mode)
|
||||
(save-block title))))
|
||||
|
||||
;; TODO: support tree
|
||||
(defn new-blocks
|
||||
@@ -37,7 +48,7 @@
|
||||
(when-not editor? (open-last-block))
|
||||
(assert/assert-editor-mode)
|
||||
(let [value (util/get-edit-content)]
|
||||
(if (string/blank? value) ; empty block
|
||||
(if (string/blank? value) ; empty block
|
||||
(save-block (first titles))
|
||||
(new-block (first titles))))
|
||||
(doseq [title (rest titles)]
|
||||
@@ -62,6 +73,7 @@
|
||||
|
||||
(defn wait-editor-text
|
||||
[text]
|
||||
(assert/assert-have-count util/editor-q 1)
|
||||
(w/wait-for (format ".editor-wrapper textarea:text('%s')" text)))
|
||||
|
||||
(def copy #(k/press "ControlOrMeta+c" {:delay 100}))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
(ns logseq.e2e.keyboard
|
||||
(:require [wally.main :as w]))
|
||||
|
||||
(def ^:private mac? (= "Mac OS X" (System/getProperty "os.name")))
|
||||
|
||||
(def press w/keyboard-press)
|
||||
|
||||
(def enter #(press "Enter"))
|
||||
@@ -9,5 +11,11 @@
|
||||
(def tab #(press "Tab"))
|
||||
(def shift+tab #(press "Shift+Tab"))
|
||||
(def shift+enter #(press "Shift+Enter"))
|
||||
(def shift+arrow-up #(press "Shift+ArrowUp"))
|
||||
(def shift+arrow-down #(press "Shift+ArrowDown"))
|
||||
|
||||
(def arrow-up #(press "ArrowUp"))
|
||||
(def arrow-down #(press "ArrowDown"))
|
||||
|
||||
(def meta+shift+arrow-up #(press (str (if mac? "Meta" "Alt") "+Shift+ArrowUp")))
|
||||
(def meta+shift+arrow-down #(press (str (if mac? "Meta" "Alt") "+Shift+ArrowDown")))
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
(ns logseq.e2e.page
|
||||
(:require [logseq.e2e.assert :as assert]
|
||||
(:require [logseq.e2e.keyboard :as k]
|
||||
[logseq.e2e.util :as util]
|
||||
[wally.main :as w]
|
||||
[wally.selectors :as ws]))
|
||||
[wally.selectors :as ws])
|
||||
(:import (com.microsoft.playwright TimeoutError)))
|
||||
|
||||
(defn goto-page
|
||||
[page-name]
|
||||
(assert (string? page-name) page-name)
|
||||
(util/search-and-click page-name))
|
||||
(try
|
||||
(util/search-and-click page-name)
|
||||
(catch TimeoutError _e
|
||||
;; try one more time
|
||||
(k/esc)
|
||||
(util/search-and-click page-name))))
|
||||
|
||||
(defn new-page
|
||||
[title]
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
~@body
|
||||
(loop [i# 5]
|
||||
(when (zero? i#) (throw (ex-info "wait-tx-updated failed" {:old m# :new (get-rtc-tx)})))
|
||||
(util/wait-timeout 500)
|
||||
(w/wait-for "button.cloud.on.idle")
|
||||
(util/wait-timeout 1000)
|
||||
(let [new-m# (get-rtc-tx)
|
||||
new-local-tx# (or (:local-tx new-m#) 0)
|
||||
@@ -52,3 +54,21 @@
|
||||
(defn rtc-stop
|
||||
[]
|
||||
(util/search-and-click "(Dev) RTC Stop"))
|
||||
|
||||
(defmacro with-stop-restart-rtc
|
||||
"- rtc stop on `stop-pw-pages` in order
|
||||
- run `body`
|
||||
- rtc start and exec `after-start-body` in order"
|
||||
[stop-pw-pages start-pw-page+after-start-body & body]
|
||||
(let [after-body
|
||||
(cons
|
||||
'do
|
||||
(for [[p body] (partition 2 start-pw-page+after-start-body)]
|
||||
`(w/with-page ~p
|
||||
(rtc-start)
|
||||
~body)))]
|
||||
`(do
|
||||
(doseq [p# ~stop-pw-pages]
|
||||
(w/with-page p# (rtc-stop)))
|
||||
~@body
|
||||
~after-body)))
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
|
||||
(defn get-edit-block-container
|
||||
[]
|
||||
(first (w/query ".ls-block" {:has (w/-query ".editor-wrapper textarea")})))
|
||||
(assert/assert-have-count editor-q 1)
|
||||
(first (w/query ".ls-block" {:has (w/-query editor-q)})))
|
||||
|
||||
(defn input
|
||||
"Notice this will replace the existing input value with `text`"
|
||||
@@ -97,11 +98,11 @@
|
||||
(defn blocks-count
|
||||
"Blocks count including page title"
|
||||
[]
|
||||
(count-elements ".ls-block"))
|
||||
(count-elements ".ls-block:not(.block-add-button)"))
|
||||
|
||||
(defn page-blocks-count
|
||||
[]
|
||||
(count-elements ".ls-page-blocks .ls-block"))
|
||||
(count-elements ".ls-page-blocks .page-blocks-inner .ls-block"))
|
||||
|
||||
(defn exit-edit
|
||||
[]
|
||||
@@ -131,7 +132,7 @@
|
||||
|
||||
(defn get-page-blocks-contents
|
||||
[]
|
||||
(w/all-text-contents ".ls-page-blocks .ls-block .block-title-wrap"))
|
||||
(w/all-text-contents ".ls-page-blocks .ls-block:not(.block-add-button) .block-title-wrap"))
|
||||
|
||||
(def mac? (= "Mac OS X" (System/getProperty "os.name")))
|
||||
|
||||
@@ -183,7 +184,7 @@
|
||||
(w/click (first (w/query (format "a.menu-link:has-text(\"%s\")" tag))))
|
||||
;; wait tag added on ui
|
||||
(assert/assert-is-visible
|
||||
(-> ".ls-block"
|
||||
(-> ".ls-block:not(.block-add-button)"
|
||||
(loc/filter :has ".editor-wrapper textarea")
|
||||
(loc/filter :has (format ".block-tag :text('%s')" tag)))))
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
(ns logseq.e2e.commands-basic-test
|
||||
(:require
|
||||
[clj-time.core :as t]
|
||||
[clj-time.local :as tl]
|
||||
[clojure.string :as string]
|
||||
[clojure.test :refer [deftest testing is use-fixtures]]
|
||||
[logseq.e2e.assert :as assert]
|
||||
@@ -297,12 +295,3 @@
|
||||
(util/exit-edit)
|
||||
(w/click "a.cloze")
|
||||
(w/wait-for "a.cloze-revealed")))
|
||||
|
||||
(deftest new-property-test
|
||||
(testing "new property"
|
||||
(b/new-block "")
|
||||
(util/input-command "add new property")
|
||||
(util/input "p1")
|
||||
(w/click "a:has-text(\"+ New option: p1\")")
|
||||
(k/enter)
|
||||
(is (= "p1" (util/get-text "a.property-k")))))
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
(def ^:dynamic *pw-page->console-logs* nil)
|
||||
|
||||
(def ^:dynamic *preserve-graph* nil)
|
||||
|
||||
(defn screenshot
|
||||
[page test-name]
|
||||
(println :screenshot test-name)
|
||||
@@ -22,6 +24,22 @@
|
||||
(.setPath (java.nio.file.Paths/get "e2e-dump/"
|
||||
(into-array [(format "./screenshot-%s-%s.png" test-name (System/currentTimeMillis))]))))))
|
||||
|
||||
(defn- collect-info-when-error-or-failed
|
||||
[]
|
||||
;; screenshot for all pw pages when :error
|
||||
(when-let [all-contexts (seq *pw-contexts*)]
|
||||
(doseq [page (mapcat pw-page/get-pages all-contexts)]
|
||||
(screenshot page (string/join "-" (map (comp str :name meta) t/*testing-vars*)))))
|
||||
|
||||
;; dump console logs
|
||||
(when-let [pw-page->console-logs (some-> *pw-page->console-logs* deref)]
|
||||
(doseq [[_pw-page logs] pw-page->console-logs]
|
||||
(spit (format "e2e-dump/console-logs-%s.txt" (System/currentTimeMillis))
|
||||
(with-out-str (pp/pprint logs)))))
|
||||
|
||||
(when (some? *preserve-graph*)
|
||||
(set! *preserve-graph* true)))
|
||||
|
||||
(defmethod t/report :error
|
||||
[m]
|
||||
;; copy from default impl
|
||||
@@ -37,16 +55,7 @@
|
||||
(stack/print-cause-trace actual t/*stack-trace-depth*)
|
||||
(prn actual))))
|
||||
|
||||
;; screenshot for all pw pages when :error
|
||||
(when-let [all-contexts (seq *pw-contexts*)]
|
||||
(doseq [page (mapcat pw-page/get-pages all-contexts)]
|
||||
(screenshot page (string/join "-" (map (comp str :name meta) t/*testing-vars*)))))
|
||||
|
||||
;; dump console logs
|
||||
(when-let [pw-page->console-logs (some-> *pw-page->console-logs* deref)]
|
||||
(doseq [[_pw-page logs] pw-page->console-logs]
|
||||
(spit (format "e2e-dump/console-logs-%s.txt" (System/currentTimeMillis))
|
||||
(with-out-str (pp/pprint logs))))))
|
||||
(collect-info-when-error-or-failed))
|
||||
|
||||
(defmethod t/report :fail
|
||||
[m]
|
||||
@@ -58,13 +67,4 @@
|
||||
(println "expected:" (pr-str (:expected m)))
|
||||
(println " actual:" (pr-str (:actual m))))
|
||||
|
||||
;; screenshot for all pw pages when :fail
|
||||
(when-let [all-contexts (seq *pw-contexts*)]
|
||||
(doseq [page (mapcat pw-page/get-pages all-contexts)]
|
||||
(screenshot page (string/join "-" (map (comp str :name meta) t/*testing-vars*)))))
|
||||
|
||||
;; dump console logs
|
||||
(when-let [pw-page->console-logs (some-> *pw-page->console-logs* deref)]
|
||||
(doseq [[_pw-page logs] pw-page->console-logs]
|
||||
(spit (format "e2e-dump/console-logs-%s.txt" (System/currentTimeMillis))
|
||||
(with-out-str (pp/pprint logs))))))
|
||||
(collect-info-when-error-or-failed))
|
||||
|
||||
52
clj-e2e/test/logseq/e2e/property_basic_test.clj
Normal file
52
clj-e2e/test/logseq/e2e/property_basic_test.clj
Normal file
@@ -0,0 +1,52 @@
|
||||
(ns logseq.e2e.property-basic-test
|
||||
(:require [clojure.test :refer [deftest testing is use-fixtures run-test run-tests]]
|
||||
[logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.block :as b]
|
||||
[logseq.e2e.fixtures :as fixtures]
|
||||
[logseq.e2e.keyboard :as k]
|
||||
[logseq.e2e.locator :as loc]
|
||||
[logseq.e2e.util :as util]
|
||||
[wally.main :as w]))
|
||||
|
||||
(use-fixtures :once fixtures/open-page)
|
||||
|
||||
(use-fixtures :each
|
||||
fixtures/new-logseq-page
|
||||
fixtures/validate-graph)
|
||||
|
||||
(def ^:private property-types ["Text" "Number" "Date" "DateTime" "Checkbox" "Url" "Node"])
|
||||
|
||||
(defn add-new-properties
|
||||
[title-prefix]
|
||||
(b/new-blocks (map #(str title-prefix "-" %) property-types))
|
||||
(doseq [property-type property-types]
|
||||
(let [property-name (str "p-" title-prefix "-" property-type)]
|
||||
(w/click (util/get-by-text (str title-prefix "-" property-type) true))
|
||||
(k/press "Control+e")
|
||||
(util/input-command "Add new property")
|
||||
(w/click "input[placeholder]")
|
||||
(util/input property-name)
|
||||
(w/click (util/get-by-text "New option:" false))
|
||||
(assert/assert-is-visible (w/get-by-text "Select a property type"))
|
||||
(w/click (loc/and "span" (util/get-by-text property-type true)))
|
||||
(case property-type
|
||||
"Text" (do
|
||||
(w/click (format ".property-pair:has-text('%s') > .ls-block" property-name))
|
||||
(util/input "Text"))
|
||||
"Number" (do (assert/assert-is-visible (format "input[placeholder='%s']" (str "Set " property-name)))
|
||||
(util/input "111")
|
||||
(w/click (w/get-by-text "New option:")))
|
||||
("DateTime" "Date") (do
|
||||
(assert/assert-is-visible ".ls-property-dialog")
|
||||
(k/enter)
|
||||
(k/esc))
|
||||
"Checkbox" nil
|
||||
"Url" nil
|
||||
"Node" (do
|
||||
(w/click (w/get-by-text "Skip choosing tag"))
|
||||
(util/input (str title-prefix "-Node-value"))
|
||||
(w/click (w/get-by-text "New option:")))))))
|
||||
|
||||
(deftest new-property-test
|
||||
(let [title-prefix "new-property-test"]
|
||||
(add-new-properties title-prefix)))
|
||||
@@ -1,20 +1,21 @@
|
||||
(ns logseq.e2e.rtc-extra-test
|
||||
(:require
|
||||
[clojure.test :refer [deftest testing is use-fixtures run-test]]
|
||||
[clojure.test :refer [deftest testing is use-fixtures run-test run-tests]]
|
||||
[com.climate.claypoole :as cp]
|
||||
[logseq.e2e.assert :as assert]
|
||||
[logseq.e2e.block :as b]
|
||||
[logseq.e2e.custom-report :as custom-report]
|
||||
[logseq.e2e.fixtures :as fixtures :refer [*page1 *page2]]
|
||||
[logseq.e2e.graph :as graph]
|
||||
[logseq.e2e.keyboard :as k]
|
||||
[logseq.e2e.locator :as loc]
|
||||
[logseq.e2e.outliner-basic-test :as outliner-basic-test]
|
||||
[logseq.e2e.page :as page]
|
||||
[logseq.e2e.property-basic-test :as property-basic-test]
|
||||
[logseq.e2e.rtc :as rtc]
|
||||
[logseq.e2e.settings :as settings]
|
||||
[logseq.e2e.util :as util]
|
||||
[wally.main :as w]
|
||||
[wally.repl :as repl]))
|
||||
[wally.main :as w]))
|
||||
|
||||
(defn- prepare-rtc-graph-fixture
|
||||
"open 2 app instances, add a rtc graph, check this graph available on other instance"
|
||||
@@ -33,11 +34,13 @@
|
||||
(graph/wait-for-remote-graph graph-name)
|
||||
(graph/switch-graph graph-name true))
|
||||
|
||||
(f)
|
||||
|
||||
;; cleanup
|
||||
(w/with-page @*page2
|
||||
(graph/remove-remote-graph graph-name))))
|
||||
(binding [custom-report/*preserve-graph* false]
|
||||
(f)
|
||||
;; cleanup
|
||||
(if custom-report/*preserve-graph*
|
||||
(println "Don't remove graph: " graph-name)
|
||||
(w/with-page @*page2
|
||||
(graph/remove-remote-graph graph-name))))))
|
||||
|
||||
(defn- new-logseq-page
|
||||
"new logseq page and switch to this page on both page1 and page2"
|
||||
@@ -81,9 +84,19 @@
|
||||
[@*page1 @*page2])]
|
||||
(assert/assert-graph-summary-equal p1-summary p2-summary)))
|
||||
|
||||
(def status->icon-name
|
||||
{"Backlog" "Backlog"
|
||||
"Todo" "Todo"
|
||||
"Doing" "InProgress50"
|
||||
"In review" "InReview"
|
||||
"Done" "Done"
|
||||
"Canceled" "Cancelled"})
|
||||
|
||||
(def priorities ["No priority" "Low" "Medium" "High" "Urgent"])
|
||||
|
||||
(defn- validate-task-blocks
|
||||
[]
|
||||
(let [icon-names ["Backlog" "Todo" "InProgress50" "InReview" "Done" "Cancelled"]
|
||||
(let [icon-names (vals status->icon-name)
|
||||
icon-name->count
|
||||
(w/with-page @*page2
|
||||
(into
|
||||
@@ -99,14 +112,20 @@
|
||||
|
||||
(defn- insert-task-blocks
|
||||
[title-prefix]
|
||||
(doseq [status ["Backlog" "Todo" "Doing" "In review" "Done" "Canceled"]
|
||||
priority ["No priority" "Low" "Medium" "High" "Urgent"]]
|
||||
(doseq [status (keys status->icon-name)
|
||||
priority priorities]
|
||||
(b/new-block (str title-prefix "-" status "-" priority))
|
||||
(util/input-command status)
|
||||
(util/input-command priority)))
|
||||
|
||||
(defn- update-task-blocks
|
||||
[])
|
||||
[]
|
||||
(let [qs-partitions (partition-all 5 (seq (.all (loc/filter ".ls-block" :has ".ui__icon"))))]
|
||||
(doseq [q-seq qs-partitions]
|
||||
(doseq [q q-seq]
|
||||
(w/click q)
|
||||
(util/input-command (rand-nth (keys status->icon-name)))
|
||||
(util/input-command (rand-nth priorities))))))
|
||||
|
||||
(deftest rtc-task-blocks-test
|
||||
(let [insert-task-blocks-in-page2
|
||||
@@ -116,13 +135,29 @@
|
||||
(rtc/with-wait-tx-updated
|
||||
(insert-task-blocks "t1"))]
|
||||
(reset! *latest-remote-tx remote-tx))
|
||||
;; TODO: more operations
|
||||
(util/exit-edit)))]
|
||||
(testing "rtc-stop app1, add some task blocks, then rtc-start on app1"
|
||||
(util/exit-edit)))
|
||||
update-task-blocks-in-page2
|
||||
(fn [*latest-remote-tx]
|
||||
(w/with-page @*page2
|
||||
(let [{:keys [_local-tx remote-tx]}
|
||||
(rtc/with-wait-tx-updated
|
||||
(update-task-blocks))]
|
||||
(reset! *latest-remote-tx remote-tx))))]
|
||||
(testing "add some task blocks while rtc disconnected on page1"
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(with-stop-restart-rtc @*page1 #(insert-task-blocks-in-page2 *latest-remote-tx))
|
||||
(w/with-page @*page1
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1]
|
||||
[@*page1 (rtc/wait-tx-update-to @*latest-remote-tx)]
|
||||
(insert-task-blocks-in-page2 *latest-remote-tx))
|
||||
(validate-task-blocks)
|
||||
(validate-2-graphs)))
|
||||
|
||||
(testing "update task blocks while rtc disconnected on page1"
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1]
|
||||
[@*page1 (rtc/wait-tx-update-to @*latest-remote-tx)]
|
||||
(update-task-blocks-in-page2 *latest-remote-tx))
|
||||
(validate-task-blocks)
|
||||
(validate-2-graphs)))
|
||||
|
||||
@@ -134,35 +169,15 @@
|
||||
(w/with-page @*page1
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(validate-task-blocks)
|
||||
(validate-2-graphs)))))
|
||||
(validate-2-graphs)))
|
||||
|
||||
(defn- add-new-properties
|
||||
[title-prefix]
|
||||
(b/new-blocks (map #(str title-prefix "-" %) ["Text" "Number" "Date" "DateTime" "Checkbox" "Url" "Node"]))
|
||||
(doseq [property-type ["Text" "Number" "Date" "DateTime" "Checkbox" "Url" "Node"]]
|
||||
(let [property-name (str "p-" title-prefix "-" property-type)]
|
||||
(w/click (util/get-by-text (str title-prefix "-" property-type) true))
|
||||
(k/press "Control+e")
|
||||
(util/input-command "Add new property")
|
||||
(util/input property-name)
|
||||
(w/click (w/get-by-text "New option:"))
|
||||
(assert/assert-is-visible (w/get-by-text "Select a property type"))
|
||||
(w/click (loc/and "span" (util/get-by-text property-type true)))
|
||||
(case property-type
|
||||
"Text" (util/input "Text")
|
||||
"Number" (do (assert/assert-is-visible (format "input[placeholder='%s']" (str "Set " property-name)))
|
||||
(util/input "111")
|
||||
(w/click (w/get-by-text "New option:")))
|
||||
("DateTime" "Date") (do
|
||||
(assert/assert-is-visible ".ls-property-dialog")
|
||||
(k/enter)
|
||||
(k/esc))
|
||||
"Checkbox" nil
|
||||
"Url" nil
|
||||
"Node" (do
|
||||
(w/click (w/get-by-text "Skip choosing tag"))
|
||||
(util/input (str title-prefix "-Node-value"))
|
||||
(w/click (w/get-by-text "New option:")))))))
|
||||
(testing "update task blocks while rtc connected on page1"
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(update-task-blocks-in-page2 *latest-remote-tx)
|
||||
(w/with-page @*page1
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(validate-task-blocks)
|
||||
(validate-2-graphs)))))
|
||||
|
||||
(deftest rtc-property-test
|
||||
(let [insert-new-property-blocks-in-page2
|
||||
@@ -170,15 +185,14 @@
|
||||
(w/with-page @*page2
|
||||
(let [{:keys [_local-tx remote-tx]}
|
||||
(rtc/with-wait-tx-updated
|
||||
(add-new-properties title-prefix))]
|
||||
(property-basic-test/add-new-properties title-prefix))]
|
||||
(reset! *latest-remote-tx remote-tx))))]
|
||||
(testing "page1: rtc-stop
|
||||
page2: create some user properties with different type
|
||||
page1: rtc-start"
|
||||
(testing "add different types user properties on page2 while keeping rtc connected on page1"
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(with-stop-restart-rtc @*page1 #(insert-new-property-blocks-in-page2 *latest-remote-tx "rtc-property-test-1"))
|
||||
(w/with-page @*page1
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1]
|
||||
[@*page1 (rtc/wait-tx-update-to @*latest-remote-tx)]
|
||||
(insert-new-property-blocks-in-page2 *latest-remote-tx "rtc-property-test-1"))
|
||||
(validate-2-graphs)))
|
||||
|
||||
(new-logseq-page)
|
||||
@@ -201,26 +215,74 @@ page1: rtc-start"
|
||||
(let [{:keys [_local-tx remote-tx]}
|
||||
(rtc/with-wait-tx-updated
|
||||
(test-fn))]
|
||||
(reset! *latest-remote-tx remote-tx))))]
|
||||
(reset! *latest-remote-tx remote-tx))))
|
||||
*latest-remote-tx (atom nil)]
|
||||
(new-logseq-page)
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1]
|
||||
[@*page1 (rtc/wait-tx-update-to @*latest-remote-tx)]
|
||||
(test-fn-in-page2 *latest-remote-tx))
|
||||
(validate-2-graphs))))
|
||||
|
||||
;; testing while rtc connected
|
||||
(deftest rtc-outliner-conflict-update-test
|
||||
(let [title-prefix "rtc-outliner-conflict-update-test"]
|
||||
(testing "add some blocks, ensure them synced"
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(new-logseq-page)
|
||||
(test-fn-in-page2 *latest-remote-tx)
|
||||
(w/with-page @*page1
|
||||
(let [{:keys [_local-tx remote-tx]}
|
||||
(rtc/with-wait-tx-updated
|
||||
(b/new-blocks (map #(str title-prefix "-" %) (range 10))))]
|
||||
(reset! *latest-remote-tx remote-tx)))
|
||||
(w/with-page @*page2
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(validate-2-graphs))
|
||||
|
||||
;; testing while rtc off then on
|
||||
(let [*latest-remote-tx (atom nil)]
|
||||
(new-logseq-page)
|
||||
(with-stop-restart-rtc @*page1 #(test-fn-in-page2 *latest-remote-tx))
|
||||
(validate-2-graphs)))
|
||||
(testing "page1: indent block1 as child of block0, page2: delete block0"
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1 @*page2]
|
||||
[@*page1 (rtc/with-wait-tx-updated
|
||||
(k/esc)
|
||||
(assert/assert-in-normal-mode?)
|
||||
(b/new-block "page1-done-1"))
|
||||
@*page2 (rtc/with-wait-tx-updated
|
||||
(k/esc)
|
||||
(assert/assert-in-normal-mode?)
|
||||
(b/new-block "page2-done-1"))]
|
||||
(w/with-page @*page1
|
||||
(rtc/wait-tx-update-to @*latest-remote-tx))
|
||||
(validate-2-graphs)))))
|
||||
|
||||
(comment
|
||||
(let [title-prefix "xxxx"
|
||||
property-type "Text"]
|
||||
(w/with-page @*page1
|
||||
(b/new-block (str title-prefix "-" property-type)))))
|
||||
(w/click (format ".ls-block :text('%s')" (str title-prefix "-" 1)))
|
||||
(b/indent))
|
||||
(w/with-page @*page2
|
||||
(w/click (format ".ls-block :text('%s')" (str title-prefix "-" 0)))
|
||||
(b/delete-blocks)))
|
||||
(validate-2-graphs))
|
||||
(testing "
|
||||
origin:
|
||||
- block2
|
||||
- block3
|
||||
- block4
|
||||
page1:
|
||||
- block2
|
||||
- block3
|
||||
- block4
|
||||
page2:
|
||||
;; block2 deleted
|
||||
- block4
|
||||
- block3"
|
||||
(rtc/with-stop-restart-rtc
|
||||
[@*page1 @*page2]
|
||||
[@*page1 (rtc/with-wait-tx-updated (b/new-block "page1-done-2"))
|
||||
@*page2 (rtc/with-wait-tx-updated (b/new-block "page2-done-2"))]
|
||||
(w/with-page @*page1
|
||||
(w/click (format ".ls-block :text('%s')" (str title-prefix "-" 3)))
|
||||
(b/indent)
|
||||
(k/arrow-down)
|
||||
(b/indent)
|
||||
(b/indent))
|
||||
(w/with-page @*page2
|
||||
(w/click (format ".ls-block :text('%s')" (str title-prefix "-" 2)))
|
||||
(b/delete-blocks)
|
||||
(w/click (format ".ls-block :text('%s')" (str title-prefix "-" 3)))
|
||||
(k/shift+arrow-down)
|
||||
(k/meta+shift+arrow-down)
|
||||
(k/enter)
|
||||
(b/indent)))
|
||||
(validate-2-graphs))))
|
||||
|
||||
Reference in New Issue
Block a user