Skip to content
Snippets Groups Projects
Commit a844421e authored by Hernandez-Courbevoie Yohan's avatar Hernandez-Courbevoie Yohan
Browse files

Remove tests and bug fixes

CI/CD tests are removed from PAMPA web.

Correction of texte in the retrieve result parts.

Fixed a bug in which spectra were not displayed if the page was loaded
by an ajax request.
parent e1b7ad0b
Branches
No related tags found
No related merge requests found
stages:
- build
build-job:
stage: build
script:
- echo "passed"
tags:
- bws
# stages:
# - build
# - test
# build-job:
# stage: build
# script:
# - git clone https://github.com/touzet/pampa.git
# - docker build -t pampa:web .
# - docker run -dtp 82:80 pampa:web
# tags:
# - bws
# test-home:
# stage: test
# script:
# - ruby tests/test_home.rb
# tags:
# - bws
# test-form:
# stage: test
# script:
# - ruby tests/test_form.rb
# tags:
# - bws
# test-help:
# stage: test
# script:
# - ruby tests/test_help.rb
# tags:
# - bws
# test-analysis:
# stage: test
# script:
# - ruby tests/test_analysis.rb
# tags:
# - bws
# -- Packages --
require 'rubygems'
# require 'webdrivers'
require 'watir'
require 'test/unit'
require 'open-uri'
require 'email_address'
puts "=========================================================================="
puts " Testing PAMPA Web"
puts "=========================================================================="
$browsers = [
"Watir::Browser.new :chrome, options: {args: ['--no-sandbox']}",
"Watir::Browser.new :firefox, options: {args: ['--no-sandbox']}"
]
$form_url = "http://localhost:82/pampa/form.php"
class PampaWebAnalyseTest < Test::Unit::TestCase
def test_01_result_page
puts "* result - Launch page result (1/4)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# launch analysis
e = br.button(id: 'example_1')
assert(e.present?)
e.click
e = br.button(id: 'run')
assert(e.present?)
e.click
br.wait_until {|b| b.url != $form_url}
# check content
e = br.url
assert(/http:\/\/localhost:82\/pampa\/result\/[A-Za-z0-9_]+\/results\.php/ =~ e)
e = br.h2
assert(e.present? && (e.text.include? "Results for job"))
es = br.elements(css: '#result_pampa td')
assert(es.size == 80)
assert(es[1].text == "Castor canadensis" && es[14].text == "8.09E-10")
e = br.h3
assert(e.present? && e.text == "Download")
es = br.elements(css: "h3 + ul li")
assert(es.size == 4)
br.close
end
end
def test_02_result_links
puts "* result - Buttons and links result (2/4)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# launch analysis
e = br.button(id: 'example_1')
assert(e.present?)
e.click
e = br.button(id: 'run')
assert(e.present?)
e.click
br.wait_until {|b| b.url != $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
br.close
end
end
def test_03_details_simple_page
puts "* result - Launch page details simple (3/4)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# launch analysis
e = br.button(id: 'example_1')
assert(e.present?)
e.click
e = br.button(id: 'run')
assert(e.present?)
e.click
br.wait_until {|b| b.url != $form_url}
# launch details page
e = br.elements(css: '#result_pampa td')[1]
assert(e.present?)
e.click
Watir::Wait.until { br.windows.size == 2 }
handles = br.windows.map(&:handle)
window = br.window(handle: handles[1])
window.use
# check content
e = br.url
assert(/http:\/\/localhost:82\/pampa\/result\/[A-Za-z0-9_]+\/details_Castor-TOF\.php/ =~ e)
e = br.h2
e.text # ODD Avoid firefox from crashing
assert(e.present? && (/Results for job [A-Za-z0-9_]+( \([A-Za-z0-9_]+\))?\nMass spectrum Castor-TOF\.csv/ =~ e.text))
assert(br.text.include? "Taxonomic group : Castor canadensis (species)")
es = br.tds
assert(es.size == 56 && es[1].text == "1177.59461")
e = br.div(css: '[data-root-id]')
assert(e.present?)
br.close
end
end
def test_04_details_multiple_page
puts "* result - Launch page details multiple (4/4)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# launch analysis
e = br.button(id: 'example_1')
assert(e.present?)
e.click
e = br.button(id: 'run')
assert(e.present?)
e.click
br.wait_until {|b| b.url != $form_url}
# launch details page
e = br.elements(css: '#result_pampa td')[56]
assert(e.present?)
e.click
Watir::Wait.until { br.windows.size == 2 }
handles = br.windows.map(&:handle)
window = br.window(handle: handles[1])
window.use
# check content
e = br.url
assert(/http:\/\/localhost:82\/pampa\/result\/[A-Za-z0-9_]+\/details_Whale-TOF\.php/ =~ e)
e = br.h2
e.text # Need to call `element.text` before assert to prevent firefox from crashing
assert(e.present? && (/Results for job [A-Za-z0-9_]+( \([A-Za-z0-9_]+\))?\nMass spectrum Whale-TOF\.csv/ =~ e.text))
assert(br.text.include? "Taxonomic group : Globicephala melas (species), with P-value 6.32E-16")
es = br.tds
assert(es.size == 234)
assert(es[176].text == "652")
assert(br.text.include? "GPSGEPGTAGSPGTPGPQGLLGAPGFLGLPGSR")
es = br.divs(css: '[data-root-id]')
assert(es.size == 3)
br.close
end
end
end
# -- Packages --
require 'rubygems'
# require 'webdrivers'
require 'watir'
require 'test/unit'
require 'open-uri'
require 'email_address'
puts "=========================================================================="
puts " Testing PAMPA Web"
puts "=========================================================================="
$browsers = [
"Watir::Browser.new :chrome, options: {args: ['--no-sandbox']}",
"Watir::Browser.new :firefox, options: {args: ['--no-sandbox']}"
]
$form_url = "http://localhost:82/pampa/form.php"
class PampaWebFormTest < Test::Unit::TestCase
def test_01_launch_page
puts "* pampa/form.php - Launch page (1/5)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# check text
e = br.element(id: 'title')
assert(e.present? && (e.text == "Pampa"))
e = br.element(class: 'onglet_left')
assert(e.present? && e.text == "Pampa")
assert(br.text.include? "Mass spectra")
assert(br.table(class: 'pampa_choice').present?)
assert(br.button(id: 'run').present?)
br.close
end
end
def test_02_buttons_links
puts "* pampa/form.php - Buttons and links (2/5)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
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
br.close
end
end
def test_03_display
puts "* pampa/form.php - Normal display (3/5)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# check options
e = br.checkbox(name: 'spectra_example_1')
assert(e.exists? && !(e.set?))
e = br.radio(name: 'error_margin_selection', value: 'MALDI_TOF')
assert(e.exists? && e.set?)
e = br.radio(id: 'reference_source_default')
assert(e.exists? && !(e.set?))
e = br.radio(id: 'reference_source_user')
assert(e.exists? && !(e.set?))
e = br.checkbox(name: 'taxonomic_group_selection', value: 'mammals')
assert(e.exists? && e.set?)
e = br.checkbox(name: 'ptm_deamidation', value: 'deamidation')
assert(e.exists? && e.set?)
e = br.radio(name: 'nearoptimal_selection', value: 'optimal')
assert(e.exists? && e.set?)
# check hidden elements
e = br.tr(id: 'spectra_input')
assert(e.present?)
e = br.tr(id: 'spectra_example')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_reference_source_default')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_reference_source_user')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_results')
assert(e.exists? && !(e.visible?))
br.close
end
end
def test_04_interactions
puts "* pampa/form.php - Js interactions (4/5)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# check basic mode
e = br.radio(id: 'reference_source_default')
assert(e.exists?)
e.click
e = br.div(id: 'block_reference_source_default')
assert(e.present?)
e = br.div(id: 'block_reference_source_user')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_results')
assert(e.present?)
# check reset button
e = br.button(id: "reset")
assert(e.present?)
e.click
e = br.tr(id: 'spectra_input')
assert(e.present?)
e = br.tr(id: 'spectra_example')
assert(e.exists? && !(e.visible?))
e = br.checkbox(name: 'spectra_example_1')
assert(e.exists? && !(e.set?))
e = br.radio(name: 'error_margin_selection', value: 'MALDI_TOF')
assert(e.present? && e.set?)
e = br.radio(id: 'reference_source_default')
assert(e.present? && !(e.set?))
e = br.radio(id: 'reference_source_user')
assert(e.present? && !(e.set?))
e = br.checkbox(name: 'taxonomic_group_selection', value: 'mammals')
assert(e.exists? && e.set?)
e = br.checkbox(name: 'ptm_deamidation', value: 'deamidation')
assert(e.exists? && e.set?)
e = br.radio(name: 'nearoptimal_selection', value: 'optimal')
assert(e.exists? && e.set?)
e = br.div(id: 'block_reference_source_default')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_reference_source_user')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_results')
assert(e.exists? && !(e.visible?))
# check advanced mode
e = br.radio(id: 'reference_source_user')
assert(e.exists?)
e.click
e = br.div(id: 'block_reference_source_default')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_reference_source_user')
assert(e.present?)
e = br.div(id: 'block_results')
assert(e.present?)
br.close
end
end
def test_05_example
puts "* pampa/form.php - Example (5/5)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $form_url
# example button effect (form)
e = br.button(id: 'example_1')
assert(e.present?)
e.click
# visibility
e = br.checkbox(name: 'spectra_example_1')
assert(e.exists? && !e.visible? && e.set?)
e = br.button(id: 'back_to_normal')
assert(e.present?)
e = br.tr(id: 'spectra_input')
assert(e.exists? && !(e.visible?))
e = br.radio(name: 'error_margin_selection', value: 'MALDI_TOF')
assert(e.present? && e.set?)
e = br.radio(id: 'reference_source_default')
assert(e.present? && e.set?)
e = br.div(id: 'block_reference_source_default')
assert(e.present?)
e = br.div(id: 'block_reference_source_user')
assert(e.exists? && !(e.visible?))
e = br.div(id: 'block_results')
assert(e.present?)
# parameters
e = br.text_field(name: 'job_name')
assert(e.present? && e.value == "example_1")
e = br.checkbox(name: 'taxonomic_group_selection', value: 'mammals')
assert(e.exists? && e.set?)
es = br.inputs(css: '[list="taxonomic_node_list"]')
assert(es.size == 1)
e = es[0]
assert(e.present? && e.value == "")
e = br.checkbox(name: 'ptm_deamidation', value: 'deamidation')
assert(e.exists? && e.set?)
e = br.radio(name: 'nearoptimal_selection', value: 'optimal')
assert(e.exists? && e.set?)
# custom upload after example
br.button(id: 'back_to_normal').click
e = br.tr(id: 'spectra_input')
assert(e.present?)
e = br.tr(id: 'spectra_example')
assert(e.exists? && !(e.visible?))
e = br.checkbox(name: 'spectra_example_1')
assert(e.exists? && !(e.set?))
e = br.text_field(name: 'job_name')
assert(e.present? && e.value != "example_1")
br.close
end
end
end
# -- Packages --
require 'rubygems'
# require 'webdrivers'
require 'watir'
require 'test/unit'
require 'open-uri'
require 'email_address'
puts "=========================================================================="
puts " Testing PAMPA Web"
puts "=========================================================================="
$browsers = [
"Watir::Browser.new :chrome, options: {args: ['--no-sandbox']}",
"Watir::Browser.new :firefox, options: {args: ['--no-sandbox']}"
]
$help_url = "http://localhost:82/pampa/help.php"
class PampaWebHelpTest < Test::Unit::TestCase
def test_01_launch_page
puts "* pampa/help.php - Launch page (1/2)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $help_url
# check text
e = br.element(id: 'title')
assert(e.present? && (e.text == "Pampa"))
e = br.element(class: 'onglet_right')
assert(e.present? && e.text == "Help")
assert(br.text.include? "Peptide markers are organized within peptide tables")
assert(br.element(id: 'PTM_description').present?)
br.close
end
end
def test_02_buttons_links
puts "* pampa/help.php - Buttons and links (2/2)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $help_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
br.close
end
end
end
# -- Packages --
require 'rubygems'
# require 'webdrivers'
require 'watir'
require 'test/unit'
require 'open-uri'
require 'email_address'
puts "=========================================================================="
puts " Testing PAMPA Web"
puts "=========================================================================="
$browsers = [
"Watir::Browser.new :chrome, options: {args: ['--no-sandbox']}",
"Watir::Browser.new :firefox, options: {args: ['--no-sandbox']}"
]
$home_url = "http://localhost:82/pampa/"
class PampaWebHomeTest < Test::Unit::TestCase
def test_01_launch_page
puts "* pampa - Launch page (1/2)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $home_url
# check text
e = br.element(id: 'title')
assert(e.present? && (e.text == "Pampa"))
e = br.element(class: 'onglet_left')
assert(e.present? && e.text == "Pampa")
assert(br.text.include? "PAMPA is available in two versions.")
br.close
end
end
def test_02_buttons_links
puts "* pampa - Buttons and links (2/2)"
$browsers.each do |br_string|
puts br_string
br = eval(br_string)
br.goto $home_url
# check links
br.div(id: 'center').as.each do |link|
assert(link.href != "")
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:") # mails
email = link.href[7..-1]
assert(EmailAddress.valid? email)
else
puts '- "' + link.href + '" not tested'
end
end
br.close
end
end
end
......@@ -148,9 +148,9 @@ def write_main_page(run_id, taxo_used, job_name=None):
html += ('<br>')
# Come back later
html += '<h3>You want to come back later ?</h3>'
html += '<p>Your result stay available for at least one month.</p>'
html += f'<p>To access it, you can either save the url or <a id="copy" data-copy="{run_id}">copy</a> the ID {run_id}.</p>'
html += '<h3>Retrieve results with an ID</h3>'
html += '<p>Your result remains available for at least one month.</p>'
html += f'<p>To access it, you can either save the url or <a id="copy" data-copy="{run_id}">copy the ID</a> {run_id}.</p>'
html += ('<br>')
# Insert page footer
......
<ul id="menu">
<li class="onglet onglet_left">
<a href="/pampa/" class="mc aLoad">pampa</a>
<a href="/pampa/" class="mc">pampa</a>
</li>
<li class="onglet">
<a href="/pampa/form.php" class="mc aLoad" >web server</a>
<a href="/pampa/form.php" class="mc" >web server</a>
</li>
<li class="onglet">
<a href="/pampa/help.php" class="mc aLoad" >help</a>
<a href="/pampa/help.php" class="mc" >help</a>
</li>
<li class="onglet onglet_right">
<a href="/pampa/result.php" class="mc aLoad" >retrieve result with an ID</a>
<a href="/pampa/result.php" class="mc" >retrieve result with an ID</a>
</li>
</ul>
......@@ -27,8 +27,8 @@
</p-->
<h2>Retrieve analysis results</h2>
<p>Results are saved for a minimum of one month.</p>
<p>They can be accessed directly via their link if it have been saved. Otherwise, you can enter your run ID in the field below.</p>
<p>Results remain available for at least one month.</p>
<p>They can be accessed directly via their link if it has been saved. Otherwise, you can enter your ID in the field below.</p>
<form id="retrieve" method="post" enctype="multipart/form-data">
<table class="vide pampa-choice">
<tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment