Commit d5b716e3 authored by Ryan Herbert's avatar Ryan Herbert

first draft server functional tests

See #2881
parent 3cc64730
require 'rubygems'
gem "minitest"
require 'watir-webdriver'
require 'test/unit'
require "minitest/autorun"
require 'minitest/ci'
if ENV['HEADLESS']
require 'headless'
end
load 'vidjil_browser.rb'
include Test::Unit::Assertions
MiniTest.autorun
#browser test suite
class BrowserTest < MiniTest::Test
def self.test_order
:alpha
end
def setup
if ENV['HEADLESS'] and not defined? $headless
$headless = Headless.new
$headless.start
end
end
def set_browser(url)
puts "Open browser"
$b = VidjilBrowser.new
puts "Resize"
$b.window.resize_to(1500, 800)
puts "Testing Vidjil client at %s" % url
$b.goto url
# check that the browser loaded correctly
if not $b.div(:id => 'logo').present?
print "Loading of Vidjil client failed. Do not execute remaining tests."
exit
end
puts "Vidjil client loaded, launching tests."
# check the 'db_content' window opens
assert ($b.div(:id => 'db_content').present?), "db content is not present"
$b.div(:id => 'tip-container').div(:class => 'tip_1').element(:class => 'icon-cancel').click
end
def close_everything
if defined? $b
puts "\nTests finished, closing browser."
$b.close
if ENV['HEADLESS']
$headless.destroy
end
end
end
end
# sh launch_functional_tests "functional/test_*rb"
FUNCTIONAL_TESTS=$1
rename_reports_in() {
dir="$1"
b="$2"
if [ "$b" = "." ]; then
b="default"
else
b=$(echo "$b" | tr '/' '-')
fi
for file in $1/*.xml; do
filename=$(basename -s .xml $file)
mv $file $dir/$filename-$b.xml
done
}
rm -f test/*.xml
EXIT=0
if [ -z "$FUNCTIONAL_CLIENT_BROWSER_PATH" ]; then
FUNCTIONAL_CLIENT_BROWSER_PATH="."
fi
for browser in $FUNCTIONAL_CLIENT_BROWSER_PATH; do
for file in $FUNCTIONAL_TESTS; do
if [ ${#browser} -gt 1 ]; then
export WATIR_BROWSER_PATH="$browser"
fi
ruby -I functional $file;
TMP_EXIT=$?
if [ $TMP_EXIT -ne 0 ]; then
EXIT=$TMP_EXIT
fi
rename_reports_in test/reports/ "$browser"
mv test/reports/*.xml test/
done
done
exit $EXIT
load 'vidjil_browser.rb'
load 'browser_test.rb'
class TestLogin < BrowserTest
def setup
super
if not defined? $b
set_browser("https://localhost/browser")
end
end
def test_00_failed_login
login_form = $b.form(:id => 'login_form')
assert(login_form.present?)
login_form.text_field(:id => "auth_user_email").set('foo@bar.com')
login_form.text_field(:id => "auth_user_password").set('foobar')
login_form.tr(:id => 'submit_record_row').input(:type => 'submit').click
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment