From a15ff495c8c576378f55f58fe22ce9f3c49121e8 Mon Sep 17 00:00:00 2001 From: radhika chippada Date: Fri, 28 Mar 2014 15:21:05 -0400 Subject: [PATCH] Add users integration test class. Beginnings of setup and unsetup method tests. --- apps/workbench/test/integration/users_test.rb | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 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 new file mode 100644 index 0000000000..5c4848e000 --- /dev/null +++ b/apps/workbench/test/integration/users_test.rb @@ -0,0 +1,103 @@ +require 'integration_helper' + +class UsersTest < ActionDispatch::IntegrationTest + + test "create a new user" do + Capybara.current_driver = Capybara.javascript_driver + visit page_with_token('admin_trustedclient') + + click_link 'Users' + + assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f' + + click_on 'Add a new user' + + # for now just check that we are back in Users -> List page + assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f' + end + + test "unsetup active user" do + Capybara.current_driver = Capybara.javascript_driver + visit page_with_token('admin_trustedclient') + + click_link 'Users' + + assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz' + + # click on active user + click_link 'zzzzz-tpzed-xurymjxw79nv3jz' + assert page.has_text? 'Attributes' + assert page.has_text? 'Metadata' + assert page.has_text? 'Admin' + + # 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 + assert_equal text, "true", "Expected user's is_active to be true" + end + + # go to Admin tab + click_link 'Admin' + assert page.has_text? 'As an admin, you can deactivate and reset this user' + + # Click on Deactivate button + click_button 'Deactivate Active User' + + # Click Ok in the confirm dialog + sleep(0.1) + + popup = page.driver.window_handles.last + page.within_window popup do + assert has_text? 'Are you sure you want to deactivate Active User' + click_button "Ok" + end + + # Should now be back in the Attributes tab for the user + assert page.has_text? 'modified_by_user_uuid' + page.within(:xpath, '//a[@data-name="is_active"]') do + assert_equal text, "false", "Expected user's is_active to be false after unsetup" + end + + end + + test "setup the active user" do + Capybara.current_driver = Capybara.javascript_driver + visit page_with_token('admin_trustedclient') + + click_link 'Users' + + assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz' + + # click on active user + click_link 'zzzzz-tpzed-xurymjxw79nv3jz' + assert page.has_text? 'Attributes' + assert page.has_text? 'Metadata' + assert page.has_text? 'Admin' + + # go to Admin tab + click_link 'Admin' + assert page.has_text? 'As an admin, you can deactivate and reset this user' + +=begin + # Click on Setup button + click_button 'Setup Active User' + + # Click Ok in the confirm dialog + sleep(0.1) + + popup = page.driver.window_handles.last + page.within_window popup do + assert has_text? 'Are you sure you want to deactivate Active User' + fill_in "email", :with => "test@example.com" + click_button "Ok" + end + + # Should now be back in the Attributes tab for the user + assert page.has_text? 'modified_by_client_uuid' + + puts "\n\n************* page now = \n#{page.body}" +=end + end + +end -- 2.30.2