Started working on test script

This commit is contained in:
Bryce Covert
2020-12-28 09:41:39 -08:00
parent 41660226cc
commit 1d1f8e220c
6 changed files with 126 additions and 59 deletions

View File

@@ -0,0 +1,52 @@
(ns auto-ap.functional.test
(:require [clojure.test :as t :refer :all]
[etaoin.api :as e]
[etaoin.keys :as k]
[config.core :refer [env]]
[clj-time.core :as time]
[buddy.sign.jwt :as jwt]))
(def base-url "https://staging3.app.integreatconsult.com")
(defn login-admin [driver]
(let [jwt-token (jwt/sign {:user "Automated Tests"
:exp (time/plus (time/now) (time/days 30))
:user/role "admin"
:user/name "Automated Tests"}
(:jwt-secret env)
{:alg :hs512})]
(e/go driver (str base-url "/?jwt=" jwt-token))
(e/wait-visible driver {:tag :h1
:class "title"})))
(deftest create-invoice
(testing "Creating a new invoice"
(e/with-wait-timeout 10
(e/with-firefox {} driver
(login-admin driver)
(e/click driver {:tag :a :fn/text "Invoices"})
(e/wait-visible driver {:tag :h1
:class "title"
:fn/text "Unpaid Invoices"})))))
(deftest edit-client
(testing "Editing a client"
(e/with-wait-timeout 10
(e/with-firefox {} driver
(login-admin driver)
(e/click driver {:tag :a :class "navbar-link login"})
(e/click driver {:tag :a :fn/text "Administration"})
(e/wait-visible driver {:tag :h1
:class "title"
:fn/text "Admin"})
(e/click driver {:tag :span :fn/text "Clients"})
(e/wait-visible driver {:tag :h1
:class "title"
:fn/text "Clients"})
(e/click driver {:tag :i :class "fa fa-pencil"})
(e/wait-visible driver {:tag :button
:fn/text "Save"})
(e/click driver {:tag :button :fn/text "Save"})
(e/wait-invisible driver {:tag :form})))))