Repository: CSCfi/rems
Pull request #3322 (2024-08-21 07:19:08)

Fix broken tests
Fixes issue with browser tests not passing:
- `open-collapsible` helper no longer uses class name in selector
- `add-form-field!` helper uses less explicit id management (again)

Other changes:
- removed unused refresh driver fixture (actually was removed already before, due to stability issues)
- added flag to disable chrome from asking default search (quite annoying when running non-headless)
- removed custom implementation of `fill-human` and replaced with etaoin.api/fill-human. tuning the algorithm was quite time consuming and it wouldn't prevent tests from flaking anyway
- added wait and extra selector path to dropdown select in `test-invite-reviewer` (perhaps flaky due too fast clicking)
- updated `etaoin` to latest, introduced some new API



Patch:
diff --git a/project.clj b/project.clj
index 68b4e00a9..d0bdd674f 100644
--- a/project.clj
+++ b/project.clj
@@ -118,7 +118,7 @@
                                 [criterium "0.4.6"]
                                 [lambdaisland/kaocha "1.91.1392"]
                                 [lambdaisland/kaocha-junit-xml "1.17.101"]
-                                [etaoin "1.0.40"]
+                                [etaoin "1.1.41"]
                                 [ring/ring-mock "0.4.0" :exclusions [cheshire]]
                                 [se.haleby/stub-http "0.2.14"]
                                 [com.icegreen/greenmail "1.6.15"]
diff --git a/src/cljs/rems/administration/create_form.cljs b/src/cljs/rems/administration/create_form.cljs
index a439c09a9..29f24cbf1 100644
--- a/src/cljs/rems/administration/create_form.cljs
+++ b/src/cljs/rems/administration/create_form.cljs
@@ -693,7 +693,7 @@
   (let [fields (indexed @(rf/subscribe [::fields]))
         field-count (count fields)]
     (into [:<>
-           [:div.new-form-field
+           [:div.new-form-field {:data-field-index 0}
             [add-form-field-button 0]]]
           (for [[idx field] fields]
             ^{:key (get-field-key field idx)}
@@ -701,7 +701,7 @@
              [:div.form-field {:data-field-id (:field/id field)
                                :data-field-index idx}
               [field-editor idx field field-count]]
-             [:div.new-form-field
+             [:div.new-form-field {:data-field-index (inc idx)}
               [add-form-field-button (inc idx)]]]))))
 
 (defn- render-preview-hidden []


Test patch:
diff --git a/test/clj/rems/browser_test_util.clj b/test/clj/rems/browser_test_util.clj
index a6e1127f9..1bcf2d503 100644
--- a/test/clj/rems/browser_test_util.clj
+++ b/test/clj/rems/browser_test_util.clj
@@ -96,7 +96,7 @@
 (defn- reset-window-size!
   "Sets window size big enough to show the whole page in the screenshots."
   [driver]
-  (et/set-window-size driver 1400 7000))
+  (et/set-window-rect driver {:width 1400 :height 7000}))
 
 (defn- init-session! [driver]
   (doto driver
@@ -104,7 +104,8 @@
     (reset-window-size!)))
 
 (def ^:private driver-defaults
-  {:args ["--lang=en-US"]
+  {:args ["--lang=en-US"
+          "--disable-search-engine-choice-screen"] ; https://stackoverflow.com/a/78800001
    :prefs {:intl.accept_languages "en-US"
            :download.directory_upgrade true
            :safebrowsing.enabled false
@@ -145,21 +146,6 @@
          :mode mode
          :seed (random-seed)))
 
-(defn- recreate-session! [driver]
-  (et/delete-session driver)
-  (let [driver (dissoc driver :session)
-        session (et/create-session driver)]
-    (assoc driver :session session)))
-
-(defn refresh-driver!
-  "Re-creates session on an existing driver and sets default values."
-  []
-  (assert (get-driver) "must have initialized driver already!")
-  (et/with-wait-timeout 60
-    (-> (get-driver)
-        recreate-session!
-        init-session!)))
-
 (defn init-driver-fixture
   "Executes a test running a fresh driver except when in development."
   [f]
@@ -173,21 +159,6 @@
         (log/warn e "WebDriver failed to start, retrying...")
         (run)))))
 
-(defn refresh-driver-fixture
-  "Executes a test running with a re-used but clean and refreshed driver."
-  [f]
-  (try
-    (refresh-driver!)
-    (f)
-    (catch clojure.lang.ExceptionInfo e
-      ;; could need a restart
-      (let [data (ex-data e)]
-        (if (= "invalid session id" (get-in data [:response :value :error]))
-          (do
-            (log/warn e "Unexpected problem, need to restart driver" data)
-            (init-driver-fixture f))
-          (throw e))))))
-
 (defn reset-context-fixture [f]
   (reset-context!)
   (f))
@@ -355,7 +326,7 @@
         full-filename (str (get-file-base) filename ".png")
         file (io/file (:reporting-dir @test-context) full-filename)
 
-        window-size (et/get-window-size driver)
+        window-size (et/get-window-rect driver)
         empty-space (if (et/exists? driver :empty-space) ; if page has not rendered, screenshot can fail due to missing element
                       (parse-int (et/get-element-attr driver :empty-space "clientHeight"))
                       0)
@@ -368,14 +339,14 @@
 
     ;; adjust window to correct size
     (when need-to-adjust?
-      (et/set-window-size driver {:width (:width window-size)
+      (et/set-window-rect driver {:width (:width window-size)
                                   :height without-extra-height}))
 
     (et/screenshot driver file)
 
     ;; restore (big) size
     (when need-to-adjust?
-      (et/set-window-size driver window-size))))
+      (et/set-window-rect driver window-size))))
 
 (defn screenshot-element [filename q]
   (let [full-filename (format "%03d-%s-%s"
@@ -414,7 +385,7 @@
 (defn wrap-etaoin [f]
   (fn [& args] (apply f (get-driver) args)))
 
-(def set-window-size (wrap-etaoin et/set-window-size))
+(def set-window-rect (wrap-etaoin et/set-window-rect))
 (def go (wrap-etaoin et/go))
 (def wait-visible (wrap-etaoin et/wait-visible))
 (def wait-invisible (wrap-etaoin et/wait-invisible))
@@ -476,41 +447,10 @@
   (wait-for-idle)
   (no-timeout? #(apply wait-invisible args)))
 
-;; TODO our input fields process every character through re-frame.
-;; Etaoin's fill-human almost works, but very rarely loses characters,
-;; probably due to the lack of a _minimum_ delay between keypresses.
-;; This is a reimplementation.
-(def +character-delay+ 0.01)
-(def +typo-probability+ 0.05)
-(def +typoable-chars+
-  (clojure.set/union (set "0123456789")
-                     (set "abcdefghijklmnopqrstuvwxyzåäö")
-                     (set "ABCDEFGHIJKLMONPQRSTUVWXYZÅÄÖ")))
-
-(defn- wait-delay-and-idle [seconds]
-  (et/wait seconds) ; minimum wait
-  (wait-for-idle)) ; extra wait, in case browser is in middle of something
-
 (defn fill-human [q text]
   (wait-for-idle)
-  (wait-visible q)
-
-  (doseq [c text
-          :let [elem (query q)]]
-    (et/wait (* 0.05 (rand))) ; max 50ms
-    (when (and (contains? +typoable-chars+ c)
-               (< (rand) +typo-probability+))
-      (fill-el elem (char (inc (int c))))
-      (wait-delay-and-idle +character-delay+)
-      (fill-el elem etaoin.keys/backspace)
-      (wait-delay-and-idle +character-delay+))
-    (fill-el elem c))
-
-  (wait-delay-and-idle 0.1)
-
-  (let [value (get-element-attr q "value")]
-    (when (not= text value)
-      (log/warn "Failed to fill field" (pr-str {:expected text :actual value})))))
+  (et/fill-human (get-driver) q text {:pause-max 0.03
+                                      :mistake-prob 0.05}))
 
 (defn visible-el?
   "Checks whether an element is visible on the page."
diff --git a/test/clj/rems/service/test_catalogue.clj b/test/clj/rems/service/test_catalogue.clj
index 10c0461fc..fe573514c 100644
--- a/test/clj/rems/service/test_catalogue.clj
+++ b/test/clj/rems/service/test_catalogue.clj
@@ -14,10 +14,12 @@
 
 (use-fixtures
   :once
-  test-db-fixture
-  reset-caches-fixture)
+  test-db-fixture)
 
-(use-fixtures :each rollback-db-fixture)
+(use-fixtures
+  :each
+  reset-caches-fixture
+  rollback-db-fixture)
 
 (defn- status-flags [item-id]
   (-> (catalogue/get-localized-catalogue-item item-id)
diff --git a/test/clj/rems/test_browser.clj b/test/clj/rems/test_browser.clj
index 083e505ef..10188db76 100644
--- a/test/clj/rems/test_browser.clj
+++ b/test/clj/rems/test_browser.clj
@@ -147,16 +147,18 @@
        (finally
          (change-language :en)))))
 
-(defn open-collapsible [id]
-  (btu/scroll-and-click [{:id (name id) :fn/has-class :collapsible}
-                         {:css ".show-more-link"}])
-  (btu/wait-visible [{:id (name id)}
-                     {:css ".collapse-open"}]))
+(defn aria-controls [& [id]]
+  (if id
+    (format "[aria-controls='%s']" (name id))
+    "[aria-controls]"))
 
-(defn aria-controls [id] (format "[aria-controls='%s']" (name id)))
+(defn aria-expanded [& [value]]
+  (if (some? value)
+    (format "[aria-expanded='%s']" (true? value))
+    "[aria-expanded]"))
 
-(defn open-external-collapsible [id]
-  (btu/scroll-and-click {:css (str "a.show-more-link" (aria-controls id))})
+(defn open-collapsible [id]
+  (btu/scroll-and-click {:css (str (aria-controls id) (aria-expanded false))})
   (btu/wait-visible [{:id (name id)}
                      {:css ".collapse-open"}]))
 
@@ -395,9 +397,9 @@
   (when external-links
     (btu/scroll-and-click :licensetype-link)
     (btu/eventually-visible? :localizations-en-link)
-    (btu/fill-human :localizations-en-link (:en external-links))
-    (btu/fill-human :localizations-fi-link (:fi external-links))
-    (btu/fill-human :localizations-sv-link (:sv external-links)))
+    (some->> (:en external-links) (btu/fill-human :localizations-en-link))
+    (some->> (:fi external-links) (btu/fill-human :localizations-fi-link))
+    (some->> (:sv external-links) (btu/fill-human :localizations-sv-link)))
   (when inline-text
     (btu/scroll-and-click :licensetype-text)
     (btu/eventually-visible? :localizations-en-text)
@@ -1057,7 +1059,7 @@
     (testing "handler should see application after clicking on View"
       (wait-page-title (format "Application %s: test-handling – REMS" (btu/context-getx :external-id))))
     (testing "handler should see the applicant info"
-      (open-collapsible :applicants-info-collapsible)
+      (open-collapsible :applicant-info-collapsible)
       (btu/screenshot "after-opening-applicant-info")
       (is (= {"Name" "Alice Applicant"
               "Accepted terms of use" true
@@ -1441,14 +1443,18 @@
       (btu/scroll-and-click :request-review-dropdown)
       (is (btu/eventually-visible? :request-review-action-button))
       (btu/scroll-and-click :request-review-action-button)
-
       (is (btu/eventually-visible? :actions-request-review))
+
+      (Thread/sleep 500) ; wait for /reviewers api request
+
       (btu/scroll-and-click [:actions-request-review
                              {:css ".form-group > .dropdown-container"}])
       (is (btu/eventually-visible? {:css ".dropdown-select__menu"}))
 
-      (btu/scroll-and-click [{:css ".dropdown-select__menu"}
-                             {:tag :div :fn/has-text "Carl Reviewer"}])
+      (btu/scroll-and-click [:actions-request-review
+                             {:css ".form-group > .dropdown-container"}
+                             {:css ".dropdown-select__menu"}
+                             {:fn/has-text "Carl Reviewer"}])
 
       (btu/scroll-and-click :request-review-button)
       (is (btu/eventually-visible? {:css ".alert-success"}))
@@ -2143,30 +2149,31 @@
 ;; NB: admin components use 0-base index (for both data and id)
 (defn field-component [attr] {:id (format "fields-%s-%s" (btu/context-getx :field-index) (name attr))})
 (defn preview-component [attr] {:id (format "form-1-field-%s-%s" (btu/context-getx :field-id) (name attr))})
+
 (defn field-settings-collapsible [] {:id (format "field-collapsible-%s-settings" (btu/context-getx :field-id))})
 (defn field-placeholder-collapsible [] {:id (format "field-collapsible-%s-placeholder" (btu/context-getx :field-id))})
 (defn field-description-collapsible [] {:id (format "field-collapsible-%s-description" (btu/context-getx :field-id))})
 
-(defn field-editor [& [{:keys [id index]}]]
+(defn field-editor [& [id index]]
   {:css (str ".form-field"
              (format "[data-field-id='%s']" (name (or id (btu/context-getx :field-id))))
              (format "[data-field-index='%s']" (or index (btu/context-getx :field-index))))})
 
-(defn field-preview [& [{:keys [id index]}]]
+(defn field-preview [& [id index]]
   {:css (str ".field-preview"
              (format "[data-field-id='%s']" (name (or id (btu/context-getx :field-id))))
              (format "[data-field-index='%s']" (or index (btu/context-getx :field-index))))})
 
-(defn check-data-attribute! [elem k v]
-  (is (= (str v) (btu/get-element-attr-el elem (str "data-" (name k)))))
-  v)
-
-(defn add-form-field! [{:keys [expected-field-id expected-field-index]}]
-  (btu/scroll-and-click-el (nth (btu/query-all {:class :add-form-field}) expected-field-index))
-  (btu/wait-visible {:css ".form-field"})
-  (let [new-field (nth (btu/query-all {:css ".form-field"}) expected-field-index)]
-    (btu/context-assoc! :field-id (check-data-attribute! new-field :field-id expected-field-id)
-                        :field-index (check-data-attribute! new-field :field-index expected-field-index))))
+(defn add-form-field! [& [{:keys [expected-field-id expected-field-index]}]]
+  (btu/context-assoc! :field-index (or expected-field-index
+                                       (some-> (btu/context-get :field-index) inc)
+                                       0))
+  (btu/context-assoc! :field-id (or expected-field-id
+                                    (str "fld" (inc (btu/context-getx :field-index)))))
+  (let [idx (btu/context-getx :field-index)]
+    (btu/scroll-and-click [{:css (format ".new-form-field[data-field-index='%s']" idx)}
+                           {:fn/text "Add field"}])
+    (btu/wait-visible (field-editor))))
 
 (defn fill-localized-title! [fmt]
   (btu/fill-human (field-component :title-en) (format fmt "EN"))
@@ -2183,7 +2190,7 @@
   (btu/fill-human (field-component :info-text-fi) (format fmt "FI"))
   (btu/fill-human (field-component :info-text-sv) (format fmt "SV"))
   ;; check preview as well
-  (btu/scroll-and-click [{:css (aria-controls (:id (preview-component :collapsible)))}])
+  (btu/scroll-and-click {:css (aria-controls (:id (preview-component :collapsible)))})
   (is (btu/eventually-visible? (preview-component :collapsible)))
   (is (= (btu/value-of (preview-component :collapsible))
          (format fmt "EN"))))
@@ -2205,7 +2212,7 @@
       (fill-form-field "SV" "Form Editor Test (SV)")
 
       (testing "add and remove a field"
-        (add-form-field! {:expected-field-id "fld1" :expected-field-index 0})
+        (add-form-field! {:expected-field-index 0})
         (btu/scroll-and-click [(field-editor) {:css ".form-field-controls .remove"}])
         (btu/wait-has-alert)
         (btu/accept-alert)
@@ -2215,45 +2222,45 @@
       (testing "create all field types"
 
         (testing "create text field"
-          (add-form-field! {:expected-field-id "fld1" :expected-field-index 0})
+          (add-form-field! {:expected-field-index 0})
           (testing "fill localized title"
             (fill-localized-title! "Text field (%s)"))
           (testing "fill localized placeholder"
-            (open-external-collapsible (:id (field-placeholder-collapsible)))
+            (open-collapsible (:id (field-placeholder-collapsible)))
             (fill-localized-placeholder! "Text field placeholder (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Text field description (%s)"))
           (testing "set optional"
             (btu/scroll-and-click (field-component :optional)))
           (testing "set maximum length"
-            (open-external-collapsible (:id (field-settings-collapsible)))
+            (open-collapsible (:id (field-settings-collapsible)))
             (btu/fill-human (field-component :max-length) "127")))
 
         (testing "create text area"
-          (add-form-field! {:expected-field-id "fld2" :expected-field-index 1})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-texta))
           (testing "fill localized title"
             (fill-localized-title! "Text area (%s)"))
           (testing "fill localized placeholder"
-            (open-external-collapsible (:id (field-placeholder-collapsible)))
+            (open-collapsible (:id (field-placeholder-collapsible)))
             (fill-localized-placeholder! "Text area placeholder (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Text area description (%s)"))
           (testing "set optional"
             (btu/scroll-and-click (field-component :optional)))
           (testing "set maximum length"
-            (open-external-collapsible (:id (field-settings-collapsible)))
+            (open-collapsible (:id (field-settings-collapsible)))
             (btu/fill-human (field-component :max-length) "127")))
 
         (testing "create option field"
-          (add-form-field! {:expected-field-id "fld3" :expected-field-index 2})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-option))
           (testing "fill localized title"
             (fill-localized-title! "Option list (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Option description (%s)"))
           (testing "create two options"
             (btu/scroll-and-click (field-component :add-option))
@@ -2271,7 +2278,7 @@
             (btu/fill-human (field-component :options-1-label-sv) "Nej")))
 
         (testing "create multi-select field"
-          (add-form-field! {:expected-field-id "fld4" :expected-field-index 3})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-multiselect))
           (testing "fill localized title"
             (fill-localized-title! "Multi-select list (%s)"))
@@ -2297,7 +2304,7 @@
                     "multi-select-option-2"]))))
 
         (testing "create table field"
-          (add-form-field! {:expected-field-id "fld5" :expected-field-index 4})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-table))
           (testing "fill localized title"
             (fill-localized-title! "Table (%s)"))
@@ -2320,48 +2327,48 @@
                       "Actions"])))))
 
         (testing "create date field"
-          (add-form-field! {:expected-field-id "fld6" :expected-field-index 5})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-date))
           (testing "fill localized title"
             (fill-localized-title! "Date (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Date description (%s)")))
 
         (testing "create email address field"
-          (add-form-field! {:expected-field-id "fld7" :expected-field-index 6})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-email))
           (testing "fill localized title"
             (fill-localized-title! "Email (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Email description (%s)")))
 
         (testing "create phone number field"
-          (add-form-field! {:expected-field-id "fld8" :expected-field-index 7})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-phone-number))
           (testing "fill localized title"
             (fill-localized-title! "Phone number (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Phone number description (%s)")))
 
         (testing "create ip address field"
-          (add-form-field! {:expected-field-id "fld9" :expected-field-index 8})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-ip-address))
           (testing "fill localized title"
             (fill-localized-title! "IP address (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "IP address description (%s)")))
 
         (testing "create attachment field"
-          (add-form-field! {:expected-field-id "fld10" :expected-field-index 9})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-attachment))
           (testing "fill localized title"
             (fill-localized-title! "Attachment (%s)"))
           (testing "fill localized description"
-            (open-external-collapsible (:id (field-description-collapsible)))
+            (open-collapsible (:id (field-description-collapsible)))
             (fill-localized-description! "Attachment description (%s)"))
           (testing "attachment has extra info in preview"
             (btu/context-assoc! ::attachment-collapsible (str "upload-" (:id (preview-component :info-collapsible))))
@@ -2370,14 +2377,14 @@
             (is (btu/eventually-visible? {:id (btu/context-getx ::attachment-collapsible)}))))
 
         (testing "create label field"
-          (add-form-field! {:expected-field-id "fld11" :expected-field-index 10})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-label))
           (testing "fill localized title"
             (fill-localized-title! "Label (%s)")
             (is (btu/eventually-visible? [(field-preview) {:tag :label :fn/text "Label (EN)"}]))))
 
         (testing "create header field"
-          (add-form-field! {:expected-field-id "fld12" :expected-field-index 11})
+          (add-form-field!)
           (btu/scroll-and-click (field-component :type-header))
           (testing "fill localized title"
             (fill-localized-title! "Header (%s)")
@@ -2442,7 +2449,7 @@
       (wait-page-title "Edit form – REMS")
 
       (testing "add description field"
-        (add-form-field! {:expected-field-id "fld13" :expected-field-index 0})
+        (add-form-field! {:expected-field-index 0 :expected-field-id "fld13"})
         (btu/scroll-and-click (field-component :type-description))
         (testing "fill localized title"
           (fill-localized-title! "Description (%s)"))
@@ -2456,9 +2463,9 @@
         (btu/wait-page-loaded)
         (wait-page-title "Edit form – REMS")
 
-        (open-external-collapsible (str "field-collapsible-" (btu/context-getx :field-id)))
+        (open-collapsible (str "field-collapsible-" (btu/context-getx :field-id)))
         (btu/scroll-and-click (field-component :type-description))
-        (open-external-collapsible (:id (field-description-collapsible)))
+        (open-collapsible (:id (field-description-collapsible)))
         (btu/fill-human (field-component :info-text-en) "Description (EN)")
         (btu/fill-human (field-component :info-text-fi) "Description (FI)")
         (btu/fill-human (field-component :info-text-sv) " ")
@@ -2611,7 +2618,7 @@
       (fill-form-field "SV" "Conditional field test (SV)")
 
       (testing "create option field"
-        (add-form-field! {:expected-field-id "fld1" :expected-field-index 0})
+        (add-form-field!)
         (btu/scroll-and-click (field-component :type-option))
         (testing "fill localized title"
           (fill-localized-title! "Option (%s)"))
@@ -2631,7 +2638,7 @@
           (btu/fill-human (field-component :options-1-label-sv) "Nej")))
 
       (testing "create multiselect field"
-        (add-form-field! {:expected-field-id "fld2" :expected-field-index 1})
+        (add-form-field!)
         (btu/scroll-and-click (field-component :type-multiselect))
         (testing "fill localized title"
           (fill-localized-title! "Multiselect (%s)"))
@@ -2655,11 +2662,11 @@
           (btu/fill-human (field-component :options-2-label-sv) "Z")))
 
       (testing "create conditional text field"
-        (add-form-field! {:expected-field-id "fld3" :expected-field-index 2})
+        (add-form-field!)
         (testing "fill localized title"
           (fill-localized-title! "Text (%s)"))
         (testing "set visibility to only if field 1 has true selected"
-          (open-external-collapsible (:id (field-settings-collapsible)))
+          (open-collapsible (:id (field-settings-collapsible)))
           (is (btu/eventually-visible? (field-component :visibility-type)))
           (btu/fill (field-component :visibility-type) "Only if\n")
           (is (btu/eventually-visible? (field-component :visibility-field)))
@@ -2668,12 +2675,12 @@
           (btu/fill (field-component :visibility-value) "Yes\n")))
 
       (testing "create conditional email field"
-        (add-form-field! {:expected-field-id "fld4" :expected-field-index 3})
+        (add-form-field!)
         (btu/scroll-and-click :fields-3-type-email)
         (testing "fill localized title"
           (fill-localized-title! "Email (%s)"))
         (testing "set visibility to only if field 2 has X,Z selected"
-          (open-external-collapsible (:id (field-settings-collapsible)))
+          (open-collapsible (:id (field-settings-collapsible)))
           (is (btu/eventually-visible? (field-component :visibility-type)))
           (btu/fill (field-component :visibility-type) "Only if\n")
           (is (btu/eventually-visible? (field-component :visibility-field)))
@@ -3169,7 +3176,7 @@
   (btu/with-postmortem
     (login-as "alice")
     (go-to-catalogue)
-    (btu/set-window-size 400 600) ; small enough for mobile
+    (btu/set-window-rect {:width 400 :height 600}) ; small enough for mobile
     (btu/wait-invisible :small-navbar)
     (btu/scroll-and-click {:css ".navbar-toggler"})
     (is (btu/eventually-visible? :small-navbar))