Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 60136d1c authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Tests: Update test_browser.rb for new .data file

Data file used is the first one from the doc (automatically retrieved from org file).
The browser test now uses a headless browser if HEADLESS environment variable is defined.
parent da0792b8
......@@ -3,58 +3,78 @@ gem "minitest"
require 'watir-webdriver'
require 'test/unit'
require "minitest/autorun"
if ENV['HEADLESS']
require 'headless'
end
include Test::Unit::Assertions
MiniTest.autorun
class MySpec < MiniTest::Spec
class MyClass
end
def self.init
puts "hi"
#browser test suite
class Browser < MiniTest::Test
def self.test_order
:alpha
end
def setup
folder_path = Dir.pwd
index_path = 'file://' + folder_path + '/../index.html'
data_path = folder_path + '/test.data'
data_path = folder_path + '/../../doc/analysis-example1.vidjil'
analysis_path = folder_path + '/test.analysis'
if ENV['HEADLESS']
$headless = Headless.new(dimensions: "1400x900x24")
$headless.start
end
$b = Watir::Browser.new :firefox
#$b = Watir::Browser.new :chrome
$b.goto index_path
# close the welcoming popup
$b.div(:id => 'popup-msg').button(:text => 'start').click
$b.div(:id => 'popup-msg').button(:text => 'ok').click
assert (not $b.div(:id => 'popup-msg').present?), "Popup message still present"
$b.div(:id => 'demo_file_menu').click
$b.div(:id => 'demo_file_menu').a(:text => 'Open').click
$b.div(:id => 'demo_file_menu').a(:text => 'import data').click
# select data file
$b.div(:id => 'file_menu').file_field(:name,"json").set(data_path)
$b.div(:id => 'file_menu').button(:text => 'start').click
sleep 2
end
#after each tests
def teardown
$b.close
if ENV['HEADLESS']
$headless.destroy
end
end
init
end
def test_00_info_segmentation
assert ($b.div(:id => 'info_segmented').text.include? '335662 reads (76.78%)'), ' Incorrect number of segmented reads'
end
MiniTest.after_run {
$b.close
}
def test_00_info_reads
assert ($b.div(:id => 'info_total').text.include? '437164 reads'), 'Incorrect number of reads'
end
def test_00_default_point_name
assert ($b.div(:id => 'info_point').text.include? 'T8045-BC081-Diag'), 'Incorrect point name in info box'
assert ($b.element(:id => 'time0').text.include? 'T8045-BC081-Diag'), 'Incorrect point name on plot'
end
def test_00_germline
assert ($b.div(:id => 'info').span(:class => 'systemBoxNameMenu').text == 'GTRG'), 'Incorrect system name'
end
def test_00_legend_scatterplot
assert ($b.element(:id => 'visu_axis_x_container').element(:class => 'sp_legend', :index => 0).text == 'TRGV5'), "Bad legend for scatterplot"
assert ($b.element(:id => 'visu_axis_x_container').element(:class => 'sp_legend', :index => 1).text == '?'), "Bad legend for scatterplot"
assert ($b.element(:id => 'visu_axis_y_container').element(:class => 'sp_legend', :index => 0).text == 'TRGJ1'), "Bad legend for scatterplot"
assert ($b.element(:id => 'visu_axis_y_container').element(:class => 'sp_legend', :index => 1).text == '?'), "Bad legend for scatterplot"
end
#browser test suite
class Browser < MiniTest::Test
#after each tests
def teardown
$b.window(:title => "Vidjil").use do
$b.execute_script("m.resetClones()")
$b.element(:id => "visu_back" ).click
end
end
def test_01_init
begin
list = $b.div(:id => 'list_clones')
......@@ -62,162 +82,138 @@ class Browser < MiniTest::Test
assert ( list.li(:id => '0' ).exists?), ">>fail init : clone 0 missing in list"
assert ( $b.element(:id => "circle0" ).exists?), ">>fail init : clone 0 missing in scatterplot"
assert ( $b.element(:id => "polyline0" ).exists?), ">>fail init : clone 0 missing in graph"
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">>fail init : wrong clone size "
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '72.47%' ) , ">>fail init : wrong clone size "
rescue
assert (false), "missing element to run test_01_init \n"
end
end
def test_02_focus
begin
def test_02_fold_left_menu
assert ($b.div(:id => "left-container").present?), ">> fail : left menu should be visible"
$b.div(:id => "vertical-separator").click
assert (not $b.div(:id => "left-container").present?), ">> fail : left menu is still visible"
$b.div(:id => "vertical-separator").click
assert ($b.div(:id => "left-container").present?), ">> fail : left menu did not reappear"
end
def test_03_rename_clone_by_clicking
clone_name = $b.div(:id => 'list_clones').li(:id => '0').div(:class => 'nameBox')
assert (clone_name.text == 'clone-001'), " >> clone name is no corect"
clone_name.double_click
clone_name.text_field(:id => 'new_name').set 'toto'
clone_name.a(:id => 'btnSave').click
assert (clone_name.text == 'toto'), " >> clone name has not changed"
end
def test_04_rename_clone_by_enter
clone_name = $b.div(:id => 'list_clones').li(:id => '0').div(:class => 'nameBox')
clone_name.double_click
clone_name.text_field(:id => 'new_name').set 'other test'
$b.send_keys :return
assert (clone_name.text == 'other test'), " >> clone name has not changed"
end
def test_05_focus_in_list
begin
#test hover a clone in the list
list = $b.div(:id => 'list_clones')
$b.element(:id => "circle0" ).wait_until_present
list.li(:id => '0' ).hover
sleep 1
assert ( $b.element(:id => "circle0", :class => "circle_focus" ).exists?), ">> fail to focus correct plot after hovering a clone in the list"
assert ( $b.element(:id => "polyline0", :class => "graph_focus" ).exists?), ">> fail to focus correct graphLine after hovering a clone in the list"
#test hover a clone in the scatterplot
$b.element(:id => "circle1" ).hover
sleep 1
assert ( $b.element(:id => "circle1", :class => "circle_focus" ).exists?), ">> fail to focus correct plot after hovering a clone in the scatterplot"
assert ( $b.element(:id => "polyline1", :class => "graph_focus" ).exists?), ">> fail to focus correct graphLine after hovering a clone in the scatterplot"
#watir unable to do hover/click on svg path
rescue
assert (false), "missing element to run test_02_focus \n"
assert (false), "missing element to run test"
end
end
def test_03_select
begin
def test_06_focus_in_scatterplot
begin
$b.element(:id => "circle0" ).wait_until_present
$b.element(:id => "circle0" ).hover
assert ( $b.element(:id => "circle0", :class => "circle_focus" ).exists?), ">> fail to focus correct plot after hovering a clone in the scatterplot"
assert ( $b.element(:id => "polyline0", :class => "graph_focus" ).exists?), ">> fail to focus correct graphLine after hovering a clone in the scatterplot"
rescue
assert (false), "missing element to run test\n"
end
end
def test_07_focus_in_graph
begin
$b.element(:id => "circle0" ).wait_until_present
$b.element(:id => "polyline0" ).hover
assert ( $b.element(:id => "circle0", :class => "circle_focus" ).exists?), ">> fail to focus correct plot after hovering a clone in the graph"
assert ( $b.element(:id => "polyline0", :class => "graph_focus" ).exists?), ">> fail to focus correct graphLine after hovering a clone in the graph"
rescue
assert (false), "missing element to run test\n"
end
end
def test_08_click_in_list
#test select a clone in the list
list = $b.div(:id => 'list_clones')
#list.li(:id => '0' ).div(:class => 'nameBox').click
# ".click" work with chrome but not with firefox so direct call with javascript ( a bit hadrcore ...)
$b.execute_script("document.getElementById('0').getElementsByClassName('nameBox')[0].click()")
sleep 1
$b.element(:id => "circle0").wait_until_present
list.li(:id => '0' ).div(:class => 'nameBox').click
assert ( list.li(:id => '0' ).class_name == "list list_select" )
assert ( $b.element(:id => "circle0", :class => "circle_select" ).exists?)
assert ( $b.element(:id => "polyline0", :class => "graph_select" ).exists?)
assert ( $b.element(:id => "seq0" ).exists? ), ">> fail to add clone to segmenter by clicking on the list"
#test select a clone in the scatteplot
$b.element(:id => "circle1" ).click
sleep 1
assert ( list.li(:id => '1' ).class_name == "list list_select" )
assert ( $b.element(:id => "circle1", :class => "circle_select" ).exists?)
assert ( $b.element(:id => "polyline1", :class => "graph_select" ).exists?)
assert ( $b.element(:id => "seq1" ).exists? ), ">> fail to add clone to segmenter by clicking on the scatterplot"
#watir unable to hover/click svg path
#unselect
$b.element(:id => "visu_back" ).click
assert ( list.li(:id => '0' ).class_name == "list" )
rescue
assert (false), "missing element to run test_03_select \n"
end
end
def test_04_cluster
begin
def test_08_click_in_scatterplot
list = $b.div(:id => 'list_clones')
$b.execute_script("m.clusterBy('V')")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '78.65%' ) , ">> fail cluster by V : wrong clone size "
$b.execute_script("m.clusterBy('J')")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '69.92%' ) , ">> fail cluster by J : wrong clone size "
$b.execute_script("m.resetClones()")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail reset cluster : wrong clone size "
rescue
assert (false), "missing element to run test_04_cluster \n"
end
$b.element(:id => "circle0").wait_until_present
$b.element(:id => "circle0" ).click
assert ( list.li(:id => '0' ).class_name == "list list_select" )
assert ( $b.element(:id => "circle0", :class => "circle_select" ).exists?)
assert ( $b.element(:id => "polyline0", :class => "graph_select" ).exists?)
assert ( $b.element(:id => "seq0" ).exists? ), ">> fail to add clone to segmenter by clicking on the scatterplot"
#unselect
$b.element(:id => "visu_back" ).click
assert ( list.li(:id => '0' ).class_name == "list" )
end
def test_05_normalize
def test_09_normalize
begin
list = $b.div(:id => 'list_clones')
elem = $b.div(:id => 'list_clones').li(:id => '0')
tagSelector = $b.div(:id => 'tagSelector')
elem.div(:class => 'starBox').click
$b.input(:id => 'normalized_size').to_subtype.set('0.01')
$b.element(:id => 'normalized_size').wait_until_present
$b.text_field(:id => 'normalized_size').set('0.01')
tagSelector.button(:text => 'ok').click
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '1.000%' ) , ">> fail normalize on : wrong clone size "
$b.div(:id => 'settings_menu').click
$b.radio(:id => 'reset_norm').click
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail normalize off : wrong clone size "
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '72.47%' ) , ">> fail normalize off : wrong clone size "
rescue
assert (false), "missing element to run test_05_normalize \n"
assert (false), "missing element to run test_05_normalize \n"
end
end
def test_06_displayTop
begin
list = $b.div(:id => 'list_clones')
$b.execute_script("m.displayTop(100)")
assert ( list.li(:id => '120' ).visible? ) , ">> fail display : this clone should be visible"
$b.execute_script("m.displayTop(20)")
assert ( not list.li(:id => '120' ).visible? ) , ">> fail display : this clone shouldn't be visible"
rescue
assert (false), "missing element to run test_06_displayTop \n"
end
end
def test_07_merge
def test_10_imgt
begin
list = $b.div(:id => 'list_clones')
#select 3 clones
$b.element(:id => "circle0" ).click(:control)
$b.element(:id => "circle1" ).click(:control)
$b.element(:id => "circle2" ).click(:control)
#merge
#$b.span(:id => "merge" ).click
$b.execute_script("m.merge()")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '75.55%' ) , ">> fail clustering : wrong clone size "
#unmerge
$b.execute_script("m.resetClones()")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.75%' ) , ">> fail unclustering : wrong clone size "
rescue
assert (false), "missing element to run test_07_merge \n"
end
end
def test_08_imgt
begin
#select 3 clones
$b.element(:id => "circle0" ).click(:control)
$b.element(:id => "circle1" ).click(:control)
$b.element(:id => "circle2" ).click(:control)
$b.element(:id => "circle0").wait_until_present
$b.element(:id => "circle0" ).click
$b.span(:id => "toIMGT" ).click
assert ( $b.window(:title => "IMGT/V-QUEST").exists? ) , ">> fail opening IMGT "
$b.window(:title => "IMGT/V-QUEST").use do
assert ($b.text.include? "Number of analysed sequences: 3"), ">> fail IMGT analysis"
assert ($b.text.include? "Number of analysed sequences: 1"), ">> fail IMGT analysis"
assert ($b.text.include? "Homsap TRGV5*01"), ">> IMGT expected V not found"
assert ($b.text.include? "Homsap TRGJ1*02"), ">> IMGT expected J not found"
end
$b.window(:title => "Vidjil").use
......@@ -228,17 +224,18 @@ class Browser < MiniTest::Test
end
def test_09_igBlast
def test_11_igBlast
begin
#select 3 clones
$b.element(:id => "circle5" ).click(:control)
$b.element(:id => "circle8" ).click(:control)
$b.element(:id => "circle0").wait_until_present
$b.element(:id => "circle0" ).click
$b.span(:id => "toIgBlast" ).click
assert ( $b.window(:title => "IgBLAST Search Results").exists? ) , ">> fail opening igblast "
$b.window(:title => "IgBLAST Search Results").use do
assert ($b.text.include? "Index for multiple query sequences (total = 2)"), ">> fail igblast analysis"
assert ($b.text.include? "Query= clone-001"), ">> fail igblast analysis"
assert ($b.text.include? "TRGV5*01"), ">> igblast: expected V not found"
assert ($b.text.include? "TRGJ1*02,TRGJ1*01,TRGJ2*01"), ">> igblast: expected Js not found"
end
$b.window(:title => "Vidjil").use
......@@ -247,85 +244,18 @@ class Browser < MiniTest::Test
assert (false), "missing element to run test_09_igBlast \n"
end
end
def test_10_align
#TODO find a way to use local cgi
skip
begin
#select 2 clones
$b.element(:id => "circle1" ).click(:control)
$b.element(:id => "circle0" ).click(:control)
assert ($b.text.include? "GGTCTATTACTGTGCCACCTTCTGACATAAGAAACTCTTTGGCAGTGGA"), ">> fail to display sequence"
$b.span(:id => "align" ).click
assert ($b.text.include? "CTT---CTG-AC-AT--AAGAAACT--CTTT-GG--C-A-G-TG---G-AA"), ">> fail to align sequences"
rescue
assert (false), "missing element to run test_10_align \n"
end
end
def test_11_load_analysis
begin
analysis_path = Dir.pwd + '/test.analysis'
data_path = Dir.pwd + '/test.data'
$b.div(:id => 'demo_file_menu').click
$b.div(:id => 'demo_file_menu').a(:text => 'Open').click
$b.div(:id => 'file_menu').file_field(:name,"json").set(data_path)
$b.div(:id => 'file_menu').file_field(:name,"pref").set(analysis_path)
$b.div(:id => 'file_menu').button(:text => 'start').click
assert ( $b.div(:id => 'info').text.include? "plop") , ">> fail load analysis: wrong selected time point "
rescue
assert (false), "missing element to run test_11_load_analysis \n"
end
end
def test_12_drag_time
begin
time=$b.element(:id => "time6" )
target=$b.element(:id => "time0" )
time.fire_event("onmousedown")
$b.driver.action.click_and_hold(time.wd).perform
sleep 2
$b.driver.action.move_to(target.wd).perform
sleep 2
target.fire_event("onmouseup")
time.wd.location[0]
target.wd.location[0]
list = $b.div(:id => 'list_clones')
assert ( time.wd.location[0] < target.wd.location[0] ) , ">> fail drag/drop : wrong time order"
rescue
assert (false), "missing element to run test_12_drag_time \n"
end
end
def test_13_tag
def test_12_tag
begin
elem = $b.div(:id => 'list_clones').li(:id => '1')
elem = $b.div(:id => 'list_clones').li(:id => '0')
tagSelector = $b.div(:id => 'tagSelector')
elem.div(:class => 'starBox').click
tagSelector.span(:class => 'tagName1').click
$b.element(:id => "circle0" ).click
sleep 1
assert (elem.div(:class => 'nameBox').style('color') == 'rgba(203, 75, 22, 1)' ) , ">> fail tag : clone color hasn't changed"
tagSelector.span(:class => 'tagName0').click
$b.element(:id => "visu_back" ).click
assert (elem.div(:class => 'nameBox').style('color') == 'rgba(220, 50, 47, 1)' ) , ">> fail tag : clone color hasn't changed"
rescue
assert (false), "missing element to run test_13_tag \n"
......@@ -356,7 +286,7 @@ class Browser < MiniTest::Test
assert (false), "missing element to run test_14_edit_tag \n"
end
end
end
=begin
......@@ -372,4 +302,4 @@ end
check x/y clone position on scatterplot
check clone path
=end
\ No newline at end of file
=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