1 require 'integration_helper'
3 class UsersTest < ActionDispatch::IntegrationTest
5 test "create a new user" do
6 Capybara.current_driver = Capybara.javascript_driver
7 visit page_with_token('admin_trustedclient')
11 assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
13 click_on 'Add a new user'
15 # for now just check that we are back in Users -> List page
16 assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
19 test "unsetup active user" do
20 Capybara.current_driver = Capybara.javascript_driver
21 visit page_with_token('admin_trustedclient')
25 assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
27 # click on active user
28 click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
29 assert page.has_text? 'Attributes'
30 assert page.has_text? 'Metadata'
31 assert page.has_text? 'Admin'
33 # go to the Attributes tab
34 click_link 'Attributes'
35 assert page.has_text? 'modified_by_user_uuid'
36 page.within(:xpath, '//a[@data-name="is_active"]') do
37 assert_equal text, "true", "Expected user's is_active to be true"
42 assert page.has_text? 'As an admin, you can deactivate and reset this user'
44 # Click on Deactivate button
45 click_button 'Deactivate Active User'
47 # Click Ok in the confirm dialog
50 popup = page.driver.window_handles.last
51 page.within_window popup do
52 assert has_text? 'Are you sure you want to deactivate Active User'
56 # Should now be back in the Attributes tab for the user
57 assert page.has_text? 'modified_by_user_uuid'
58 page.within(:xpath, '//a[@data-name="is_active"]') do
59 assert_equal text, "false", "Expected user's is_active to be false after unsetup"
64 test "setup the active user" do
65 Capybara.current_driver = Capybara.javascript_driver
66 visit page_with_token('admin_trustedclient')
70 assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
72 # click on active user
73 click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
74 assert page.has_text? 'Attributes'
75 assert page.has_text? 'Metadata'
76 assert page.has_text? 'Admin'
80 assert page.has_text? 'As an admin, you can deactivate and reset this user'
83 # Click on Setup button
84 click_button 'Setup Active User'
86 # Click Ok in the confirm dialog
89 popup = page.driver.window_handles.last
90 page.within_window popup do
91 assert has_text? 'Are you sure you want to deactivate Active User'
92 fill_in "email", :with => "test@example.com"
96 # Should now be back in the Attributes tab for the user
97 assert page.has_text? 'modified_by_client_uuid'
99 puts "\n\n************* page now = \n#{page.body}"