|
|
@@ -15,12 +15,45 @@
|
|
|
[]
|
|
|
(util/search-and-click "Go to all graphs"))
|
|
|
|
|
|
+(def ^:private e2ee-password-modal ".e2ee-password-modal-content")
|
|
|
+(def ^:private e2ee-new-password-input (str e2ee-password-modal " input[placeholder=\"Enter password\"]"))
|
|
|
+(def ^:private e2ee-new-password-confirm-input (str e2ee-password-modal " input[placeholder=\"Enter password again\"]"))
|
|
|
+(def ^:private e2ee-password-input (str e2ee-password-modal " .ls-toggle-password-input input"))
|
|
|
+(def ^:private e2ee-password-submit (str e2ee-password-modal " button:text(\"Submit\")"))
|
|
|
+(def ^:private cloud-ready-indicator "button.cloud.on.idle")
|
|
|
+
|
|
|
(defn- input-e2ee-password
|
|
|
[]
|
|
|
- (w/wait-for "input[type=\"password\"]" {:timeout 20000})
|
|
|
- (w/click "input[type=\"password\"]")
|
|
|
- (util/input "e2etest")
|
|
|
- (w/click "button:text(\"Submit\")"))
|
|
|
+ (if (w/visible? e2ee-new-password-confirm-input)
|
|
|
+ (do
|
|
|
+ (w/click e2ee-new-password-input)
|
|
|
+ (util/input "e2etest")
|
|
|
+ (w/click e2ee-new-password-confirm-input)
|
|
|
+ (util/input "e2etest"))
|
|
|
+ (do
|
|
|
+ (w/click (.first (w/-query e2ee-password-input)))
|
|
|
+ (util/input "e2etest")))
|
|
|
+ (w/click e2ee-password-submit)
|
|
|
+ (w/wait-for-not-visible e2ee-password-modal))
|
|
|
+
|
|
|
+(defn- maybe-input-e2ee-password
|
|
|
+ []
|
|
|
+ ;; Password input prompt is optional for accounts with already initialized keys/password.
|
|
|
+ (loop [remaining-ms 20000]
|
|
|
+ (cond
|
|
|
+ (w/visible? e2ee-password-modal)
|
|
|
+ (input-e2ee-password)
|
|
|
+
|
|
|
+ (w/visible? cloud-ready-indicator)
|
|
|
+ nil
|
|
|
+
|
|
|
+ (<= remaining-ms 0)
|
|
|
+ nil
|
|
|
+
|
|
|
+ :else
|
|
|
+ (do
|
|
|
+ (util/wait-timeout 250)
|
|
|
+ (recur (- remaining-ms 250))))))
|
|
|
|
|
|
(defn- new-graph-helper
|
|
|
[graph-name enable-sync?]
|
|
|
@@ -30,10 +63,14 @@
|
|
|
(util/input graph-name)
|
|
|
(when enable-sync?
|
|
|
(w/wait-for "button#rtc-sync" {:timeout 3000})
|
|
|
- (w/click "button#rtc-sync")
|
|
|
- (input-e2ee-password)
|
|
|
- (w/wait-for "button.cloud.on.idle" {:timeout 20000}))
|
|
|
+ (w/click "button#rtc-sync"))
|
|
|
+
|
|
|
(w/click "button:not([disabled]):text(\"Submit\")")
|
|
|
+
|
|
|
+ (when enable-sync?
|
|
|
+ (maybe-input-e2ee-password)
|
|
|
+ (w/wait-for cloud-ready-indicator {:timeout 20000}))
|
|
|
+
|
|
|
;; new graph can blocks the ui because the db need to be created and restored,
|
|
|
;; I have no idea why `search-and-click` failed to auto-wait sometimes.
|
|
|
(util/wait-timeout 1000))
|
|
|
@@ -81,8 +118,8 @@
|
|
|
(goto-all-graphs)
|
|
|
(w/click (.last (w/-query (format "div[data-testid='logseq_db_%1$s'] span:has-text('%1$s')" to-graph-name))))
|
|
|
(when wait-sync?
|
|
|
- (when need-input-password? (input-e2ee-password))
|
|
|
- (w/wait-for "button.cloud.on.idle" {:timeout 20000}))
|
|
|
+ (when need-input-password? (maybe-input-e2ee-password))
|
|
|
+ (w/wait-for cloud-ready-indicator {:timeout 20000}))
|
|
|
(assert/assert-graph-loaded?))
|
|
|
|
|
|
(defn validate-graph
|