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