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