Merge branch '10037-useless-progress-bar'
[arvados.git] / apps / workbench / test / integration / container_requests_test.rb
1 require 'integration_helper'
2
3 class ContainerRequestsTest < ActionDispatch::IntegrationTest
4   setup do
5     need_javascript
6   end
7
8   [
9     ['ex_string', 'abc'],
10     ['ex_string_opt', 'abc'],
11     ['ex_int', 12],
12     ['ex_int_opt', 12],
13     ['ex_long', 12],
14     ['ex_double', '12.34', 12.34],
15     ['ex_float', '12.34', 12.34],
16   ].each do |input_id, input_value, expected_value|
17     test "set input #{input_id} with #{input_value}" do
18       request_uuid = api_fixture("container_requests", "uncommitted", "uuid")
19       visit page_with_token("active", "/container_requests/#{request_uuid}")
20       selector = ".editable[data-name='[mounts][/var/lib/cwl/cwl.input.json][content][#{input_id}]']"
21       find(selector).click
22       find(".editable-input input").set(input_value)
23       find("#editable-submit").click
24       assert_no_selector(".editable-popup")
25       assert_selector(selector, text: expected_value || input_value)
26     end
27   end
28
29   test "select value for boolean input" do
30     request_uuid = api_fixture("container_requests", "uncommitted", "uuid")
31     visit page_with_token("active", "/container_requests/#{request_uuid}")
32     selector = ".editable[data-name='[mounts][/var/lib/cwl/cwl.input.json][content][ex_boolean]']"
33     find(selector).click
34     within(".editable-input") do
35       select "true"
36     end
37     find("#editable-submit").click
38     assert_no_selector(".editable-popup")
39     assert_selector(selector, text: "true")
40   end
41
42   test "select value for enum typed input" do
43     request_uuid = api_fixture("container_requests", "uncommitted", "uuid")
44     visit page_with_token("active", "/container_requests/#{request_uuid}")
45     selector = ".editable[data-name='[mounts][/var/lib/cwl/cwl.input.json][content][ex_enum]']"
46     find(selector).click
47     within(".editable-input") do
48       select "b"    # second value
49     end
50     find("#editable-submit").click
51     assert_no_selector(".editable-popup")
52     assert_selector(selector, text: "b")
53   end
54
55   [
56     ['directory_type'],
57     ['file_type'],
58   ].each do |type|
59     test "select value for #{type} input" do
60       request_uuid = api_fixture("container_requests", "uncommitted-with-directory-input", "uuid")
61       visit page_with_token("active", "/container_requests/#{request_uuid}")
62       assert_text 'Provide a value for the following parameter'
63       click_link 'Choose'
64       within('.modal-dialog') do
65         wait_for_ajax
66         collection = api_fixture('collections', 'collection_with_one_property', 'uuid')
67         find("div[data-object-uuid=#{collection}]").click
68         if type == 'ex_file'
69           wait_for_ajax
70           find('.preview-selectable', text: 'bar').click
71         end
72         find('button', text: 'OK').click
73       end
74       page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
75       assert_text 'This workflow does not need any further inputs'
76       click_link "Run"
77       wait_for_ajax
78       assert_text 'This container is queued'
79     end
80   end
81
82   test "Run button enabled once all required inputs are provided" do
83     request_uuid = api_fixture("container_requests", "uncommitted-with-required-and-optional-inputs", "uuid")
84     visit page_with_token("active", "/container_requests/#{request_uuid}")
85     assert_text 'Provide a value for the following parameter'
86
87     page.assert_selector 'a.disabled,button.disabled', text: 'Run'
88
89     selector = ".editable[data-name='[mounts][/var/lib/cwl/cwl.input.json][content][int_required]']"
90     find(selector).click
91     find(".editable-input input").set(2016)
92     find("#editable-submit").click
93
94     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
95     click_link "Run"
96     wait_for_ajax
97     assert_text 'This container is queued'
98   end
99 end