Merge branch 'master' into 2761-diagnostic-suite
[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_run = Rails.configuration.diagnostics_testing_pipeline_fields.andand.keys
7
8   setup do
9     headless = Headless.new
10     headless.start
11     Capybara.current_driver = :selenium
12   end
13
14   pipelines_to_run.andand.each do |pipeline_to_run|
15     test "visit home page for user #{pipeline_to_run}" do
16       visit_page_with_token 'active'
17
18       pipeline_config = diagnostic_test_pipeline_config pipeline_to_run
19
20       # Search for tutorial template
21       within('.navbar-fixed-top') do
22         page.find_field('search').set pipeline_config['template_uuid']
23         page.find('.glyphicon-search').click
24       end
25
26       # Run the pipeline
27       find('a,button', text: 'Run').click
28
29       # Choose project
30       within('.modal-dialog') do
31         find('.selectable', text: 'Home').click
32         find('button', text: 'Choose').click
33       end
34
35       # Choose input for the pipeline
36       if pipeline_config['input_paths'].andand.any?
37         # This pipeline needs input. So, Run should be disabled
38         page.assert_selector 'a.disabled,button.disabled', text: 'Run'
39
40         inputs_needed = page.all('.btn', text: 'Choose')
41         inputs_needed.each_with_index do |input_needed, index|
42           input_needed.click
43           within('.modal-dialog') do
44             look_for = pipeline_config['input_paths'][index]
45             found = page.has_text?(look_for)
46             if found
47               find('.selectable').click
48             else
49               fill_in('Search', with: look_for, exact: true)
50               wait_for_ajax
51               find('.selectable').click
52             end
53             find('button', text: 'OK').click
54             wait_for_ajax
55           end
56         end
57       end
58
59       # Run this pipeline instance
60       find('a,button', text: 'Run').click
61
62       # Pipeline is running. We have a "Stop" button instead now.
63       page.assert_selector 'a,button', text: 'Stop'
64     end
65   end
66
67 end