[ARVADOS] updated: 203958b587d05ba1be437a70609a80b35f79368d

git at public.curoverse.com git at public.curoverse.com
Thu Apr 3 22:43:32 EDT 2014


Summary of changes:
 apps/workbench/test/integration/users_test.rb |  104 ++++++++++++-------------
 1 files changed, 51 insertions(+), 53 deletions(-)

       via  203958b587d05ba1be437a70609a80b35f79368d (commit)
      from  29c890d0ac617ec3b06976fc07c7328624e90af5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 203958b587d05ba1be437a70609a80b35f79368d
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Thu Apr 3 22:41:42 2014 -0400

    Added integration tests for create new user, setup and unsetup existing user. The tests use selenium driver without headless. Hence, we see the browser while these tests are running.
    
    Next step is to use headless to hide the browser during test execution.

diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 1576c04..7555e3a 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,9 +1,7 @@
 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')
@@ -41,7 +39,7 @@ class UsersTest < ActionDispatch::IntegrationTest
   end
 
   test "create a new user" do
-    Capybara.current_driver = Capybara.javascript_driver
+    Capybara.current_driver = :selenium
     visit page_with_token('admin_trustedclient')
 
     click_link 'Users'
@@ -50,64 +48,36 @@ class UsersTest < ActionDispatch::IntegrationTest
 
     click_link 'Add a new user'
     
-    # for now just check that we are back in Users -> List page
-    assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
-  end
-
-  #@headless
-  test "unsetup active user" do
-    Capybara.current_driver = Capybara.javascript_driver
-    #Capybara.current_driver = :selenium
-
-    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'
-
-    # 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
-      assert_equal "true", text, "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
-=begin
-#use with selenium
-    page.driver.browser.switch_to.alert.accept
     sleep(0.1)
     popup = page.driver.browser.window_handles.last
-    #popup = page.driver.browser.window_handle
     page.within_window popup do
-      assert has_text? 'Are you sure you want to deactivate'
-      click_button "OK"
+      assert has_text? 'Virtual Machine'
+      fill_in "email", :with => "foo at example.com"
+      fill_in "repo_name", :with => "test_repo"
+      click_button "Submit"
     end
 
-# use with poltergeist driver
-popup = page.driver.window_handles.last
-page.within_window popup do
-  #fill_in "email", :with => "my_email"
-  assert has_text? 'Are you sure you want to deactivate'
-  click_button "OK"
-end
-=end
+    sleep(0.1)
+    
+    # verify that the new user showed up in the users page
+    assert page.has_text? 'foo at example.com'
+
+    page.within(:xpath, '//tr[@data-object-uuid][1]') do
+      assert (text.include? 'foo at example.com false'), 'Expected email'
+      new_user_uuid = text.split[0]
+
+      # go to the new user's page
+      click_link new_user_uuid
+    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 "false", text, "Expected user's is_active to be false after unsetup"
+      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:)')
   end
 
   test "setup the active user" do
@@ -160,6 +130,30 @@ end
     click_link 'Metadata'
     assert page.has_text? '(Repository: second_test_repo)'
     assert page.has_text? '(VirtualMachine: testvm.shell)'
+  end
+
+  test "unsetup active user" do
+    Capybara.current_driver = :selenium
+
+    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'
+
+    # 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
+      assert_equal "true", text, "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'
 
     # unsetup user and verify all the above links are deleted
     click_link 'Admin'
@@ -167,7 +161,11 @@ end
     page.driver.browser.switch_to.alert.accept
     sleep(0.1)
 
-#    popup = page.driver.browser.window_handles.last
+    # 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 "false", text, "Expected user's is_active to be false after unsetup"
+    end
 
     click_link 'Metadata'
     assert !(page.has_text? '(Repository: test_repo)')

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list