// 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;
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;
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}}).
<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>
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
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
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'
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
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
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
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
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']
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}")
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}/"))
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']
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']
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
[
['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")
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
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
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']}")
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'
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"
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
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
# 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"),
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')
[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
['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'
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')
# 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")
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
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
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
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'
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
# 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'
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
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
require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
class UserAgreementsTest < ActionDispatch::IntegrationTest
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
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
require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
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')
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
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')
# 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"
click_link 'Metadata'
assert page.has_text? 'Repository: second_test_repo'
assert page.has_text? 'VirtualMachine: testvm.shell'
-
- headless.stop
end
end
require 'integration_helper'
-require 'selenium-webdriver'
-require 'headless'
class WebsocketTest < ActionDispatch::IntegrationTest
-
setup do
- headless = Headless.new
- headless.start
Capybara.current_driver = :selenium
end
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