Merge branch 'master' into 3076-topnav-help
[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     find('tr[data-kind="arvados#pipelineInstance"]', text: 'New pipeline instance').
49       find('a', text: 'Show').
50       click
51
52     assert find('p', text: 'Provide a value')
53
54     find('div.form-group', text: 'Foo/bar pair').
55       find('.btn', text: 'Choose').
56       click
57
58     within('.modal-dialog') do
59       first('span', text: 'foo_tag').click
60       find('button', text: 'OK').click
61     end
62
63     wait_for_ajax
64
65     # "Run" button is now enabled
66     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
67
68     first('a,button', text: 'Run').click
69
70     # Pipeline is running. We have a "Stop" button instead now.
71     page.assert_selector 'a,button', text: 'Stop'
72     find('a,button', text: 'Stop').click
73
74     # Pipeline is stopped. It should now be in paused state and Runnable again.
75     assert page.has_text? 'Paused'
76     page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
77     page.assert_selector 'a,button', text: 'Clone and edit'
78
79     # Since it is test env, no jobs are created to run. So, graph not visible
80     assert_not page.has_text? 'Graph'
81   end
82
83   # Create a pipeline instance from within a project and run
84   test 'Create pipeline inside a project and run' do
85     visit page_with_token('active_trustedclient')
86
87     # Go over to the collections page and select something
88     visit '/collections'
89     within('tr', text: 'GNU_General_Public_License') do
90       find('input[type=checkbox]').click
91     end
92     find('#persistent-selection-count').click
93
94     # Add this collection to the project using collections menu from top nav
95     visit '/projects'
96     find('.arv-project-list a,button', text: 'A Project').click
97
98     find('li.selection-menu > a').click
99     click_button 'Copy selections into this project'
100
101     # create a pipeline instance
102     find('.btn', text: 'Run a pipeline').click
103     within('.modal-dialog') do
104       assert page.has_text? 'Two Part Pipeline Template'
105       find('.fa-gear').click
106       find('.btn', text: 'Next: choose inputs').click
107     end
108
109     assert find('p', text: 'Provide a value')
110
111     find('div.form-group', text: 'Foo/bar pair').
112       find('.btn', text: 'Choose').
113       click
114
115     within('.modal-dialog') do
116       first('span', text: 'foo_tag').click
117       find('button', text: 'OK').click
118     end
119
120     wait_for_ajax
121
122     # "Run" button present and enabled
123     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
124     first('a,button', text: 'Run').click
125
126     # Pipeline is running. We have a "Stop" button instead now.
127     page.assert_no_selector 'a,button', text: 'Run'
128     page.assert_selector 'a,button', text: 'Stop'
129
130     # Since it is test env, no jobs are created to run. So, graph not visible
131     assert_not page.has_text? 'Graph'
132   end
133
134   test 'view pipeline with job and see graph' do
135     visit page_with_token('active_trustedclient')
136
137     visit '/pipeline_instances'
138     assert page.has_text? 'pipeline_with_job'
139
140     find('a', text: 'pipeline_with_job').click
141
142     # since the pipeline component has a job, expect to see the graph
143     assert page.has_text? 'Graph'
144     click_link 'Graph'
145     assert page.has_text? 'script_version'
146   end
147
148 end