Integration test: verify grubs are stored on server
This commit is contained in:
parent
6754e05001
commit
635dfd948e
1 changed files with 27 additions and 10 deletions
|
@ -3,17 +3,21 @@
|
|||
[clj-webdriver.core :as webdriver]
|
||||
[clojure.test :as test]))
|
||||
|
||||
(def site-url "http://localhost:3000")
|
||||
|
||||
(defn add-grub [driver grub-text]
|
||||
(taxi/input-text driver "#add-grub-input" grub-text)
|
||||
(taxi/click driver {:text "Add"}))
|
||||
|
||||
(defn get-driver []
|
||||
(webdriver/start {:browser :chrome} "http://localhost:3000"))
|
||||
(defn get-driver [url]
|
||||
(webdriver/start {:browser :chrome} url))
|
||||
|
||||
(defn get-rand-grub []
|
||||
(str "testgrub" (rand-int 10000)))
|
||||
|
||||
(defn test-adding-grubs [driver1 driver2]
|
||||
(defn test-adding-grubs [url driver1 driver2]
|
||||
(taxi/to driver1 url)
|
||||
(taxi/to driver2 url)
|
||||
(let [grubs (repeatedly 4 get-rand-grub)]
|
||||
(doseq [grub grubs]
|
||||
(add-grub driver1 grub))
|
||||
|
@ -21,10 +25,23 @@
|
|||
(test/is (taxi/find-element driver2 {:text grub})
|
||||
"Added grubs should appear in other browser"))))
|
||||
|
||||
(defn run []
|
||||
(println "Starting integration test")
|
||||
(let [driver1 (get-driver)
|
||||
driver2 (get-driver)]
|
||||
(test-adding-grubs driver1 driver2)
|
||||
(taxi/quit driver1)
|
||||
(taxi/quit driver2)))
|
||||
(defn test-grubs-are-stored-on-server [url driver]
|
||||
(taxi/to driver url)
|
||||
(let [grubs (repeatedly 4 get-rand-grub)]
|
||||
(doseq [grub grubs]
|
||||
(add-grub driver grub))
|
||||
(taxi/refresh driver)
|
||||
(doseq [grub grubs]
|
||||
(test/is (taxi/find-element driver {:text grub})
|
||||
"Previously added grubs should be loaded on refresh"))))
|
||||
|
||||
|
||||
(defn run [port]
|
||||
(let [site-url (str "http://localhost:" port)]
|
||||
(println "Starting integration test")
|
||||
(let [driver1 (get-driver site-url)
|
||||
driver2 (get-driver site-url)]
|
||||
(test-adding-grubs site-url driver1 driver2)
|
||||
(test-grubs-are-stored-on-server site-url driver1)
|
||||
(taxi/quit driver1)
|
||||
(taxi/quit driver2))))
|
||||
|
|
Loading…
Reference in a new issue