+ click_link 'Add a new user'
+
+ within '.modal-content' do
+ find 'label', text: 'Virtual Machine'
+ fill_in "email", :with => "foo@example.com"
+ click_button "Submit"
+ wait_for_ajax
+ end
+
+ visit '/users'
+
+ # verify that the new user showed up in the users page and find
+ # the new user's UUID
+ new_user_uuid =
+ find('tr[data-object-uuid]', text: 'foo@example.com')['data-object-uuid']
+ assert new_user_uuid, "Expected new user uuid not found"
+
+ # go to the new user's page
+ find('tr', text: new_user_uuid).
+ find('a', text: 'Show').
+ click
+
+ assert page.has_text? 'modified_by_user_uuid'
+ 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 'Advanced'
+ click_link 'Metadata'
+ assert page.has_text? 'can_login' # make sure page is rendered / ready
+ assert page.has_no_text? 'VirtualMachine:'
+ end
+
+ test "setup the active user" do
+ need_javascript
+ visit page_with_token('admin_trustedclient')
+
+ find('#system-menu').click
+ click_link 'Users'
+
+ # click on active user
+ find('tr', text: 'zzzzz-tpzed-xurymjxw79nv3jz').
+ find('a', text: 'Show').
+ click
+ user_url = page.current_url
+
+ # Setup user
+ click_link 'Admin'
+ assert page.has_text? 'As an admin, you can setup'
+
+ click_link 'Setup shell account for Active User'
+
+ within '.modal-content' do
+ find 'label', text: 'Virtual Machine'
+ click_button "Submit"
+ end
+
+ visit user_url
+ assert page.has_text? 'modified_by_client_uuid'
+
+ click_link 'Advanced'
+ click_link 'Metadata'
+ vm_links = all("a", text: "VirtualMachine:")
+ assert_equal(1, vm_links.size)
+ assert_equal("VirtualMachine: testvm2.shell", vm_links.first.text)
+
+ # Click on Setup button again and this time also choose a VM
+ click_link 'Admin'
+ click_link 'Setup shell account for Active User'
+
+ within '.modal-content' do
+ select("testvm.shell", :from => 'vm_uuid')
+ fill_in "groups", :with => "test group one, test-group-two"
+ click_button "Submit"
+ end
+
+ visit user_url
+ find '#Attributes', text: 'modified_by_client_uuid'
+
+ click_link 'Advanced'
+ click_link 'Metadata'
+ assert page.has_text? 'VirtualMachine: testvm.shell'
+ assert page.has_text? '["test group one", "test-group-two"]'