Merge branch 'master' into 2934-limit-crunch-logs
[arvados.git] / apps / workbench / test / integration / pipeline_instances_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class PipelineInstancesTest < ActionDispatch::IntegrationTest
6   setup do
7     # Selecting collections requiresLocalStorage
8     headless = Headless.new
9     headless.start
10     Capybara.current_driver = :selenium
11   end
12
13   test 'Create and run a pipeline' do
14     visit page_with_token('active_trustedclient')
15
16     visit '/pipeline_templates'
17     within('tr', text: 'Two Part Pipeline Template') do
18       find('a,button', text: 'Run').click
19     end
20
21     # This pipeline needs input. So, Run should be disabled
22     page.assert_selector 'a.disabled,button.disabled', text: 'Run'
23
24     instance_page = current_path
25
26     # put this pipeline instance in "A Project"
27     find('button', text: 'Choose a project...').click
28     within('.modal-dialog') do
29       find('.selectable', text: 'A Project').click
30       find('button', text: 'Move').click
31     end
32
33     # Go over to the collections page and select something
34     visit '/collections'
35     within('tr', text: 'GNU_General_Public_License') do
36       find('input[type=checkbox]').click
37     end
38     find('#persistent-selection-count').click
39
40     # Add this collection to the project
41     visit '/projects'
42     find('.arv-project-list a,button', text: 'A Project').click
43     find('.btn', text: 'Add data').click
44     find('span', text: 'foo_tag').click
45     within('.modal-dialog') do
46       find('.btn', text: 'Add').click
47     end
48    
49     find('tr[data-kind="arvados#pipelineInstance"]', text: 'New pipeline instance').
50       find('a', text: 'Show').
51       click
52
53     assert find('p', text: 'Provide a value')
54
55     find('div.form-group', text: 'Foo/bar pair').
56       find('.btn', text: 'Choose').
57       click
58
59     within('.modal-dialog') do
60       find('span', text: 'foo_tag').click
61       find('button', text: 'OK').click
62     end
63
64     wait_for_ajax
65
66     # "Run" button is now enabled
67     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
68
69     first('a,button', text: 'Run').click
70
71     # Pipeline is running. We have a "Stop" button instead now.
72     page.assert_selector 'a,button', text: 'Stop'
73     find('a,button', text: 'Stop').click
74
75     # Pipeline is stopped. It should now be in paused state and Runnable again.
76     assert page.has_text? 'Paused'
77     page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
78     page.assert_selector 'a,button', text: 'Clone and edit'
79
80     # Since it is test env, no jobs are created to run. So, graph not visible
81     assert_not page.has_text? 'Graph'
82   end
83
84   # Create a pipeline instance from within a project and run
85   test 'Create pipeline inside a project and run' do
86     visit page_with_token('active_trustedclient')
87
88     # Go over to the collections page and select something
89     visit '/collections'
90     within('tr', text: 'GNU_General_Public_License') do
91       find('input[type=checkbox]').click
92     end
93     find('#persistent-selection-count').click
94
95     # Add this collection to the project using collections menu from top nav
96     visit '/projects'
97     find('.arv-project-list a,button', text: 'A Project').click
98
99     find('li.selection-menu > a').click
100     click_button 'Copy selections into this project'
101
102     # create a pipeline instance
103     find('.btn', text: 'Run a pipeline').click
104     within('.modal-dialog') do
105       assert page.has_text? 'Two Part Pipeline Template'
106       find('.fa-gear').click
107       find('.btn', text: 'Next: choose inputs').click
108     end
109
110     assert find('p', text: 'Provide a value')
111
112     find('div.form-group', text: 'Foo/bar pair').
113       find('.btn', text: 'Choose').
114       click
115
116     within('.modal-dialog') do
117       find('span', text: 'foo_tag').click
118       find('button', text: 'OK').click
119     end
120
121     wait_for_ajax
122
123     # "Run" button present and enabled
124     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
125     first('a,button', text: 'Run').click
126
127     # Pipeline is running. We have a "Stop" button instead now.
128     page.assert_no_selector 'a,button', text: 'Run'
129     page.assert_selector 'a,button', text: 'Stop'
130
131     # Since it is test env, no jobs are created to run. So, graph not visible
132     assert_not page.has_text? 'Graph'
133   end
134
135   test 'view pipeline with job and see graph' do
136     visit page_with_token('active_trustedclient')
137
138     visit '/pipeline_instances'
139     assert page.has_text? 'pipeline_with_job'
140
141     find('a', text: 'pipeline_with_job').click
142
143     # since the pipeline component has a job, expect to see the graph
144     assert page.has_text? 'Graph'
145     click_link 'Graph'
146     assert page.has_text? 'script_version'
147   end
148
149 end