<commit_before>(ns functional.functional-test
  (:require [clojure.test :refer :all]
            [clj-webdriver.taxi :refer :all]
            [clj-webdriver.driver :refer [init-driver]]
            [environ.core :refer [env]])
  (import org.openqa.selenium.phantomjs.PhantomJSDriver
          org.openqa.selenium.Dimension))

(defn in? [seq elm]
  (some #(= elm %) seq))

(def hd-tv-size (Dimension. 1920 1080))

(defn functional-fixture [test-fn]
  (let [driver (PhantomJSDriver.)]
    (.. driver (manage) (window) (setSize hd-tv-size))
    (set-driver! (init-driver {:webdriver driver})))

  (test-fn)

  (take-screenshot :file "./target/functional-test.png")
  (quit))

(use-fixtures :once functional-fixture)

(defn nevergreen-under-test []
  (let [url (or (env :functional-url) "http://localhost:5000/config")]
    (println "Running agaisnt" url)
    url))

(def expected-projects ["success building project", "failure sleeping project", "failure building project"])

(deftest simple-journey
  (to (nevergreen-under-test))

  (clear "#cctray-url")
  (input-text "#cctray-url" "http://localhost:5000/test_data.xml")
  (click "#cctray-fetch")

  (wait-until #(exists? "#projects > p > label > input"))

  (click "#include-all")
  (click "#monitor")

  (wait-until #(= (title) "Nevergreen"))

  (doseq [actual-project (elements "#projects > li > div > div")]
    (is (in? expected-projects (text actual-project)) "Expected project not displayed")))<commit_msg>Chris #22 - use the base url to get the test data as well!<commit_after>(ns functional.functional-test
  (:require [clojure.test :refer :all]
            [clj-webdriver.taxi :refer :all]
            [clj-webdriver.driver :refer [init-driver]]
            [environ.core :refer [env]])
  (import org.openqa.selenium.phantomjs.PhantomJSDriver
          org.openqa.selenium.Dimension))

(defn in? [seq elm]
  (some #(= elm %) seq))

(def hd-tv-size (Dimension. 1920 1080))

(defn functional-fixture [test-fn]
  (let [driver (PhantomJSDriver.)]
    (.. driver (manage) (window) (setSize hd-tv-size))
    (set-driver! (init-driver {:webdriver driver})))

  (test-fn)

  (take-screenshot :file "./target/functional-test.png")
  (quit))

(use-fixtures :once functional-fixture)

(defn nevergreen-under-test []
  (let [url (or (env :functional-url) "http://localhost:5000")]
    (println "Running agaisnt" url)
    url))

(def expected-projects ["success building project", "failure sleeping project", "failure building project"])

(deftest simple-journey
  (let [base-url (nevergreen-under-test)]
    (to (str base-url "/config"))

    (clear "#cctray-url")
    (input-text "#cctray-url" (str base-url "/test_data.xml"))
    (click "#cctray-fetch")

    (wait-until #(exists? "#projects > p > label > input"))

    (click "#include-all")
    (click "#monitor")

    (wait-until #(= (title) "Nevergreen"))

    (doseq [actual-project (elements "#projects > li > div > div")]
      (is (in? expected-projects (text actual-project)) "Expected project not displayed"))))
{'fraction_non_alphanumeric': 0.17218543046357615, 'fraction_numerical': 0.009933774834437087, 'mean_word_length': 3.6548536209553157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6870171', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1032, 'n_words': 252}