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'
87 # Since it is test env, no jobs are created to run. So, graph not visible
88 assert_not page.has_text? 'Graph'
91 # Create a pipeline instance from within a project and run
92 test 'Create pipeline inside a project and run' do
93 visit page_with_token('active_trustedclient')
95 # Go over to the collections page and select something
97 within('tr', text: 'GNU_General_Public_License') do
98 find('input[type=checkbox]').click
100 find('#persistent-selection-count').click
102 # Add this collection to the project using collections menu from top nav
104 find("#projects-menu").click
105 find('.dropdown-menu a,button', text: 'A Project').click
106 find('.btn', text: 'Add data').click
107 within('.modal-dialog') do
109 first('span', text: 'foo_tag').click
110 find('.btn', text: 'Add').click
112 using_wait_time(Capybara.default_wait_time * 3) do
116 # create a pipeline instance
117 find('.btn', text: 'Run a pipeline').click
118 within('.modal-dialog') do
119 find('.selectable', text: 'Two Part Pipeline Template').click
120 find('.btn', text: 'Next: choose inputs').click
123 assert find('p', text: 'Provide a value')
125 find('div.form-group', text: 'Foo/bar pair').
126 find('.btn', text: 'Choose').
129 within('.modal-dialog') do
130 assert_selector 'button.dropdown-toggle', text: 'A Project'
132 first('span', text: 'foo_tag').click
133 find('button', text: 'OK').click
137 # "Run" button present and enabled
138 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
139 first('a,button', text: 'Run').click
141 # Pipeline is running. We have a "Pause" button instead now.
142 page.assert_no_selector 'a,button', text: 'Run'
143 page.assert_selector 'a,button', text: 'Pause'
145 # Since it is test env, no jobs are created to run. So, graph not visible
146 assert_not page.has_text? 'Graph'
149 # Create a pipeline instance from within a project and run
150 test 'Run a pipeline from dashboard' do
151 visit page_with_token('active_trustedclient')
153 # create a pipeline instance
154 find('.btn', text: 'Run a pipeline').click
155 within('.modal-dialog') do
156 find('.selectable', text: 'Two Part Pipeline Template').click
157 find('.btn', text: 'Next: choose inputs').click
160 assert find('p', text: 'Provide a value')
162 find('div.form-group', text: 'Foo/bar pair').
163 find('.btn', text: 'Choose').
166 within('.modal-dialog') do
167 assert_selector 'button.dropdown-toggle', text: 'Home'
170 click_link "A Project"
172 first('span', text: 'foo_tag').click
173 find('button', text: 'OK').click
177 # "Run" button present and enabled
178 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
179 first('a,button', text: 'Run').click
181 # Pipeline is running. We have a "Pause" button instead now.
182 page.assert_no_selector 'a,button', text: 'Run'
183 page.assert_selector 'a,button', text: 'Pause'
185 # Since it is test env, no jobs are created to run. So, graph not visible
186 assert_not page.has_text? 'Graph'
190 test 'view pipeline with job and see graph' do
191 visit page_with_token('active_trustedclient')
193 visit '/pipeline_instances'
194 assert page.has_text? 'pipeline_with_job'
196 find('a', text: 'pipeline_with_job').click
198 # since the pipeline component has a job, expect to see the graph
199 assert page.has_text? 'Graph'
201 assert page.has_text? 'script_version'
204 test 'pipeline description' do
205 visit page_with_token('active_trustedclient')
207 visit '/pipeline_instances'
208 assert page.has_text? 'pipeline_with_job'
210 find('a', text: 'pipeline_with_job').click
212 within('.arv-description-as-subtitle') do
213 find('.fa-pencil').click
214 find('.editable-input textarea').set('*Textile description for pipeline instance*')
215 find('.editable-submit').click
220 assert page.has_no_text? '*Textile description for pipeline instance*'
221 assert page.has_text? 'Textile description for pipeline instance'
224 test "JSON popup available for strange components" do
225 uuid = api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]
226 visit page_with_token("active", "/pipeline_instances/#{uuid}")
227 click_on "Components"
228 assert(page.has_no_text?("script_parameters"),
229 "components JSON visible without popup")
230 click_on "Show components JSON"
231 assert(page.has_text?("script_parameters"),
232 "components JSON not found")
235 PROJECT_WITH_SEARCH_COLLECTION = "A Subproject"
236 def check_parameter_search(proj_name)
237 template = api_fixture("pipeline_templates")["parameter_with_search"]
238 search_text = template["components"]["with-search"]["script_parameters"]["input"]["search_for"]
239 visit page_with_token("active", "/pipeline_templates/#{template['uuid']}")
240 click_on "Run this pipeline"
241 within(".modal-dialog") do # Set project for the new pipeline instance
242 find(".selectable", text: proj_name).click
245 assert(has_text?("This pipeline was created from the template"), "did not land on pipeline instance page")
246 first("a.btn,button", text: "Choose").click
247 within(".modal-body") do
248 if (proj_name != PROJECT_WITH_SEARCH_COLLECTION)
249 # Switch finder modal to Subproject to find the Collection.
251 click_on PROJECT_WITH_SEARCH_COLLECTION
253 assert_equal(search_text, first("input").value,
254 "parameter search not preseeded")
255 assert(has_text?(api_fixture("collections")["baz_collection_name_in_asubproject"]["name"]),
256 "baz Collection not in preseeded search results")
260 test "Workbench respects search_for parameter in templates" do
261 check_parameter_search(PROJECT_WITH_SEARCH_COLLECTION)
264 test "Workbench preserves search_for parameter after project switch" do
265 check_parameter_search("A Project")