Merge branch 'master' into 3634-tab-state
[arvados.git] / apps / workbench / test / diagnostics / pipeline_test.rb
1 require 'diagnostics_test_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class PipelineTest < DiagnosticsTest
6   pipelines_to_test = Rails.configuration.pipelines_to_test.andand.keys
7
8   setup do
9     headless = Headless.new
10     headless.start
11     Capybara.current_driver = :selenium
12   end
13
14   pipelines_to_test.andand.each do |pipeline_to_test|
15     test "visit home page for user #{pipeline_to_test}" do
16       visit_page_with_token 'active'
17       pipeline_config = Rails.configuration.pipelines_to_test[pipeline_to_test]
18
19       # Search for tutorial template
20       within('.navbar-fixed-top') do
21         page.find_field('search').set pipeline_config['template_uuid']
22         page.find('.glyphicon-search').click
23       end
24
25       # Run the pipeline
26       find('a,button', text: 'Run').click
27
28       # Choose project
29       within('.modal-dialog') do
30         find('.selectable', text: 'Home').click
31         find('button', text: 'Choose').click
32       end
33
34       page.assert_selector('a.disabled,button.disabled', text: 'Run') if pipeline_config['input_paths'].any?
35
36       # Choose input for the pipeline
37       pipeline_config['input_paths'].each do |look_for|
38         select_input look_for
39       end
40       wait_for_ajax
41
42       # All needed input are filled in. Run this pipeline now
43       find('a,button', text: 'Run').click
44
45       # Pipeline is running. We have a "Stop" button instead now.
46       page.assert_selector 'a,button', text: 'Stop'
47
48       # Wait for pipeline run to complete
49       wait_until_page_has 'Complete', pipeline_config['max_wait_seconds']
50     end
51   end
52
53   def select_input look_for
54     inputs_needed = page.all('.btn', text: 'Choose')
55     return if (!inputs_needed || !inputs_needed.any?)
56
57     look_for_uuid = nil
58     look_for_file = nil
59     if look_for.andand.index('/').andand.>0
60       partitions = look_for.partition('/')
61       look_for_uuid = partitions[0]
62       look_for_file = partitions[2]
63     else
64       look_for_uuid = look_for
65       look_for_file = nil
66     end
67
68     inputs_needed[0].click
69
70     within('.modal-dialog') do
71       if look_for_uuid
72         fill_in('Search', with: look_for_uuid, exact: true)
73         wait_for_ajax
74       end
75              
76       page.all('.selectable').first.click
77       wait_for_ajax
78       # ajax reload is wiping out input selection after search results; so, select again.
79       page.all('.selectable').first.click
80       wait_for_ajax
81
82       if look_for_file
83         wait_for_ajax
84         within('.collection_files_name', text: look_for_file) do
85           find('.fa-file').click
86         end
87       end
88       
89       find('button', text: 'OK').click
90       wait_for_ajax
91     end
92   end
93 end