                       :value        value})
                    behaviours)))
 
-
-(defn dummy-behaviour [ticket-fields]
-  (let [master-field (rand-nth ticket-fields)
-        field-value (rand-nth (:possible-values master-field))
-        slave-field (rand-nth (fields-without-field ticket-fields
-                                                    master-field))]
-    [[:select-master-field master-field],
-     [:select-field-value field-value],
-     [:select-slave-field slave-field]]))
-
 (defn setup-app [ticket-fields]
   (.appendChild (.-body js/document)
                 (let [element (.createElement js/document "div")

            [iframe-app.condition-selector :refer [fields-without-field]]
            [iframe-app.core :refer [main app]]))



(enable-console-print!)

(defonce app-state (atom {:conditions #{}}))

(set! (.-warn js/console) (fn [t] nil))

; TODO: use test.check to generate behaviour
; TODO: make finders that wait til they find what they're looking for (like Capybara)

(def p println)




(defn get-master-field-element [field]
  (sel1 (str "a.master-field[data-id='" (:id field) "']")))

(defn get-field-value-element [field-value]
  (sel1 (str "a.field-value[data-value='" (:value field-value) "']")))

(defn get-slave-field-element [field]
  (sel1 (str "a.slave-field[data-id='" (:id field) "']")))

(defn element-click-fn [element-getter]
  (fn [arg]

            :shared {:pick-channel  (chan)
                     :ticket-fields ticket-fields}}))

(defn dummy-behaviour [ticket-fields]
  (let [master-field (rand-nth ticket-fields)
        field-value (rand-nth (:possible-values master-field))
        slave-field (rand-nth (fields-without-field ticket-fields
                                                    master-field))]
    [[:select-master-field master-field],
     [:select-field-value field-value],
     [:select-slave-field slave-field]]))


(deftest ^:async declarative
  (let [ticket-fields (first (gen/sample ticket-fields-gen 1))
        behaviour (dummy-behaviour ticket-fields)
        states (get-states-for-behaviors behaviour)
        behaviours-with-state-afterwards (map vector behaviour (rest states))]
