X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/351718c4524ede8442f1cc078d61ced8839440c5..38dea652d11a2a562623d80328d270707ed44887:/apps/workbench/test/integration/users_test.rb diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb index 9ee12d8086..22b92c02e1 100644 --- a/apps/workbench/test/integration/users_test.rb +++ b/apps/workbench/test/integration/users_test.rb @@ -1,6 +1,9 @@ require 'integration_helper' +require 'selenium-webdriver' +require 'headless' class UsersTest < ActionDispatch::IntegrationTest + test "login as active user but not admin" do Capybara.current_driver = Capybara.javascript_driver visit page_with_token('active_trustedclient') @@ -38,7 +41,11 @@ class UsersTest < ActionDispatch::IntegrationTest end test "create a new user" do - Capybara.current_driver = :webkit + headless = Headless.new + headless.start + + Capybara.current_driver = :selenium + visit page_with_token('admin_trustedclient') click_link 'Users' @@ -61,14 +68,19 @@ class UsersTest < ActionDispatch::IntegrationTest # verify that the new user showed up in the users page assert page.has_text? 'foo@example.com' - page.within(:xpath, '//tr[@data-object-uuid][1]') do - assert (text.include? 'foo@example.com false'), 'Expected email' - new_user_uuid = text.split[0] - - # go to the new user's page - click_link new_user_uuid + new_user_uuid = nil + all("tr").each do |elem| + if elem.text.include? 'foo@example.com' + new_user_uuid = elem.text.split[0] + break + end end + assert new_user_uuid, "Expected new user uuid not found" + + # go to the new user's page + click_link new_user_uuid + assert page.has_text? 'modified_by_user_uuid' page.within(:xpath, '//a[@data-name="is_active"]') do assert_equal "false", text, "Expected new user's is_active to be false" @@ -77,10 +89,15 @@ class UsersTest < ActionDispatch::IntegrationTest click_link 'Metadata' assert page.has_text? '(Repository: test_repo)' assert !(page.has_text? '(VirtualMachine:)') + + headless.stop end test "setup the active user" do - Capybara.current_driver = :webkit + headless = Headless.new + headless.start + + Capybara.current_driver = :selenium visit page_with_token('admin_trustedclient') click_link 'Users' @@ -97,6 +114,7 @@ class UsersTest < ActionDispatch::IntegrationTest click_link 'Setup Active User' sleep(0.1) + popup = page.driver.browser.window_handles.last page.within_window popup do assert has_text? 'Virtual Machine' @@ -129,10 +147,15 @@ class UsersTest < ActionDispatch::IntegrationTest click_link 'Metadata' assert page.has_text? '(Repository: second_test_repo)' assert page.has_text? '(VirtualMachine: testvm.shell)' + + headless.stop end test "unsetup active user" do - Capybara.current_driver = :webkit + headless = Headless.new + headless.start + + Capybara.current_driver = :selenium visit page_with_token('admin_trustedclient') @@ -160,6 +183,7 @@ class UsersTest < ActionDispatch::IntegrationTest sleep(0.1) # Should now be back in the Attributes tab for the user + page.driver.browser.switch_to.alert.accept assert page.has_text? 'modified_by_user_uuid' page.within(:xpath, '//a[@data-name="is_active"]') do assert_equal "false", text, "Expected user's is_active to be false after unsetup" @@ -188,6 +212,8 @@ class UsersTest < ActionDispatch::IntegrationTest click_link 'Metadata' assert page.has_text? '(Repository: second_test_repo)' assert page.has_text? '(VirtualMachine: testvm.shell)' + + headless.stop end end