Commit 41a2b9b6 authored by flothoni's avatar flothoni

tests server; add new function to get login user name and password

Also update functions that need it
add a new function 'create_user' to automaticaly create a new user
parent c714dd49
Pipeline #247454 failed with stages
in 25 minutes and 32 seconds
......@@ -585,6 +585,16 @@ class VidjilBrowser < Watir::Browser
end
return false
end
def delete_group(grp_name)
go_to_groups
line = get_group_line(grp_name)
i(:class => "icon-erase", :title => "delete group").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
if div(:text => /Are you sure you want to delete this group/).present?
button(:text => "continue").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
end
end
def add_user_to_group(user_name)
# make it from a group open with invite list
select_list(:id => "select_user").select(user_name)
......@@ -614,8 +624,20 @@ class VidjilBrowser < Watir::Browser
return
end
end
end
def create_user(first_name, last_name, email, password)
$b.go_to_users
$b.element(:class => "button2", :text => "+ new user").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.fill_form_register_user(first_name, last_name, email, password)
$b.register_user_table.element(:value => "Sign Up").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
assert( $b.h3(:text => /user info/).present? )
end
def new_form
return form(:id => "data_form")
......
......@@ -29,7 +29,7 @@ class LiveTestSampleSets < ServerTest
# set_browser("http://app.vidjil.org/browser")
set_browser("https://localhost/browser/")
end
$b.login('dev.server@local.org', 'devtest1234')
$b.login(logins("admin", "user"), logins("admin", "password"))
end
def go_to_list_patient
......
......@@ -9,44 +9,33 @@ class LiveTestSampleSets < ServerTest
# set_browser("http://app.vidjil.org/browser")
set_browser("https://localhost/browser/")
end
$b.login('dev.admin@local.org', 'devadmintest1234')
$b.login(logins("admin", "user"), logins("admin", "password"))
$b.go_to_groups()
if $b.get_group_line("test_group")
$b.delete_group("test_group")
end
end
def test_00_demo_logged_in
# login_form = $b.form(:id => 'login_form')
assert(!$b.login_form.present?)
end
# def test_01_change_password
def test_01_create_users
## Add first user
$b.go_to_users
$b.element(:class => "button2", :text => "+ new user").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.fill_form_register_user("first_name", "last_name", "email@local.org", "password")
$b.register_user_table.element(:value => "Sign Up").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
assert( $b.h3(:text => /user info/).present? )
# add second user
$b.go_to_users
$b.element(:class => "button2", :text => "+ new user").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.fill_form_register_user("first_name2", "last_name2", "email2@local.org", "password2")
$b.register_user_table.element(:value => "Sign Up").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
assert( $b.h3(:text => /user info/).present? )
## Add users
$b.create_user(logins("user0", "first"), logins("user0", "last"), logins("user0", "user"), logins("user0", "password"))
$b.create_user(logins("user1", "first"), logins("user1", "last"), logins("user1", "user"), logins("user1", "password"))
$b.create_user(logins("user2", "first"), logins("user2", "last"), logins("user2", "user"), logins("user2", "password"))
end
def test_02_land
# $b.go_to_user_groups("email@local.org")
$b.go_to_users
$b.go_to_user_groups("email@local.org")
$b.go_to_user_groups(logins("user1", "user"))
table_grp_of_user = $b.table(:id => "table")
lines = table_grp_of_user.tbody.rows
......@@ -73,7 +62,7 @@ class LiveTestSampleSets < ServerTest
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.set_grp_right("anon", true) # remove anon
$b.add_user_to_group("first_name last_name")
$b.add_user_to_group(logins("user1", "first")+" "+logins("user1", "last"))
table_grp_of_user = $b.table(:id => "table")
lines = table_grp_of_user.tbody.rows
assert( lines.length == 2 )
......@@ -81,7 +70,7 @@ class LiveTestSampleSets < ServerTest
def test_04_user_have_three_group
$b.go_to_users
$b.go_to_user_groups("email@local.org")
$b.go_to_user_groups(logins("user2", "user"))
table_grp_of_user = $b.table(:id => "table")
lines = table_grp_of_user.tbody.rows
......@@ -92,7 +81,7 @@ class LiveTestSampleSets < ServerTest
# when add a new patient, new group is selectable
# impersonate user1
$b.impersonate(/first_name last_name/)
$b.impersonate(/first_name1 last_name1/)
$b.a(:class => "button button_token patient_token", :text => "patients").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
......@@ -135,7 +124,7 @@ class LiveTestSampleSets < ServerTest
$b.get_group_line("test_group").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.add_user_to_group("first_name2 last_name2")
$b.add_user_to_group(logins("user2", "first") +" "+logins("user2", "last")) #"first_name2 last_name2")
table_grp_of_user = $b.table(:id => "table")
lines = table_grp_of_user.tbody.rows
assert( lines.length == 3 )
......@@ -172,233 +161,7 @@ class LiveTestSampleSets < ServerTest
$b.go_to_news
$b.news_add("Header", "Informations", "une new", "un contenu de new", "2022-01-01")
end
# $b.i(:title => "Edit my personal informations").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# new_password = "test_password_new"
# $b.edit_user_table.text_field(:id => "password").set(new_password)
# $b.edit_user_table.text_field(:id => "confirm_password").set(new_password)
# $b.edit_user_table.element(:value => "save").click
# assert(!$b.edit_user_table.present?)
# end
# def test_02_logout
# $b.logout()
# # "login form is present after logout call"
# assert($b.login_form.present?)
# end
# def test_03_relogin_with_new_password
# new_password = "test_password_new"
# old_password = 'devtest1234'
# $b.login('dev.test@local.org', new_password)
# assert(!$b.login_form.present?)
# $b.i(:title => "Edit my personal informations").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# $b.edit_user_table.text_field(:id => "password").set(old_password)
# $b.edit_user_table.text_field(:id => "confirm_password").set(old_password)
# $b.edit_user_table.element(:value => "save").click
# assert(!$b.edit_user_table.present?)
# end
# def go_to_list_patient
# $b.a(:class => "button button_token patient_token", :text => "patients").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# table = $b.table(:id => "table")
# table.wait_until_present
# table
# end
# def test_101_demo_patients
# table = $b.go_to_list_patient
# lines = table.tbody.rows
# puts "Demo sees %s patients." % lines.count
# assert(lines.count >= 4)
# assert(lines.count <= 1500)
# end
# def test_102_demo_patients_search
# filter = $b.text_field(:id => "db_filter_input")
# filter.wait_until_present
# filter.set('LIL-L3')
# filter.fire_event('onchange')
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# table = $b.table(:id => "table")
# table.wait_until_present
# lines = table.tbody.rows
# puts "Searching for 'LIL-L3', Demo sees %s patients." % lines.count
# assert(lines.count == 2)
# end
# def test_103_add_new_patient
# $b.a(:class => "button button_token patient_token", :text => "patients").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# $b.element(:class => "button2", :text => "+ new patients").click
# $b.fill_patient_form(0, "patient_test_id", "First_name", "Last_name", "2000-01-01", "quelques informations #tagtest")
# $b.set_add_form.input(:type => 'submit').click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# # contrôle; on arrive directement sur la page de ce patient
# assert( $b.span(:class => ["set_token", "patient_token"]).present? )
# assert( $b.span(:class => ["set_token", "patient_token"]).text == "Last_name First_name" )
# # automatic switch after that on patient page
# end
# def test_104_add_sample
# $b.go_to_list_patient
# $b.span(:class => ["set_token", "patient_token"], :text => "Last_name First_name").click
# assert( $b.div(:class => "db_block_left", :text => "patient_test_id (2000-01-01)") )
# $b.element(:class => "button2", :text => "+ add samples").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# # change source for file (if available)
# if $b.element(:type => "radio", :id => "source_computer").present?
# $b.element(:type => "radio", :id => "source_computer").click
# end
# $b.fill_sample_form(0, "2010-01-01", "Sample from functional test #functional", "Stanford_S22.fasta", nil)
# $b.input(:id => "submit_samples_btn").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# # return on patient table
# assert( $b.div(:class => "db_block_left", :text => "patient_test_id (2000-01-01)") )
# table = $b.table(:id => "table")
# lines = table.tbody.rows
# assert( lines.length == 1) # only one sample present
# end
# def test_105_edit_patient
# $b.i(:title => "edit information").click
# $b.fill_patient_form(0, "patient_test_id_mod", "First_name_mod", "Last_name_mod", "2001-01-01", "quelques informations #tagtest #tagtestmod")
# $b.set_add_form.input(:type => 'submit').click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# assert( $b.span(:class => ["set_token", "patient_token"]).present? )
# assert( $b.span(:class => ["set_token", "patient_token"]).text == "Last_name_mod First_name_mod" )
# assert( $b.div(:class => "db_block_left", :text => "patient_test_id_mod (2001-01-01)").present? )
# end
# # def test_110_upload_data
# # $b.select_list(:id, "choose_config").select_value("2")
# # $b.i(:class => "icon-cog-2").click
# # table = $b.table(:id => "table")
# # assert( table.present?)
# # line = table.tbody.rows[0]
# # # print line.inner_html
# # line.element(:class => "button", :text => "QUEUED").wait_until_present
# # assert( line.element(:class => "button", :text => "QUEUED").present? )
# # def wait_and_reload(timeout, repeatition)
# # repeatition.times do
# # print "new repeatition"
# # $b.span(:id => "db_reload").click
# # table = $b.table(:id => "table")
# # line = table.tbody.rows[0]
# # sleep timeout
# # if line.element(:class => "button", :text => "COMPLETED").present?
# # return true
# # end
# # end
# # return false
# # end
# # completed = wait_and_reload(10, 30)
# # assert( completed == true)
# # end
# def test_111_edit_sample_file
# $b.go_to_list_patient
# $b.span(:class => ["set_token", "patient_token"], :text => "Last_name_mod First_name_mod").click
# $b.db_table_container.i(:class => ["icon-pencil-2"], :title => "edit sample information").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# $b.set_selected_preprocess("1 – flash r2")
# $b.fill_sample_form(0, "2010-01-01", "Sample from functional test #functional", "Stanford_S22.fasta", "Stanford_S22.fasta")
# $b.input(:id => "submit_samples_btn").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# # control new col preprocess
# assert( $b.db_table_container.td(:text => "pre-process").present? )
# assert( $b.db_table_container.td(:text => "[queued] flash r2").present? )
# sleep 10 # ?
# $b.span(:id => "db_reload").click
# $b.db_table_container.span(:text => "try again").click
# $b.span(:id => "db_reload").click
# assert( $b.db_table_container.td(:text => "[queued] flash r2").present? )
# sleep 10 # ?
# $b.span(:id => "db_reload").click
# assert( $b.db_table_container.td(:text => "[failed] try again flash r2").present? )
# end
# def test_116_delete_patient
# $b.go_to_list_patient
# filter = $b.text_field(:id => "db_filter_input")
# filter.wait_until_present
# filter.set('#tagtestmod')
# filter.fire_event('onchange')
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# table = $b.table(:id => "table")
# table.wait_until_present
# lines = table.tbody.rows
# puts "Searching for 'tagtestmod', Demo sees %s patients." % lines.count
# assert(lines.count == 1)
# # deletion
# $b.i(:class => "icon-erase", :title => "delete patient").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# assert( $b.span(:class => ["set_token", "patient_token"], :text => "Last_name_mod First_name_mod").present? )
# $b.button(:text => "delete").click
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# filter.wait_until_present
# filter.set('#tagtestmod')
# filter.fire_event('onchange')
# Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
# table = $b.table(:id => "table")
# assert( table.present?)
# # lines = table.tbody.rows
# # puts "Searching for 'tagtestmod', %s after deletion." % lines.length
# # assert(lines.count == 0)
# end
end
......@@ -9,7 +9,7 @@ class LiveTestSampleSets < ServerTest
# set_browser("http://app.vidjil.org/browser")
set_browser("https://localhost/browser/")
end
$b.login('dev.test@local.org', 'devtest1234')
$b.login(logins("admin", "user"), logins("admin", "password"))
end
......@@ -36,15 +36,16 @@ class LiveTestSampleSets < ServerTest
end
def test_031_relogin_with_old_password
new_password = "test_password_new"
old_password = 'devtest1234'
user = logins("user0", "password")
new_password = logins("user0", "new_password")
old_password = logins("user0", "password")
# old password should not work anymore
$b.login('dev.test@local.org', old_password)
$b.login(user, old_password)
assert($b.login_form.present?)
# new password should work
$b.login('dev.test@local.org', new_password)
$b.login(user, new_password)
assert(!$b.login_form.present?)
# Revert password to old for futur tests
......
......@@ -5,5 +5,15 @@ class ServerTest < BrowserTest
File.expand_path(File.join(File.dirname(__FILE__), filename))
end
end
def logins(user, field)
data = { "admin" => {"user" => "plop@plop.com", "password" => "foobartest"},
"user0" => {"user" => "email0@local.org", "password" => "password0", "first" => "first_name0", "last" => "last_name0", "new_password" => "password0mod"},
"user1" => {"user" => "email1@local.org", "password" => "password1", "first" => "first_name1", "last" => "last_name1"},
"user2" => {"user" => "email2@local.org", "password" => "password2", "first" => "first_name2", "last" => "last_name2"}
}
return data.fetch(user).fetch(field)
end
end
\ No newline at end of file
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