3686: verify repositories testing uses hard coded repo info.
[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_selenium 'to make websockets work'
8   end
9
10   pipelines_to_test.andand.each do |pipeline_to_test|
11     test "run pipeline: #{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       find '.navbar-fixed-top'
17       within('.navbar-fixed-top') do
18         page.find_field('search').set pipeline_config['template_uuid']
19         page.find('.glyphicon-search').click
20       end
21
22       # Run the pipeline
23       assert_triggers_dom_event 'shown.bs.modal' do
24         find('a,button', text: 'Run').click
25       end
26
27       # Choose project
28       within('.modal-dialog') do
29         find('.selectable', text: 'Home').click
30         find('button', text: 'Choose').click
31       end
32
33       page.assert_selector('a.disabled,button.disabled', text: 'Run') if pipeline_config['input_paths'].any?
34
35       # Choose input for the pipeline
36       pipeline_config['input_paths'].each do |look_for|
37         select_input look_for
38       end
39       wait_for_ajax
40
41       # All needed input are filled in. Run this pipeline now
42       find('a,button', text: 'Run').click
43
44       # Pipeline is running. We have a "Stop" button instead now.
45       page.assert_selector 'a,button', text: 'Pause'
46
47       # Wait for pipeline run to complete
48       wait_until_page_has 'Complete', pipeline_config['max_wait_seconds']
49     end
50   end
51
52   def select_input look_for
53     inputs_needed = page.all('.btn', text: 'Choose')
54     return if (!inputs_needed || !inputs_needed.any?)
55
56     look_for_uuid = nil
57     look_for_file = nil
58     if look_for.andand.index('/').andand.>0
59       partitions = look_for.partition('/')
60       look_for_uuid = partitions[0]
61       look_for_file = partitions[2]
62     else
63       look_for_uuid = look_for
64       look_for_file = nil
65     end
66
67     assert_triggers_dom_event 'shown.bs.modal' do
68       inputs_needed[0].click
69     end
70
71     within('.modal-dialog') do
72       if look_for_uuid
73         fill_in('Search', with: look_for_uuid, exact: true)
74         wait_for_ajax
75       end
76              
77       page.all('.selectable').first.click
78       wait_for_ajax
79       # ajax reload is wiping out input selection after search results; so, select again.
80       page.all('.selectable').first.click
81       wait_for_ajax
82
83       if look_for_file
84         wait_for_ajax
85         within('.collection_files_name', text: look_for_file) do
86           find('.fa-file').click
87         end
88       end
89       
90       find('button', text: 'OK').click
91       wait_for_ajax
92     end
93   end
94 end