3021: 4399: Convert some tests from selenium to phantomjs. Restart Headless less.
authorTom Clegg <tom@curoverse.com>
Fri, 2 Jan 2015 22:38:34 +0000 (17:38 -0500)
committerTom Clegg <tom@curoverse.com>
Sat, 3 Jan 2015 03:21:42 +0000 (22:21 -0500)
18 files changed:
apps/workbench/app/assets/javascripts/infinite_scroll.js
apps/workbench/app/assets/javascripts/select_modal.js
apps/workbench/app/views/layouts/body.html.erb
apps/workbench/test/integration/application_layout_test.rb
apps/workbench/test/integration/collection_upload_test.rb
apps/workbench/test/integration/collections_test.rb
apps/workbench/test/integration/errors_test.rb
apps/workbench/test/integration/filterable_infinite_scroll_test.rb
apps/workbench/test/integration/pipeline_instances_test.rb
apps/workbench/test/integration/projects_test.rb
apps/workbench/test/integration/report_issue_test.rb
apps/workbench/test/integration/search_box_test.rb
apps/workbench/test/integration/user_agreements_test.rb
apps/workbench/test/integration/user_manage_account_test.rb
apps/workbench/test/integration/user_profile_test.rb
apps/workbench/test/integration/users_test.rb
apps/workbench/test/integration/websockets_test.rb
apps/workbench/test/integration_helper.rb

index 7bdf574ed9964802d6dab2b011ad3d8ca8b7fd1d..1c741bd614045783587411788ac3b706cc4bbf11 100644 (file)
@@ -241,8 +241,8 @@ $(document).
         // put it in the browser history state if browser allows it
         if( hasHTML5History() ) {
             var tabId = $(this).closest('div.tab-pane').attr('id');
-            var state =  history.state;
-            if( state.order === undefined) {
+            var state =  history.state || {};
+            if( state.order === undefined ) {
                 state.order = {};
             }
             state.order[tabId] = order;
index bd68bc8a2facf92e0769b3ccec9dc9cd384e8aba..3b51faad6a8b67c5dde1b174c1f02410e17677b4 100644 (file)
@@ -49,6 +49,7 @@ $(document).on('click', '.selectable', function() {
     var selection = [];
     var data = [];
     var $modal = $(this).closest('.modal');
+    var http_method = $(this).attr('data-method').toUpperCase();
     var action_data = $(this).data('action-data');
     var action_data_from_params = $(this).data('action-data-from-params');
     var selection_param = action_data.selection_param;
@@ -75,9 +76,17 @@ $(document).on('click', '.selectable', function() {
                    data.push({name: key, value: value});
                }
            });
+    if (http_method === 'PATCH') {
+        // Some user agents do not support HTTP PATCH (notably,
+        // phantomjs silently ignores our "data" and sends an empty
+        // request body) so we use POST instead, and supply a
+        // _method=PATCH param to tell Rails what we really want.
+        data.push({name: '_method', value: http_method});
+        http_method = 'POST';
+    }
     $.ajax($(this).attr('data-action-href'),
            {dataType: 'json',
-            type: $(this).attr('data-method'),
+            type: http_method,
             data: data,
             traditional: false,
             context: {modal: $modal, action_data: action_data}}).
index 824e370c582d6ad2ea80f12ac8b342bb099a2464..5cfa2ca373c79f7708f63f77b65dc547adab5f42 100644 (file)
               <li><%= link_to raw('<i class="fa fa-book fa-fw"></i> SDK Reference'), "#{Rails.configuration.arvados_docsite}/sdk", target: "_blank" %></li>
               <li role="presentation" class="divider"></li>
               <li> <%= link_to report_issue_popup_path(popup_type: 'version', current_location: request.url, current_path: request.fullpath, action_method: 'post'),
-                      {class: 'report-issue-modal-window',  :remote => true, return_to: request.url} do %>
+                      {class: 'report-issue-modal-window', remote: true, return_to: request.url} do %>
                        <i class="fa fa-fw fa-support"></i> Show version / debugging info ...
                       <% end %>
               </li>
               <li> <%= link_to report_issue_popup_path(popup_type: 'report', current_location: request.url, current_path: request.fullpath, action_method: 'post'),
-                      {class: 'report-issue-modal-window', :remote => true, return_to: request.url} do %>
+                      {class: 'report-issue-modal-window', remote: true, return_to: request.url} do %>
                        <i class="fa fa-fw fa-support"></i> Report a problem ...
                       <% end %>
               </li>
index 093915905498f9cd529690614e36f54751119813..6949072f71112c64bd66d281aff531b647aabe91 100644 (file)
@@ -1,6 +1,4 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class ApplicationLayoutTest < ActionDispatch::IntegrationTest
   # These tests don't do state-changing API calls. Save some time by
@@ -9,9 +7,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
   reset_api_fixtures :after_suite, true
 
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   def verify_homepage user, invited, has_profile
index 9a2637365cedc66ce3d20715d4c301c1cd2850a4..c4dc184acdd9f38423bbe1e4321009a41b538888 100644 (file)
@@ -20,7 +20,7 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest
   end
 
   test "Create new collection using upload button" do
-    Capybara.current_driver = :poltergeist
+    Capybara.current_driver = Capybara.javascript_driver
     visit page_with_token 'active', aproject_path
     find('.btn', text: 'Add data').click
     click_link 'Upload files from my computer'
@@ -32,13 +32,14 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest
   end
 
   test "No Upload tab on non-writable collection" do
-    Capybara.current_driver = :poltergeist
+    Capybara.current_driver = Capybara.javascript_driver
     visit(page_with_token 'active',
           '/collections/'+api_fixture('collections')['user_agreement']['uuid'])
     assert_no_selector '.nav-tabs Upload'
   end
 
   test "Upload two empty files with the same name" do
+    # Selenium is needed because poltergeist/phantomjs can't do file uploads.
     Capybara.current_driver = :selenium
     visit page_with_token 'active', sandbox_path
     find('.nav-tabs a', text: 'Upload').click
@@ -53,6 +54,7 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest
   end
 
   test "Upload non-empty files, report errors" do
+    # Selenium is needed because poltergeist/phantomjs can't do file uploads.
     Capybara.current_driver = :selenium
     visit page_with_token 'active', sandbox_path
     find('.nav-tabs a', text: 'Upload').click
@@ -60,7 +62,7 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest
     attach_file 'file_selector', testfile_path('foo.txt')
     assert_selector 'button:not([disabled])', text: 'Start'
     click_button 'Start'
-    if "test environment does not have a keepproxy yet, see #4534"
+    if "test environment does not have a keepproxy yet, see #4534" != "fixed"
       using_wait_time 20 do
         assert_text :visible, 'error'
       end
index 201be6d77696671b022bca6cd44f0aa03e8dd9d3..6999b1bb928654f21c7ee1670ab458c074de98a3 100644 (file)
@@ -1,10 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class CollectionsTest < ActionDispatch::IntegrationTest
   setup do
-    Capybara.current_driver = :rack_test
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   # check_checkboxes_state asserts that the page holds at least one
@@ -18,8 +16,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "Can copy a collection to a project" do
-    Capybara.current_driver = Capybara.javascript_driver
-
     collection_uuid = api_fixture('collections')['foo_file']['uuid']
     collection_name = api_fixture('collections')['foo_file']['name']
     project_uuid = api_fixture('groups')['aproject']['uuid']
@@ -35,6 +31,7 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "Collection page renders name" do
+    Capybara.current_driver = :rack_test
     uuid = api_fixture('collections')['foo_file']['uuid']
     coll_name = api_fixture('collections')['foo_file']['name']
     visit page_with_token('active', "/collections/#{uuid}")
@@ -62,7 +59,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "creating and uncreating a sharing link" do
-    Capybara.current_driver = Capybara.javascript_driver
     coll_uuid = api_fixture("collections", "collection_owned_by_active", "uuid")
     download_link_re =
       Regexp.new(Regexp.escape("/collections/download/#{coll_uuid}/"))
@@ -74,6 +70,7 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "can download an entire collection with a reader token" do
+    Capybara.current_driver = :rack_test
     CollectionsController.any_instance.
       stubs(:file_enumerator).returns(["foo\n", "file\n"])
     uuid = api_fixture('collections')['foo_file']['uuid']
@@ -105,16 +102,13 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "can view empty collection" do
+    Capybara.current_driver = :rack_test
     uuid = 'd41d8cd98f00b204e9800998ecf8427e+0'
     visit page_with_token('active', "/collections/#{uuid}")
     assert page.has_text?(/This collection is empty|The following collections have this content/)
   end
 
   test "combine selected collections into new collection" do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
     foo_collection = api_fixture('collections')['foo_file']
     bar_collection = api_fixture('collections')['bar_file']
 
@@ -144,7 +138,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     assert(page.has_text?('bar'), "Collection page did not include bar file")
     assert(page.has_text?('Created new collection in your Home project'),
                           'Not found flash message that new collection is created in Home project')
-    headless.stop
   end
 
   [
@@ -154,10 +147,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     ['project_viewer', 'foo_collection_in_aproject', false], #aproject not writable
   ].each do |user, collection, expect_collection_in_aproject|
     test "combine selected collection files into new collection #{user} #{collection} #{expect_collection_in_aproject}" do
-      headless = Headless.new
-      headless.start
-      Capybara.current_driver = :selenium
-
       my_collection = api_fixture('collections')[collection]
 
       visit page_with_token(user, "/collections")
@@ -187,16 +176,10 @@ class CollectionsTest < ActionDispatch::IntegrationTest
         assert page.has_text?("Created new collection in your Home project"),
                               'Not found flash message that new collection is created in Home project'
       end
-
-      headless.stop
     end
   end
 
   test "combine selected collection files from collection subdirectory" do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
     visit page_with_token('user1_with_load', "/collections/zzzzz-4zz18-filesinsubdir00")
 
     # now in collection page
@@ -216,8 +199,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     assert(page.has_text?('file2_in_subdir3.txt'), 'file not found - file2_in_subdir3.txt')
     assert(page.has_text?('file1_in_subdir4.txt'), 'file not found - file1_in_subdir4.txt')
     assert(page.has_text?('file2_in_subdir4.txt'), 'file not found - file1_in_subdir4.txt')
-
-    headless.stop
   end
 
   test "Collection portable data hash redirect" do
@@ -246,9 +227,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "Filtering collection files by regexp" do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
     col = api_fixture('collections', 'multilevel_collection_1')
     visit page_with_token('active', "/collections/#{col['uuid']}")
 
@@ -327,10 +305,6 @@ class CollectionsTest < ActionDispatch::IntegrationTest
   end
 
   test "Creating collection from list of filtered files" do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
     col = api_fixture('collections', 'collection_with_files_in_subdir')
     visit page_with_token('user1_with_load', "/collections/#{col['uuid']}")
     assert page.has_text?('file_in_subdir1'), 'expected file_in_subdir1 not found'
index ce90068b9676c2a840d8f7c7853cd5e2f97d4cb2..19ed7dca684f8b1a460e560220fc82a642fc687d 100644 (file)
@@ -1,12 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class ErrorsTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   BAD_UUID = "ffffffffffffffffffffffffffffffff+0"
index 4434f9a5772b56dcddb8b873858ad53641807f17..90b73d5e9cd4695ed39e4b6a4d8221cae19de73c 100644 (file)
@@ -2,9 +2,7 @@ require 'integration_helper'
 
 class FilterableInfiniteScrollTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   # Chrome remembers what you had in the text field when you hit
index e9c84c158b945bf0d589a0da11a8614ccdae1c3c..313bde64ec2b223d594f993ede632158ad60b31d 100644 (file)
@@ -1,13 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class PipelineInstancesTest < ActionDispatch::IntegrationTest
   setup do
-    # Selecting collections requiresLocalStorage
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   test 'Create and run a pipeline' do
@@ -69,8 +64,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
 
     # The input, after being specified, should still be editable (#3382)
     find('div.form-group', text: 'Foo/bar pair').
-      find('.btn', text: 'Choose').
-      click
+      find('.btn', text: 'Choose').click
 
     within('.modal-dialog') do
       assert(has_text?("Foo/bar pair"),
@@ -79,7 +73,6 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       first('span', text: 'foo_tag').click
       find('button', text: 'OK').click
     end
-    wait_for_ajax
 
     # For good measure, check one last time that the input, after being specified twice, is still be displayed (#3382)
     assert find('div.form-group', text: 'Foo/bar pair')
@@ -230,14 +223,16 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
     [true, 'Two Part Pipeline Template', 'collection_with_no_name_in_aproject', false],
   ].each do |in_aproject, template_name, collection, choose_file|
     test "Run pipeline instance in #{in_aproject} with #{template_name} with #{collection} file #{choose_file}" do
-      visit page_with_token('active')
+      if in_aproject
+        visit page_with_token 'active', \
+        '/projects/'+api_fixture('groups')['aproject']['uuid']
+      else
+        visit page_with_token 'active', '/'
+      end
 
       # need bigger modal size when choosing a file from collection
-      Capybara.current_session.driver.browser.manage.window.resize_to(1024, 768)
-
-      if in_aproject
-        find("#projects-menu").click
-        find('.dropdown-menu a,button', text: 'A Project').click
+      if Capybara.current_driver == :selenium
+        Capybara.current_session.driver.browser.manage.window.resize_to(1200, 800)
       end
 
       create_and_run_pipeline_in_aproject in_aproject, template_name, collection, choose_file
@@ -271,14 +266,16 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
     ['project_viewer', true, true, true],
   ].each do |user, with_options, choose_options, in_aproject|
     test "Rerun pipeline instance as #{user} using options #{with_options} #{choose_options} in #{in_aproject}" do
-      visit page_with_token('active')
+      if in_aproject
+        visit page_with_token 'active', \
+        '/projects/'+api_fixture('groups')['aproject']['uuid']
+      else
+        visit page_with_token 'active', '/'
+      end
 
       # need bigger modal size when choosing a file from collection
-      Capybara.current_session.driver.browser.manage.window.resize_to(1024, 768)
-
-      if in_aproject
-        find("#projects-menu").click
-        find('.dropdown-menu a,button', text: 'A Project').click
+      if Capybara.current_driver == :selenium
+        Capybara.current_session.driver.browser.manage.window.resize_to(1200, 800)
       end
 
       create_and_run_pipeline_in_aproject in_aproject, 'Two Part Pipeline Template', 'foo_collection_in_aproject'
@@ -374,7 +371,6 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       end
       find('button', text: 'OK').click
     end
-    wait_for_ajax
 
     # The input, after being specified, should still be displayed (#3382)
     assert find('div.form-group', text: 'Foo/bar pair')
@@ -383,6 +379,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
     # are saved in the desired places. (#4015)
     click_link 'Advanced'
     click_link 'API response'
+
     api_response = JSON.parse(find('div#advanced_api_response pre').text)
     input_params = api_response['components']['part-one']['script_parameters']['input']
     assert_equal(input_params['selection_uuid'], collection['uuid'], "Not found expected input param uuid")
@@ -462,7 +459,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       page_scrolls = expected_max/20 + 2    # scroll num_pages+2 times to test scrolling is disabled when it should be
       within('.arv-recent-pipeline-instances') do
         (0..page_scrolls).each do |i|
-          page.execute_script "window.scrollBy(0,999000)"
+          page.driver.scroll_to 0, 999000
           begin
             wait_for_ajax
           rescue
index 97e1a542bafcfad5f7a7e930c48c21f9417ec149..04f99c493aced7371efd53c9dafc0fc9cc2f0f5c 100644 (file)
@@ -1,15 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class ProjectsTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
-    # project tests need bigger page size to be able to see all the buttons
-    Capybara.current_session.driver.browser.manage.window.resize_to(1152, 768)
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   test 'Check collection count for A Project in the tab pane titles' do
@@ -226,7 +219,11 @@ class ProjectsTest < ActionDispatch::IntegrationTest
       assert(has_link?("Write"),
              "failed to change access level on new share")
       click_on "Revoke"
-      page.driver.browser.switch_to.alert.accept
+      if Capybara.current_driver == :selenium
+        page.driver.browser.switch_to.alert.accept
+      else
+        # poltergeist returns true for confirm(), so we don't need to accept.
+      end
     end
     wait_for_ajax
     using_wait_time(Capybara.default_wait_time * 3) do
@@ -485,8 +482,11 @@ class ProjectsTest < ActionDispatch::IntegrationTest
       assert_selector 'li', text: 'Remove selected'
     end
 
+    # Close the dropdown by clicking outside it.
+    find('.dropdown-toggle', text: 'Selection').find(:xpath, '..').click
+
     # Go back to Data collections tab
-    click_link 'Data collections'
+    find('.nav-tabs a', text: 'Data collections').click
     click_button 'Selection'
     within('.selection-action-container') do
       assert_no_selector 'li.disabled', text: 'Create new collection with selected collections'
index ac9e596f8cb65053b6a217646757c5db2288ad80..7d050f43537680da5b44a166b6901a40cea4baec 100644 (file)
@@ -1,13 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class ReportIssueTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
+    Capybara.current_driver = Capybara.javascript_driver
     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
   end
 
@@ -17,9 +12,9 @@ class ReportIssueTest < ActionDispatch::IntegrationTest
 
   # test version info and report issue from help menu
   def check_version_info_and_report_issue_from_help_menu
-    within('.navbar-fixed-top') do
-      page.find("#arv-help").click
-      within('.dropdown-menu') do
+    within '.navbar-fixed-top' do
+      find('.help-menu > a').click
+      within '.help-menu .dropdown-menu' do
         assert page.has_link?('Tutorials and User guide'), 'No link - Tutorials and User guide'
         assert page.has_link?('API Reference'), 'No link - API Reference'
         assert page.has_link?('SDK Reference'), 'No link - SDK Reference'
@@ -47,11 +42,9 @@ class ReportIssueTest < ActionDispatch::IntegrationTest
     end
 
     # check report issue link
-    within('.navbar-fixed-top') do
-      page.find("#arv-help").click
-      within('.dropdown-menu') do
-        click_link 'Report a problem ...'
-      end
+    within '.navbar-fixed-top' do
+      find('.help-menu > a').click
+      find('.help-menu .dropdown-menu a', text: 'Report a problem ...').click
     end
 
     within '.modal-content' do
index 9a259e2703b510a39599d98f9e59ea697f838993..958baf749b0fb57c1d0e95f27d477f15334b99f2 100644 (file)
@@ -1,12 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class SearchBoxTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   # test the search box
index dd263a25845a7f91240d0e034d1e7c75dc8f1f08..dbd395094466034ee84dc84c747214fa7c27c7aa 100644 (file)
@@ -1,6 +1,4 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class UserAgreementsTest < ActionDispatch::IntegrationTest
 
index a4defda806fcc9357683ce8ceb760d77fc0a24ff..664bf991b6bd1b0019efd1395808cd3a967b5f73 100644 (file)
@@ -1,12 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class UserManageAccountTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
   end
 
   # test manage_account page
index fd190a2042f48ad7e3de340ce6016e63733db473..1caa5719dbac9fbe4d105d3d85c7d1163228e2b9 100644 (file)
@@ -1,13 +1,8 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class UserProfileTest < ActionDispatch::IntegrationTest
   setup do
-    headless = Headless.new
-    headless.start
-    Capybara.current_driver = :selenium
-
+    Capybara.current_driver = Capybara.javascript_driver
     @user_profile_form_fields = Rails.configuration.user_profile_form_fields
   end
 
index 58432f7d5e13108115802afce78ad2ee884dd04a..5975395ed2b28b38f636550c5e71fc2937b8aad4 100644 (file)
@@ -1,6 +1,4 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class UsersTest < ActionDispatch::IntegrationTest
 
@@ -44,10 +42,7 @@ class UsersTest < ActionDispatch::IntegrationTest
   end
 
   test "create a new user" do
-    headless = Headless.new
-    headless.start
-
-    Capybara.current_driver = :selenium
+    Capybara.current_driver = Capybara.javascript_driver
 
     visit page_with_token('admin_trustedclient')
 
@@ -88,15 +83,10 @@ class UsersTest < ActionDispatch::IntegrationTest
     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
+    Capybara.current_driver = Capybara.javascript_driver
     visit page_with_token('admin_trustedclient')
 
     find('#system-menu').click
@@ -145,15 +135,10 @@ 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
+    Capybara.current_driver = Capybara.javascript_driver
 
     visit page_with_token('admin_trustedclient')
 
@@ -180,11 +165,15 @@ class UsersTest < ActionDispatch::IntegrationTest
     # unsetup user and verify all the above links are deleted
     click_link 'Admin'
     click_button 'Deactivate Active User'
-    sleep(0.1)
 
-    # Should now be back in the Attributes tab for the user
-    page.driver.browser.switch_to.alert.accept
+    if Capybara.current_driver == :selenium
+      sleep(0.1)
+      page.driver.browser.switch_to.alert.accept
+    else
+      # poltergeist returns true for confirm(), so we don't need to accept.
+    end
 
+    # Should now be back in the Attributes tab for the user
     assert page.has_text? 'modified_by_user_uuid'
     page.within(:xpath, '//span[@data-name="is_active"]') do
       assert_equal "false", text, "Expected user's is_active to be false after unsetup"
@@ -213,8 +202,6 @@ 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
index c22b3ff58fc79bd941809f603bb113232d5b7445..6eb4d458a9f8b38ea9012a4249562a1fb150d0ca 100644 (file)
@@ -1,12 +1,7 @@
 require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
 
 class WebsocketTest < ActionDispatch::IntegrationTest
-
   setup do
-    headless = Headless.new
-    headless.start
     Capybara.current_driver = :selenium
   end
 
index febcfcfec0eb2c87122ba00594dfffc9a3958d37..01e3ff88645f846af2cab5cdfb9056407ee85aa1 100644 (file)
@@ -4,6 +4,16 @@ require 'capybara/poltergeist'
 require 'uri'
 require 'yaml'
 
+Capybara.register_driver :poltergeist do |app|
+  Capybara::Poltergeist::Driver.new app, {
+    window_size: [1200, 800],
+    phantomjs_options: ['--ignore-ssl-errors=true'],
+    inspector: true,
+  }
+end
+
+Headless.new.start
+
 module WaitForAjax
   Capybara.default_wait_time = 5
   def wait_for_ajax