Integration test for adding synced grubs
This commit is contained in:
parent
82eb60cbc2
commit
dbd6222251
5 changed files with 40 additions and 5 deletions
BIN
bin/chromedriver
Executable file
BIN
bin/chromedriver
Executable file
Binary file not shown.
30
integration/grub/integration_test.clj
Normal file
30
integration/grub/integration_test.clj
Normal file
|
@ -0,0 +1,30 @@
|
|||
(ns grub.integration-test
|
||||
(:require [clj-webdriver.taxi :as taxi]
|
||||
[clj-webdriver.core :as webdriver]
|
||||
[clojure.test :as test]))
|
||||
|
||||
(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-rand-grub []
|
||||
(str "testgrub" (rand-int 10000)))
|
||||
|
||||
(defn test-adding-grubs [driver1 driver2]
|
||||
(let [grubs (repeatedly 4 get-rand-grub)]
|
||||
(doseq [grub grubs]
|
||||
(add-grub driver1 grub))
|
||||
(doseq [grub grubs]
|
||||
(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)))
|
|
@ -13,7 +13,8 @@
|
|||
[core.async "0.1.0-SNAPSHOT"]
|
||||
[com.novemberain/monger "1.5.0"]]
|
||||
:profiles {:dev {:dependencies [[speclj "2.5.0"]
|
||||
[specljs "2.7.4"]]}}
|
||||
[specljs "2.7.4"]
|
||||
[clj-webdriver "0.6.0"]]}}
|
||||
:plugins [[lein-cljsbuild "0.3.2"]
|
||||
[lein-ring "0.8.6"]
|
||||
[speclj "2.5.0"]
|
||||
|
@ -30,7 +31,7 @@
|
|||
:compiler {:output-to "public/js/grub.js"
|
||||
:optimizations :simple}}
|
||||
:test-commands {"test" run-specs}}})
|
||||
:source-paths ["src/clj"]
|
||||
:source-paths ["src/clj" "integration"]
|
||||
:test-paths ["spec/clj"]
|
||||
:ring {:handler grub.core/app}
|
||||
:main grub.core)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns grub.core
|
||||
(:require [grub.websocket :as ws]
|
||||
[grub.db :as db]
|
||||
[grub.integration-test :as integration-test]
|
||||
[ring.middleware.reload :as reload]
|
||||
[compojure.core :refer [defroutes GET POST]]
|
||||
[compojure.handler :as handler]
|
||||
|
@ -36,4 +37,7 @@
|
|||
|
||||
(defn -main [& args]
|
||||
(db/connect-and-handle-events)
|
||||
(httpkit/run-server app {:port 3000}))
|
||||
(defonce stop-server (httpkit/run-server app {:port 3000}))
|
||||
(when (some #(= % "integration") args)
|
||||
(integration-test/run)
|
||||
(stop-server)))
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
[cljs.core.async.macros :refer [go]]))
|
||||
|
||||
(def add-grub-text
|
||||
(node [:input.form-control {:type "text" :placeholder "2 grubs"}]))
|
||||
(node [:input.form-control {:id "add-grub-input" :type "text" :placeholder "2 grubs"}]))
|
||||
|
||||
(def add-grub-btn
|
||||
(node [:button.btn.btn-default {:type "button"} "Add"]))
|
||||
(node [:button.btn.btn-default {:id "add-grub-btn" :type "button"} "Add"]))
|
||||
|
||||
(deftemplate main-template []
|
||||
[:div.container
|
||||
|
|
Loading…
Reference in a new issue