summaryrefslogtreecommitdiff
path: root/test/aopweb.rb
blob: 04b03e4a151b23f969c302fb0a5f646835a09f8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
=begin
require_relative "setup.rb"
require 'capybara'
require 'capybara-webkit'

ENV['DISPLAY'] ="localhost:1.0"

begin
  puts "Service URI is: #{$aop[:uri]}"
rescue
  puts "Configuration Error: $aop[:uri] is not defined in: " + File.join(ENV["HOME"],".opentox","config","test.rb")
  exit
end


Capybara.register_driver :webkit do |app|
  Capybara::Webkit::Driver.new(app).tap{|d| d.browser.ignore_ssl_errors}
end
Capybara.default_driver = :webkit
Capybara.default_wait_time = 20
Capybara.javascript_driver = :webkit
Capybara.run_server = false
Capybara.app_host = $aop[:uri]

class LazarWebTest < MiniTest::Test
  i_suck_and_my_tests_are_order_dependent!

  include Capybara::DSL

  def test_00_xsetup
    `Xvfb :1 -screen 0 1024x768x16 2>/dev/null &`
    sleep 2
  end

  def test_01_visit
    visit('/')
    assert page.has_content?('PubChem read across')
    assert page.has_content?('This is an experimental version.')
  end
  
  def test_02_inexisting
    visit('/')
    page.fill_in 'name', :with => "blahblah"
    find(:xpath, '/html/body/form/fieldset/input[2]').click
    assert page.has_content?('Could not find a compound with name "blahblah"')
  end

  def test_03_existing
    visit('/')
    page.fill_in 'name', :with => "doxorubicin"
    find(:xpath, '/html/body/form/fieldset/input[2]').click
    sleep 2
    assert page.has_content?('Similar compounds')
  end
  
  def test_99_kill
    `pidof Xvfb|xargs kill`
  end

end
=end