From: Tom Clegg Date: Wed, 21 May 2014 06:59:51 +0000 (-0400) Subject: 2754: Add integration test, fix selection bugs. X-Git-Tag: 1.1.0~2603^2~6^2~3 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/89096c06922b406f7157082de410e40960f5c73e 2754: Add integration test, fix selection bugs. --- diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js index 3209d67782..26a0c3e2fd 100644 --- a/apps/workbench/app/assets/javascripts/pipeline_instances.js +++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js @@ -9,37 +9,39 @@ function run_pipeline_button_state() { } $(document).on('editable:success', function(event, tag, response, newValue) { + var $tag = $(tag); if ($('.run-pipeline-button').length == 0) return; - tag = $(tag); - if (tag.hasClass("required")) { + if ($tag.hasClass("required")) { if (newValue && newValue.trim() != "") { - tag.removeClass("editable-empty"); - tag.parent().css("background-color", ""); - tag.parent().prev().css("background-color", ""); + $tag.removeClass("editable-empty"); + $tag.parent().css("background-color", ""); + $tag.parent().prev().css("background-color", ""); } else { - tag.addClass("editable-empty"); - tag.parent().css("background-color", "#ffdddd"); - tag.parent().prev().css("background-color", "#ffdddd"); + $tag.addClass("editable-empty"); + $tag.parent().css("background-color", "#ffdddd"); + $tag.parent().prev().css("background-color", "#ffdddd"); } } - if (tag.attr('data-name')) { + if ($tag.attr('data-name')) { // Update other inputs representing the same piece of data - $('[data-name="' + tag.attr('data-name') + '"]').html(newValue); + $('.editable[data-name="' + $tag.attr('data-name') + '"]'). + editable('setValue', newValue); } run_pipeline_button_state(); }); $(document).on('ready ajax:complete', function() { $('a.editable.required').each(function() { - if (this.hasClass("editable-empty")) { - this.parent().css("background-color", "#ffdddd"); - this.parent().prev().css("background-color", "#ffdddd"); + var $tag = $(this); + if ($tag.hasClass("editable-empty")) { + $tag.parent().css("background-color", "#ffdddd"); + $tag.parent().prev().css("background-color", "#ffdddd"); } else { - this.parent().css("background-color", ""); - this.parent().prev().css("background-color", ""); + $tag.parent().css("background-color", ""); + $tag.parent().prev().css("background-color", ""); } }); run_pipeline_button_state(); diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js index f8dbed59c4..1e32c63564 100644 --- a/apps/workbench/app/assets/javascripts/selection.js +++ b/apps/workbench/app/assets/javascripts/selection.js @@ -125,7 +125,7 @@ jQuery(function($){ }); add_form_selection_sources = null; -select_form_sources = null; +select_form_sources = null; (function() { var form_selection_sources = {}; diff --git a/apps/workbench/app/views/pipeline_templates/_show_recent.html.erb b/apps/workbench/app/views/pipeline_templates/_show_recent.html.erb index 3ea7d8c79b..9b637d506a 100644 --- a/apps/workbench/app/views/pipeline_templates/_show_recent.html.erb +++ b/apps/workbench/app/views/pipeline_templates/_show_recent.html.erb @@ -1,30 +1,23 @@ -<% content_for :css do %> - .playbutton { - color: white; - background: rgb(91, 192, 222); - border: 0px; - border-radius: 3px; - padding: 0px 3px; - } - .playbutton:hover { - background: rgb(57, 179, 215); - } -<% end %> - <%= render partial: "paging", locals: {results: @objects, object: @object} %> - +
+ + + + + + + @@ -36,19 +29,19 @@ diff --git a/apps/workbench/test/integration/pipeline_instances_test.rb b/apps/workbench/test/integration/pipeline_instances_test.rb new file mode 100644 index 0000000000..e10068f162 --- /dev/null +++ b/apps/workbench/test/integration/pipeline_instances_test.rb @@ -0,0 +1,56 @@ +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 + end + + test 'Create and run a pipeline' do + visit page_with_token('active_trustedclient') + + click_link 'Pipeline templates' + within('tr', text: 'Two Part Pipeline Template') do + find('a,button', text: 'Run').click + end + + instance_page = current_path + + # Go over to the collections page and select something + click_link 'Collections (data files)' + within('tr', text: 'GNU_General_Public_License') do + find('input[type=checkbox]').click + end + find('#persistent-selection-count').click + + # Go back to the pipeline instance page to use the new selection + visit instance_page + + page.assert_selector 'a.disabled,button.disabled', text: 'Run' + assert find('div.alert', text: 'Provide a value') + + find('div.form-group', text: 'Input for part-one component'). + find('a,input'). + click + find('.editable-input select').click + find('.editable-input'). + first(:option, 'b519d9cb706a29fc7ea24dbea2f05851+249025').click + wait_for_ajax + + # "Run" button is now enabled + page.assert_no_selector 'a.disabled,button.disabled', text: 'Run' + + first('a,button', text: 'Run').click + + # Pipeline is running. We have a "Stop" button instead now. + page.assert_selector 'a,button', text: 'Stop' + find('a,button', text: 'Stop').click + + # Pipeline is stopped. We have the option to resume it. + page.assert_selector 'a,button', text: 'Run' + end +end diff --git a/apps/workbench/test/integration/smoke_test.rb b/apps/workbench/test/integration/smoke_test.rb index 864224b98d..729345673e 100644 --- a/apps/workbench/test/integration/smoke_test.rb +++ b/apps/workbench/test/integration/smoke_test.rb @@ -2,6 +2,10 @@ require 'integration_helper' require 'uri' class SmokeTest < ActionDispatch::IntegrationTest + setup do + Capybara.current_driver = Capybara.javascript_driver + end + def assert_visit_success(allowed=[200]) assert_includes(allowed, status_code, "#{current_url} returned #{status_code}, not one of " + diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb index a8788ceb53..ed6f7c21ea 100644 --- a/apps/workbench/test/integration_helper.rb +++ b/apps/workbench/test/integration_helper.rb @@ -48,4 +48,20 @@ class ActionDispatch::IntegrationTest false end end + + @@screenshot_count = 0 + def screenshot + image_file = "./tmp/workbench-fail-#{@@screenshot_count += 1}.png" + page.save_screenshot image_file + puts "Saved #{image_file}" + end + + teardown do + if not passed? + screenshot + end + if Capybara.current_driver == :selenium + page.execute_script("window.localStorage.clear()") + end + end end diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml index ce05d18f0d..2e7355d5c7 100644 --- a/services/api/test/fixtures/collections.yml +++ b/services/api/test/fixtures/collections.yml @@ -1,6 +1,6 @@ user_agreement: uuid: b519d9cb706a29fc7ea24dbea2f05851+249025 - owner_uuid: qr1hi-tpzed-tpj2ff66551eyym + owner_uuid: zzzzz-tpzed-000000000000000 created_at: 2013-12-26T19:22:54Z modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f @@ -10,7 +10,7 @@ user_agreement: foo_file: uuid: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45 - owner_uuid: qr1hi-tpzed-000000000000000 + owner_uuid: zzzzz-tpzed-000000000000000 created_at: 2014-02-03T17:22:54Z modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f @@ -20,7 +20,7 @@ foo_file: bar_file: uuid: fa7aeb5140e2848d39b416daeef4ffc5+45 - owner_uuid: qr1hi-tpzed-000000000000000 + owner_uuid: zzzzz-tpzed-000000000000000 created_at: 2014-02-03T17:22:54Z modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f @@ -30,7 +30,7 @@ bar_file: baz_file: uuid: ea10d51bcf88862dbcc36eb292017dfd+45 - owner_uuid: qr1hi-tpzed-000000000000000 + owner_uuid: zzzzz-tpzed-000000000000000 created_at: 2014-02-03T17:22:54Z modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f diff --git a/services/api/test/fixtures/pipeline_templates.yml b/services/api/test/fixtures/pipeline_templates.yml index 454c184aac..41005a4027 100644 --- a/services/api/test/fixtures/pipeline_templates.yml +++ b/services/api/test/fixtures/pipeline_templates.yml @@ -14,7 +14,8 @@ two_part: script_parameters: input: required: true - dataclass: collection + dataclass: Collection + description: "Provide a collection containing at least two files." part-two: script: bar script_version: master
- id - name + name - owner + components - components + owner
<%= form_tag '/pipeline_instances' do |f| %> <%= hidden_field :pipeline_instance, :pipeline_template_uuid, :value => ob.uuid %> - <%= button_tag nil, {class: 'playbutton', title: "Run #{ob.name}"} do %> - + <%= button_tag nil, {class: "btn btn-default btn-xs", title: "Run #{ob.name}"} do %> + Run <% end %> <% end %> - <%= link_to_if_arvados_object ob %> + <%= render :partial => "show_object_button", :locals => {object: ob, size: 'xs'} %> <%= render_editable_attribute ob, 'name' %> - - <%= link_to_if_arvados_object ob.owner_uuid, friendly_name: true %> <%= ob.components.collect { |k,v| k.to_s }.join(", ") %> + + <%= link_to_if_arvados_object ob.owner_uuid, friendly_name: true %>