Skip to content
Snippets Groups Projects
Commit 742f7784 authored by Hottlet Valentin's avatar Hottlet Valentin
Browse files

Add Watir tests for new pages and update existing test scripts

parent 1e3f7224
No related branches found
No related tags found
1 merge request!8Tests docker
......@@ -71,6 +71,20 @@ tests-page-result:
tags:
- val
tests-page-selection:
stage: watir:tests-pages
script:
- docker run --rm --network pampa_web_default -v "$PWD:/pampa_web" -w /pampa_web watir-test-image ruby tests/watir/page/page_selection.rb
tags:
- val
tests-page-deamidation:
stage: watir:tests-pages
script:
- docker run --rm --network pampa_web_default -v "$PWD:/pampa_web" -w /pampa_web watir-test-image ruby tests/watir/page/page_deamidation.rb
tags:
- val
tests-analysis-classify:
stage: watir:tests-analysis
script:
......
......@@ -29,7 +29,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_01_launch_page
puts "* pampa/craft-allpeptides.php - Launch page (1/5)"
puts "* pampa/craft-allpeptides.php - Launch page (1/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -50,12 +50,18 @@ class PampaWebTest < Test::Unit::TestCase
e = br.file_field(name: 'sequences_files')
assert(e.present?)
assert(br.text.include? "Configuration")
assert(br.select(name: 'digestion', value: 'trypsine'))
e = br.text_field(name: 'minimum_prop_peaks')
assert(e.present?)
assert(br.button(id: 'run').present?)
end
end
def test_02_buttons_links
puts "* pampa/craft-allpeptides.php - Buttons and links (2/5)"
puts "* pampa/craft-allpeptides.php - Buttons and links (2/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -75,7 +81,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_03_display
puts "* pampa/craft-allpeptides.php - Normal display (3/5)"
puts "* pampa/craft-allpeptides.php - Normal display (3/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -88,7 +94,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_04_example
puts "* pampa/craft-allpeptides.php - Example (4/5)"
puts "* pampa/craft-allpeptides.php - Example (4/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -100,7 +106,7 @@ class PampaWebTest < Test::Unit::TestCase
br.button(id: 'reset-craft-a').click
e = br.text_field(name: 'job_name')
assert(e.value != "example_fillin")
assert(e.value != "example_allpeptides")
end
end
end
\ No newline at end of file
require 'watir'
require 'test/unit'
require 'open-uri'
require 'selenium-webdriver'
class PampaWebTest < Test::Unit::TestCase
def setup
@browsers = []
@browsers << Watir::Browser.new(:chrome, options: { args: ['--no-sandbox', '--headless']})
#Selenium::WebDriver::Firefox::Service.driver_path = '/snap/bin/geckodriver'
options = Selenium::WebDriver::Firefox::Options.new(args: ['--no-sandbox', '--headless'])
@browsers << Watir::Browser.new(:firefox, options: options)
#@browsers << Watir::Browser.new(:edge, options: { args: ['--no-sandbox']})
@form_url = "http://pampa/pampa/craft-deamidation.php"
end
def teardown
@browsers.each do |br|
begin
br.close if br.is_a?(Watir::Browser)
rescue => e
puts "Erreur fermeture navigateur: #{e.message}"
end
end
end
def test_01_launch_page
puts "* pampa/craft-selection.php - Launch page (1/4)"
@browsers.each do |br|
br.goto @form_url
e = br.element(id: 'title')
assert(e.present? && (e.text == "Pampa-Craft"))
assert(br.text.include? "Peptide Table")
e = br.file_field(name: 'peptides_file')
assert(e.present?)
assert(br.text.include? "limit file")
e = br.file_field(name: 'limit_file')
assert(e.present?)
assert(br.button(id: 'run').present?)
end
end
def test_02_buttons_links
puts "* pampa/craft-selection.php - Buttons and links (2/4)"
@browsers.each do |br|
br.goto @form_url
# check links
br.div(id: 'center').as.each do |link|
if link.href.start_with?("http") # web links
status_code = URI.open(link.href).status[0]
assert(status_code=='200')
elsif link.href.start_with?("mailto:")
email = link.href[7..-1]
assert(EmailAddress.valid? email)
else
puts '- "' + link.href + '" not tested'
end
end
end
end
def test_03_display
puts "* pampa/craft-selection.php - Normal display (3/4)"
@browsers.each do |br|
br.goto @form_url
e = br.checkbox(name: 'craft-example')
assert(e.exists? && !e.set?)
end
end
def test_04_example
puts "* pampa/craft-selection.php - Example (4/4)"
@browsers.each do |br|
br.goto @form_url
br.button(id: 'example-deamidation').click
e = br.checkbox(name: 'craft-example')
assert(e.exists? && e.set?)
br.button(id: 'reset-craft-d').click
e = br.text_field(name: 'job_name')
assert(e.value != "example_deamidation")
end
end
end
\ No newline at end of file
......@@ -29,7 +29,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_01_launch_page
puts "* pampa/craft-fillin.php - Launch page (1/5)"
puts "* pampa/craft-fillin.php - Launch page (1/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -57,6 +57,9 @@ class PampaWebTest < Test::Unit::TestCase
assert(br.radio(name: 'taxonomy_selection', value: 'no').present?)
assert(br.radio(name: 'taxonomy_selection', value: 'default').present?)
assert(br.text.include? "Configuration")
assert(br.select(name: 'digestion', value: 'trypsine'))
assert(br.button(id: 'example-fillin').present?)
assert(br.button(id: 'reset-craft-f').present?)
assert(br.button(id: 'run').present?)
......@@ -64,7 +67,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_02_buttons_links
puts "* pampa/craft-fillin.php - Buttons and links (2/5)"
puts "* pampa/craft-fillin.php - Buttons and links (2/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -84,7 +87,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_03_display
puts "* pampa/craft-fillin.php - Normal display (3/5)"
puts "* pampa/craft-fillin.php - Normal display (3/4)"
@browsers.each do |br|
br.goto @form_url
......@@ -100,7 +103,7 @@ class PampaWebTest < Test::Unit::TestCase
end
def test_04_example
puts "* pampa/craft-fillin.php - Example (4/5)"
puts "* pampa/craft-fillin.php - Example (4/4)"
@browsers.each do |br|
br.goto @form_url
......
......@@ -53,6 +53,9 @@ class PampaWebTest < Test::Unit::TestCase
assert(br.radio(name: 'taxonomy_selection', value: 'no').present?)
assert(br.radio(name: 'taxonomy_selection', value: 'default').present?)
assert(br.text.include? "Configuration")
assert(br.select(name: 'digestion', value: 'trypsine'))
assert(br.button(id: 'example-homology').present?)
assert(br.button(id: 'reset-craft-h').present?)
assert(br.button(id: 'run').present?)
......
require 'watir'
require 'test/unit'
require 'open-uri'
require 'selenium-webdriver'
class PampaWebTest < Test::Unit::TestCase
def setup
@browsers = []
@browsers << Watir::Browser.new(:chrome, options: { args: ['--no-sandbox', '--headless']})
#Selenium::WebDriver::Firefox::Service.driver_path = '/snap/bin/geckodriver'
options = Selenium::WebDriver::Firefox::Options.new(args: ['--no-sandbox', '--headless'])
@browsers << Watir::Browser.new(:firefox, options: options)
#@browsers << Watir::Browser.new(:edge, options: { args: ['--no-sandbox']})
@form_url = "http://pampa/pampa/craft-selection.php"
end
def teardown
@browsers.each do |br|
begin
br.close if br.is_a?(Watir::Browser)
rescue => e
puts "Erreur fermeture navigateur: #{e.message}"
end
end
end
def test_01_launch_page
puts "* pampa/craft-selection.php - Launch page (1/4)"
@browsers.each do |br|
br.goto @form_url
e = br.element(id: 'title')
assert(e.present? && (e.text == "Pampa-Craft"))
assert(br.text.include? "Mass spectra")
e = br.file_field(name: 'spectra_files')
assert(e.present?)
assert(br.text.include? "Mass error")
assert(br.radio(name: 'error_margin_selection', value: 'MALDI_TOF').present?)
assert(br.radio(name: 'error_margin_selection', value: 'MALDI_FTICR').present?)
assert(br.radio(name: 'error_margin_selection', value: 'ppm').present?)
assert(br.radio(name: 'error_margin_selection', value: 'daltons').present?)
assert(br.text.include? "Peptide Table")
e = br.file_field(name: 'peptides_file')
assert(e.present?)
e = br.text_field(name: 'minimum_prop_peaks')
assert(e.present?)
assert(br.button(id: 'run').present?)
end
end
def test_02_buttons_links
puts "* pampa/craft-selection.php - Buttons and links (2/4)"
@browsers.each do |br|
br.goto @form_url
# check links
br.div(id: 'center').as.each do |link|
if link.href.start_with?("http") # web links
status_code = URI.open(link.href).status[0]
assert(status_code=='200')
elsif link.href.start_with?("mailto:")
email = link.href[7..-1]
assert(EmailAddress.valid? email)
else
puts '- "' + link.href + '" not tested'
end
end
end
end
def test_03_display
puts "* pampa/craft-selection.php - Normal display (3/4)"
@browsers.each do |br|
br.goto @form_url
e = br.checkbox(name: 'craft-example')
assert(e.exists? && !e.set?)
e = br.radio(name: 'error_margin_selection', value: 'MALDI_TOF')
assert(e.selected?)
end
end
def test_04_example
puts "* pampa/craft-selection.php - Example (4/4)"
@browsers.each do |br|
br.goto @form_url
br.button(id: 'example-selection').click
e = br.checkbox(name: 'craft-example')
assert(e.exists? && e.set?)
br.button(id: 'reset-craft-s').click
e = br.text_field(name: 'job_name')
assert(e.value != "example_selection")
end
end
end
\ No newline at end of file
......@@ -45,7 +45,7 @@
<input type="file" name="peptides_file" value="file" accept=".tsv" required/>
</td>
</tr>
<tr id="peptide_example" style="display: none;">
<tr id="craft_example" style="display: none;">
<td>
<input class="file_input" id="back_to_normal" type="button" value="Parcourir..."/>
craft-example.tsv
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment