X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2908852ef9d52b12eb715474c5f31e35f7c44b18..3063c6106a83102214deb9d86ec621c0bb85d4b7:/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 7555e3a8d2..06d420c569 100644 --- a/apps/workbench/test/integration/users_test.rb +++ b/apps/workbench/test/integration/users_test.rb @@ -1,7 +1,9 @@ require 'integration_helper' -require "selenium-webdriver" +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') @@ -29,17 +31,21 @@ class UsersTest < ActionDispatch::IntegrationTest # go to the Attributes tab click_link 'Attributes' assert page.has_text? 'modified_by_user_uuid' - page.within(:xpath, '//a[@data-name="is_active"]') do + page.within(:xpath, '//span[@data-name="is_active"]') do assert_equal "true", text, "Expected user's is_active to be true" end - page.within(:xpath, '//a[@data-name="is_admin"]') do + page.within(:xpath, '//span[@data-name="is_admin"]') do assert_equal "false", text, "Expected user's is_admin to be false" end end test "create a new user" do + headless = Headless.new + headless.start + Capybara.current_driver = :selenium + visit page_with_token('admin_trustedclient') click_link 'Users' @@ -47,7 +53,7 @@ class UsersTest < ActionDispatch::IntegrationTest assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f' click_link 'Add a new user' - + sleep(0.1) popup = page.driver.browser.window_handles.last page.within_window popup do @@ -58,29 +64,39 @@ class UsersTest < ActionDispatch::IntegrationTest end sleep(0.1) - + # 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 + page.within(:xpath, '//span[@data-name="is_active"]') do assert_equal "false", text, "Expected new user's is_active to be false" end click_link 'Metadata' assert page.has_text? '(Repository: test_repo)' assert !(page.has_text? '(VirtualMachine:)') + + headless.stop end test "setup the active user" do + headless = Headless.new + headless.start + Capybara.current_driver = :selenium visit page_with_token('admin_trustedclient') @@ -98,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' @@ -105,7 +122,7 @@ class UsersTest < ActionDispatch::IntegrationTest click_button "Submit" end - sleep(0.1) + sleep(1) assert page.has_text? 'modified_by_client_uuid' click_link 'Metadata' @@ -130,9 +147,14 @@ 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 + headless = Headless.new + headless.start + Capybara.current_driver = :selenium visit page_with_token('admin_trustedclient') @@ -147,7 +169,7 @@ class UsersTest < ActionDispatch::IntegrationTest # Verify that is_active is set click_link 'Attributes' assert page.has_text? 'modified_by_user_uuid' - page.within(:xpath, '//a[@data-name="is_active"]') do + page.within(:xpath, '//span[@data-name="is_active"]') do assert_equal "true", text, "Expected user's is_active to be true" end @@ -158,12 +180,12 @@ class UsersTest < ActionDispatch::IntegrationTest # unsetup user and verify all the above links are deleted click_link 'Admin' click_button 'Deactivate Active User' - page.driver.browser.switch_to.alert.accept 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 + page.within(:xpath, '//span[@data-name="is_active"]') do assert_equal "false", text, "Expected user's is_active to be false after unsetup" end @@ -190,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