[ARVADOS] created: 90cfbd0a9326dcbb9b58c85cbabe4d32596cf665
git at public.curoverse.com
git at public.curoverse.com
Sat Jan 3 04:09:03 EST 2015
at 90cfbd0a9326dcbb9b58c85cbabe4d32596cf665 (commit)
commit 90cfbd0a9326dcbb9b58c85cbabe4d32596cf665
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 3 01:52:34 2015 -0500
3021: Skip angular init if angular is not loaded.
diff --git a/apps/workbench/app/assets/javascripts/angular_shim.js b/apps/workbench/app/assets/javascripts/angular_shim.js
index a5366e3..72729cd 100644
--- a/apps/workbench/app/assets/javascripts/angular_shim.js
+++ b/apps/workbench/app/assets/javascripts/angular_shim.js
@@ -1,9 +1,9 @@
// Compile any new HTML content that was loaded via jQuery.ajax().
-// Currently this only works for tabs because they emit an
+// Currently this only works for tabs, and only because they emit an
// arv:pane:loaded event after updating the DOM.
$(document).on('arv:pane:loaded', function(event, $updatedElement) {
- if ($updatedElement) {
+ if (angular && $updatedElement) {
angular.element($updatedElement).injector().invoke(function($compile) {
var scope = angular.element($updatedElement).scope();
$compile($updatedElement)(scope);
commit 20bf070208aa8284bc8a8071ec2bb65252790170
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Jan 2 22:20:59 2015 -0500
3021: Silence "invalid regexp" errors while typing regexp; put input in "has-error" state instead.
diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index cd01f64..34075ca 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -83,6 +83,7 @@ $(document).
});
}).
on('paste keyup input', 'input[type=text].filterable-control', function(e) {
+ var regexp;
if (this != e.target) return;
var $target = $($(this).attr('data-filterable-target'));
var currentquery = $target.data('filterable-query');
@@ -113,9 +114,20 @@ $(document).
} else {
// Target does not have infinite-scroll capability. Just
// filter the rows in the browser using a RegExp.
+ regexp = undefined;
+ try {
+ regexp = new RegExp($(this).val(), 'i');
+ } catch(e) {
+ if (e instanceof SyntaxError) {
+ // Invalid/partial regexp. See 'has-error' below.
+ } else {
+ throw e;
+ }
+ }
$target.
+ toggleClass('has-error', regexp === undefined).
addClass('filterable-container').
- data('q', new RegExp($(this).val(), 'i')).
+ data('q', regexp).
trigger('refresh');
}
}).on('refresh', '.filterable-container', function() {
commit 3d5ffcdc1c522d8252470d9ab448e3872e0a3a58
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Jan 2 17:38:34 2015 -0500
3021: 4399: Convert some tests from selenium to phantomjs. Restart Headless less.
diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index 7bdf574..1c741bd 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -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;
diff --git a/apps/workbench/app/assets/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js
index bd68bc8..3b51faa 100644
--- a/apps/workbench/app/assets/javascripts/select_modal.js
+++ b/apps/workbench/app/assets/javascripts/select_modal.js
@@ -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}}).
diff --git a/apps/workbench/app/views/layouts/body.html.erb b/apps/workbench/app/views/layouts/body.html.erb
index 824e370..5cfa2ca 100644
--- a/apps/workbench/app/views/layouts/body.html.erb
+++ b/apps/workbench/app/views/layouts/body.html.erb
@@ -119,12 +119,12 @@
<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>
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
index 0939159..6949072 100644
--- a/apps/workbench/test/integration/application_layout_test.rb
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/collection_upload_test.rb b/apps/workbench/test/integration/collection_upload_test.rb
index 9a26373..c4dc184 100644
--- a/apps/workbench/test/integration/collection_upload_test.rb
+++ b/apps/workbench/test/integration/collection_upload_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/collections_test.rb b/apps/workbench/test/integration/collections_test.rb
index 201be6d..6999b1b 100644
--- a/apps/workbench/test/integration/collections_test.rb
+++ b/apps/workbench/test/integration/collections_test.rb
@@ -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'
diff --git a/apps/workbench/test/integration/errors_test.rb b/apps/workbench/test/integration/errors_test.rb
index ce90068..19ed7dc 100644
--- a/apps/workbench/test/integration/errors_test.rb
+++ b/apps/workbench/test/integration/errors_test.rb
@@ -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"
diff --git a/apps/workbench/test/integration/filterable_infinite_scroll_test.rb b/apps/workbench/test/integration/filterable_infinite_scroll_test.rb
index 4434f9a..90b73d5 100644
--- a/apps/workbench/test/integration/filterable_infinite_scroll_test.rb
+++ b/apps/workbench/test/integration/filterable_infinite_scroll_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/pipeline_instances_test.rb b/apps/workbench/test/integration/pipeline_instances_test.rb
index e9c84c1..313bde6 100644
--- a/apps/workbench/test/integration/pipeline_instances_test.rb
+++ b/apps/workbench/test/integration/pipeline_instances_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/projects_test.rb b/apps/workbench/test/integration/projects_test.rb
index 97e1a54..04f99c4 100644
--- a/apps/workbench/test/integration/projects_test.rb
+++ b/apps/workbench/test/integration/projects_test.rb
@@ -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'
diff --git a/apps/workbench/test/integration/report_issue_test.rb b/apps/workbench/test/integration/report_issue_test.rb
index ac9e596..7d050f4 100644
--- a/apps/workbench/test/integration/report_issue_test.rb
+++ b/apps/workbench/test/integration/report_issue_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/search_box_test.rb b/apps/workbench/test/integration/search_box_test.rb
index 9a259e2..958baf7 100644
--- a/apps/workbench/test/integration/search_box_test.rb
+++ b/apps/workbench/test/integration/search_box_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/user_agreements_test.rb b/apps/workbench/test/integration/user_agreements_test.rb
index dd263a2..dbd3950 100644
--- a/apps/workbench/test/integration/user_agreements_test.rb
+++ b/apps/workbench/test/integration/user_agreements_test.rb
@@ -1,6 +1,4 @@
require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
class UserAgreementsTest < ActionDispatch::IntegrationTest
diff --git a/apps/workbench/test/integration/user_manage_account_test.rb b/apps/workbench/test/integration/user_manage_account_test.rb
index a4defda..664bf99 100644
--- a/apps/workbench/test/integration/user_manage_account_test.rb
+++ b/apps/workbench/test/integration/user_manage_account_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/user_profile_test.rb b/apps/workbench/test/integration/user_profile_test.rb
index fd190a2..1caa571 100644
--- a/apps/workbench/test/integration/user_profile_test.rb
+++ b/apps/workbench/test/integration/user_profile_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 58432f7..5975395 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -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
diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb
index c22b3ff..6eb4d45 100644
--- a/apps/workbench/test/integration/websockets_test.rb
+++ b/apps/workbench/test/integration/websockets_test.rb
@@ -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
diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb
index febcfcf..01e3ff8 100644
--- a/apps/workbench/test/integration_helper.rb
+++ b/apps/workbench/test/integration_helper.rb
@@ -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
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list