Merge branch '3178-discoverable-parameters' closes #3178
[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     # project chooser
22     within('.modal-dialog') do
23       find('.selectable', text: 'A Project').click
24       find('button', text: 'Choose').click
25     end
26
27     # This pipeline needs input. So, Run should be disabled
28     page.assert_selector 'a.disabled,button.disabled', text: 'Run'
29
30     instance_page = current_path
31
32     # Go over to the collections page and select something
33     visit '/collections'
34     within('tr', text: 'GNU_General_Public_License') do
35       find('input[type=checkbox]').click
36     end
37     find('#persistent-selection-count').click
38
39     # Add this collection to the project
40     visit '/projects'
41     find('.arv-project-list a,button', text: 'A Project').click
42     find('.btn', text: 'Add data').click
43     find('span', text: 'foo_tag').click
44     within('.modal-dialog') do
45       find('.btn', text: 'Add').click
46     end
47     wait_for_ajax
48
49     click_link 'Jobs and pipelines'
50     find('tr[data-kind="arvados#pipelineInstance"]', text: 'New pipeline instance').
51       find('a', text: 'Show').
52       click
53
54     assert find('p', text: 'Provide a value')
55
56     find('div.form-group', text: 'Foo/bar pair').
57       find('.btn', text: 'Choose').
58       click
59
60     within('.modal-dialog') do
61       assert(has_text?("Foo/bar pair"),
62              "pipeline input picker missing name of input")
63       first('span', text: 'foo_tag').click
64       find('button', text: 'OK').click
65     end
66
67     wait_for_ajax
68
69     # "Run" button is now enabled
70     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
71
72     first('a,button', text: 'Run').click
73
74     # Pipeline is running. We have a "Stop" button instead now.
75     page.assert_selector 'a,button', text: 'Stop'
76     find('a,button', text: 'Stop').click
77
78     # Pipeline is stopped. It should now be in paused state and Runnable again.
79     assert page.has_text? 'Paused'
80     page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
81     page.assert_selector 'a,button', text: 'Clone and edit'
82
83     # Since it is test env, no jobs are created to run. So, graph not visible
84     assert_not page.has_text? 'Graph'
85   end
86
87   # Create a pipeline instance from within a project and run
88   test 'Create pipeline inside a project and run' do
89     visit page_with_token('active_trustedclient')
90
91     # Go over to the collections page and select something
92     visit '/collections'
93     within('tr', text: 'GNU_General_Public_License') do
94       find('input[type=checkbox]').click
95     end
96     find('#persistent-selection-count').click
97
98     # Add this collection to the project using collections menu from top nav
99     visit '/projects'
100     find('.arv-project-list a,button', text: 'A Project').click
101
102     find('li.selection-menu > a').click
103     click_button 'Copy selections into this project'
104
105     # create a pipeline instance
106     find('.btn', text: 'Run a pipeline').click
107     within('.modal-dialog') do
108       assert page.has_text? 'Two Part Pipeline Template'
109       find('.selectable', text: 'Two Part Pipeline Template').click
110       find('.btn', text: 'Next: choose inputs').click
111     end
112
113     assert find('p', text: 'Provide a value')
114
115     find('div.form-group', text: 'Foo/bar pair').
116       find('.btn', text: 'Choose').
117       click
118
119     within('.modal-dialog') do
120       assert_selector 'button.dropdown-toggle', text: 'A Project'
121       first('span', text: 'foo_tag').click
122       find('button', text: 'OK').click
123     end
124
125     wait_for_ajax
126
127     # "Run" button present and enabled
128     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
129     first('a,button', text: 'Run').click
130
131     # Pipeline is running. We have a "Stop" button instead now.
132     page.assert_no_selector 'a,button', text: 'Run'
133     page.assert_selector 'a,button', text: 'Stop'
134
135     # Since it is test env, no jobs are created to run. So, graph not visible
136     assert_not page.has_text? 'Graph'
137   end
138
139   test 'view pipeline with job and see graph' do
140     visit page_with_token('active_trustedclient')
141
142     visit '/pipeline_instances'
143     assert page.has_text? 'pipeline_with_job'
144
145     find('a', text: 'pipeline_with_job').click
146
147     # since the pipeline component has a job, expect to see the graph
148     assert page.has_text? 'Graph'
149     click_link 'Graph'
150     assert page.has_text? 'script_version'
151   end
152
153   test "JSON popup available for strange components" do
154     uuid = api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]
155     visit page_with_token("active", "/pipeline_instances/#{uuid}")
156     click_on "Components"
157     assert(page.has_no_text?("script_parameters"),
158            "components JSON visible without popup")
159     click_on "Show components JSON"
160     assert(page.has_text?("script_parameters"),
161            "components JSON not found")
162   end
163 end