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