1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class PipelineInstancesTest < ActionDispatch::IntegrationTest
7 # Selecting collections requiresLocalStorage
8 headless = Headless.new
10 Capybara.current_driver = :selenium
13 test 'Create and run a pipeline' do
14 visit page_with_token('active_trustedclient')
16 visit '/pipeline_templates'
17 within('tr', text: 'Two Part Pipeline Template') do
18 find('a,button', text: 'Run').click
22 within('.modal-dialog') do
23 find('.selectable', text: 'A Project').click
24 find('button', text: 'Choose').click
27 # This pipeline needs input. So, Run should be disabled
28 page.assert_selector 'a.disabled,button.disabled', text: 'Run'
30 instance_page = current_path
32 # Go over to the collections page and select something
34 within('tr', text: 'GNU_General_Public_License') do
35 find('input[type=checkbox]').click
37 find('#persistent-selection-count').click
39 # Add this collection to the project
41 find("#projects-menu").click
42 find('.dropdown-menu a,button', text: 'A Project').click
43 find('.btn', text: 'Add data').click
44 within('.modal-dialog') do
46 first('span', text: 'foo_tag').click
47 find('.btn', text: 'Add').click
49 using_wait_time(Capybara.default_wait_time * 3) do
53 click_link 'Jobs and pipelines'
54 find('tr[data-kind="arvados#pipelineInstance"]', text: '(none)').
55 find('a', text: 'Show').
58 assert find('p', text: 'Provide a value')
60 find('div.form-group', text: 'Foo/bar pair').
61 find('.btn', text: 'Choose').
64 within('.modal-dialog') do
65 assert(has_text?("Foo/bar pair"),
66 "pipeline input picker missing name of input")
68 first('span', text: 'foo_tag').click
69 find('button', text: 'OK').click
73 # "Run" button is now enabled
74 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
76 first('a,button', text: 'Run').click
78 # Pipeline is running. We have a "Pause" button instead now.
79 page.assert_selector 'a,button', text: 'Pause'
80 find('a,button', text: 'Pause').click
82 # Pipeline is stopped. It should now be in paused state and Runnable again.
83 assert page.has_text? 'Paused'
84 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
85 page.assert_selector 'a,button', text: 'Re-run with latest'
86 page.assert_selector 'a,button', text: 'Re-run options'
88 # Since it is test env, no jobs are created to run. So, graph not visible
89 assert_not page.has_text? 'Graph'
92 # Create a pipeline instance from within a project and run
93 test 'Create pipeline inside a project and run' do
94 visit page_with_token('active_trustedclient')
96 # Go over to the collections page and select something
98 within('tr', text: 'GNU_General_Public_License') do
99 find('input[type=checkbox]').click
101 find('#persistent-selection-count').click
103 # Add this collection to the project using collections menu from top nav
105 find("#projects-menu").click
106 find('.dropdown-menu a,button', text: 'A Project').click
107 find('.btn', text: 'Add data').click
108 within('.modal-dialog') do
110 first('span', text: 'foo_tag').click
111 find('.btn', text: 'Add').click
113 using_wait_time(Capybara.default_wait_time * 3) do
117 create_and_run_pipeline_in_aproject true
120 # Create a pipeline instance from within a project and run
121 test 'Run a pipeline from dashboard' do
122 visit page_with_token('active_trustedclient')
123 create_and_run_pipeline_in_aproject false
126 test 'view pipeline with job and see graph' do
127 visit page_with_token('active_trustedclient')
129 visit '/pipeline_instances'
130 assert page.has_text? 'pipeline_with_job'
132 find('a', text: 'pipeline_with_job').click
134 # since the pipeline component has a job, expect to see the graph
135 assert page.has_text? 'Graph'
137 assert page.has_text? 'script_version'
140 test 'pipeline description' do
141 visit page_with_token('active_trustedclient')
143 visit '/pipeline_instances'
144 assert page.has_text? 'pipeline_with_job'
146 find('a', text: 'pipeline_with_job').click
148 within('.arv-description-as-subtitle') do
149 find('.fa-pencil').click
150 find('.editable-input textarea').set('*Textile description for pipeline instance*')
151 find('.editable-submit').click
156 assert page.has_no_text? '*Textile description for pipeline instance*'
157 assert page.has_text? 'Textile description for pipeline instance'
160 test "JSON popup available for strange components" do
161 uuid = api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]
162 visit page_with_token("active", "/pipeline_instances/#{uuid}")
163 click_on "Components"
164 assert(page.has_no_text?("script_parameters"),
165 "components JSON visible without popup")
166 click_on "Show components JSON"
167 assert(page.has_text?("script_parameters"),
168 "components JSON not found")
171 PROJECT_WITH_SEARCH_COLLECTION = "A Subproject"
172 def check_parameter_search(proj_name)
173 template = api_fixture("pipeline_templates")["parameter_with_search"]
174 search_text = template["components"]["with-search"]["script_parameters"]["input"]["search_for"]
175 visit page_with_token("active", "/pipeline_templates/#{template['uuid']}")
176 click_on "Run this pipeline"
177 within(".modal-dialog") do # Set project for the new pipeline instance
178 find(".selectable", text: proj_name).click
181 assert(has_text?("This pipeline was created from the template"), "did not land on pipeline instance page")
182 first("a.btn,button", text: "Choose").click
183 within(".modal-body") do
184 if (proj_name != PROJECT_WITH_SEARCH_COLLECTION)
185 # Switch finder modal to Subproject to find the Collection.
187 click_on PROJECT_WITH_SEARCH_COLLECTION
189 assert_equal(search_text, first("input").value,
190 "parameter search not preseeded")
191 assert(has_text?(api_fixture("collections")["baz_collection_name_in_asubproject"]["name"]),
192 "baz Collection not in preseeded search results")
196 test "Workbench respects search_for parameter in templates" do
197 check_parameter_search(PROJECT_WITH_SEARCH_COLLECTION)
200 test "Workbench preserves search_for parameter after project switch" do
201 check_parameter_search("A Project")
205 [false, false, false],
206 [false, false, true],
207 [true, false, false],
211 ].each do |with_options, choose_options, in_aproject|
212 test "Rerun pipeline instance using options #{with_options} #{choose_options} in #{in_aproject}" do
213 visit page_with_token('active_trustedclient')
216 find("#projects-menu").click
217 find('.dropdown-menu a,button', text: 'A Project').click
220 create_and_run_pipeline_in_aproject in_aproject
221 instance_path = current_path
224 find('a,button', text: 'Pause').click
225 assert page.has_text? 'Paused'
226 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
227 page.assert_selector 'a,button', text: 'Re-run with latest'
228 page.assert_selector 'a,button', text: 'Re-run options'
231 find('a,button', text: 'Re-run options').click
232 within('.modal-dialog') do
233 page.assert_selector 'a,button', text: 'Copy and edit inputs'
234 page.assert_selector 'a,button', text: 'Run now'
236 find('button', text: 'Copy and edit inputs').click
238 find('button', text: 'Run now').click
242 find('a,button', text: 'Re-run with latest').click
245 # verify that the newly created instance is in the expected project
246 rerun_instance_path = current_path
247 assert_not_equal instance_path, rerun_instance_path, 'Rerun instance path expected to be different'
248 assert page.has_text? 'Home'
250 assert page.has_text? 'A Project'
255 # Create and run a pipeline for 'Two Part Pipeline Template' in 'A Project'
256 def create_and_run_pipeline_in_aproject in_aproject
257 # create a pipeline instance
258 find('.btn', text: 'Run a pipeline').click
259 within('.modal-dialog') do
260 find('.selectable', text: 'Two Part Pipeline Template').click
261 find('.btn', text: 'Next: choose inputs').click
264 assert find('p', text: 'Provide a value')
266 find('div.form-group', text: 'Foo/bar pair').
267 find('.btn', text: 'Choose').
270 within('.modal-dialog') do
272 assert_selector 'button.dropdown-toggle', text: 'A Project'
275 assert_selector 'button.dropdown-toggle', text: 'Home'
278 click_link "A Project"
281 first('span', text: 'foo_tag').click
282 find('button', text: 'OK').click
286 # "Run" button present and enabled
287 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
288 first('a,button', text: 'Run').click
290 # Pipeline is running. We have a "Pause" button instead now.
291 page.assert_no_selector 'a,button', text: 'Run'
292 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
293 page.assert_selector 'a,button', text: 'Pause'
295 # Since it is test env, no jobs are created to run. So, graph not visible
296 assert_not page.has_text? 'Graph'