 
 (set-driver! browser-spec)
 (set-finder! xpath-finder)
-
-;(implicit-wait 3000)
 
 (def params {:base-url "http://localhost:3449"})
 


  ;;;;;;;;;;;;; Edit form with cancel ;;;;;;;;;;;;;

  (to "http://localhost:3449")
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'EPR212A408000Z')]"))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'optocoupler')]"))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), '7')]"))
  (click "//button[contains(text(), 'Edit')]")
  (wait-until (present? "//input[@name]"))

  (is (present? "//input[@name='name' and @value='EPR212A408000Z']"))
  (is (present? "//input[@name='tags' and @value='optocoupler']"))
  (is (present? "//input[@name='amount' and @value='7']"))


  (input-text "//input[@name='tags']" "tag1, tag2")
  (input-text "//input[@name='amount']" "20")
  (click "//button[contains(text(), 'Save')]")

  (wait-until (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'new name')]"))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'tag1, tag2')]"))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), '20')]"))

  ;;;;;;;;;;;;; Search component ;;;;;;;;;;;;;

  ; guard
  (is (< 1 (count (elements "//li[@class='component']"))))

  ; linear regulator by name
  (input-text "//input[@name='search']" "LF")
  (wait-until (= 1 (count (elements "//li[@class='component']"))))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'LF33CV')]"))

  ; avr programmer by tag
  (clear "//input[@name='search']")
  (input-text "//input[@name='search']" "rs232")
  (wait-until (= 1 (count (elements "//li[@class='component']"))))
  (is (present? "//li[@class='component'][1]//span[@class='value' and contains(text(), 'AVRProg USB v3')]"))

  ;;;;;;;;;;;;; Search edited component ;;;;;;;;;;;;;

  ; guard
  (clear "//input[@name='search']")
  (input-text "//input[@name='search']" "wtf")
  (wait-until (= 0 (count (elements "//li[@class='component']"))))
  (clear "//input[@name='search']")
  (wait-until (present? "//li[@class='component']"))

  (click "//button[contains(text(), 'Edit')]")
  (clear "//input[@name='name']")
  (input-text "//input[@name='name']" "wtf")
  (click "//button[contains(text(), 'Save')]")
  (input-text "//input[@name='search']" "wtf")
  (wait-until (= 1 (count (elements "//li[@class='component']"))))

  ;;;;;;;;;;;;;; Search new component ;;;;;;;;;;;;;

  ; guard
  (input-text "//input[@name='search']" "new-component")
  (wait-until (= 0 (count (elements "//li[@class='component']"))))
  (clear "//input[@name='search']")

  (click "//button[contains(text(), 'Add new')]")
  (wait-until (present? "//input[@name='name']"))
  (input-text "//input[@name='name']" "new-component")
  (click "//button[contains(text(), 'Save')]")
  (input-text "//input[@name='search']" "new-component")
  (wait-until (= 1 (count (elements "//li[@class='component']")))))

