Merge branch 'master' into 11898-no-distinct
[arvados.git] / apps / workbench / test / integration / container_requests_test.rb
index 86b8b054f069ac15d6541655ac3a2f4af32974b3..151654b231d2a8e9e959e5177305a97b50abe22c 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'integration_helper'
 
 class ContainerRequestsTest < ActionDispatch::IntegrationTest
@@ -11,11 +15,9 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     ['ex_int', 12],
     ['ex_int_opt', 12],
     ['ex_long', 12],
-    ['ex_double', 12.34],
-    ['ex_double', 'abc', true, 0.0],
-    ['ex_float', 12.34],
-    ['ex_float', 'abc', true, 0.0],
-  ].each do |input_id, input_value, need_refresh, expected|
+    ['ex_double', '12.34', 12.34],
+    ['ex_float', '12.34', 12.34],
+  ].each do |input_id, input_value, expected_value|
     test "set input #{input_id} with #{input_value}" do
       request_uuid = api_fixture("container_requests", "uncommitted", "uuid")
       visit page_with_token("active", "/container_requests/#{request_uuid}")
@@ -24,11 +26,7 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
       find(".editable-input input").set(input_value)
       find("#editable-submit").click
       assert_no_selector(".editable-popup")
-      assert_selector(selector, text: input_value)
-      if need_refresh
-        visit page_with_token("active", "/container_requests/#{request_uuid}")
-        assert_selector(selector, text: expected)
-      end
+      assert_selector(selector, text: expected_value || input_value)
     end
   end
 
@@ -62,7 +60,7 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     ['directory_type'],
     ['file_type'],
   ].each do |type|
-    test "select input for #{type}" do
+    test "select value for #{type} input" do
       request_uuid = api_fixture("container_requests", "uncommitted-with-directory-input", "uuid")
       visit page_with_token("active", "/container_requests/#{request_uuid}")
       assert_text 'Provide a value for the following parameter'
@@ -81,7 +79,7 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
       assert_text 'This workflow does not need any further inputs'
       click_link "Run"
       wait_for_ajax
-      assert_text 'This container is committed'
+      assert_text 'This container is queued'
     end
   end
 
@@ -90,6 +88,8 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     visit page_with_token("active", "/container_requests/#{request_uuid}")
     assert_text 'Provide a value for the following parameter'
 
+    page.assert_selector 'a.disabled,button.disabled', text: 'Run'
+
     selector = ".editable[data-name='[mounts][/var/lib/cwl/cwl.input.json][content][int_required]']"
     find(selector).click
     find(".editable-input input").set(2016)
@@ -98,6 +98,64 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
     click_link "Run"
     wait_for_ajax
-    assert_text 'This container is committed'
+    assert_text 'This container is queued'
+  end
+
+  test "Run button enabled when workflow is empty and no inputs are needed" do
+    visit page_with_token("active")
+
+    find('.btn', text: 'Run a process').click
+    within('.modal-dialog') do
+      find('.selectable', text: 'Valid workflow with no definition yaml').click
+      find('.btn', text: 'Next: choose inputs').click
+    end
+
+    assert_text 'This workflow does not need any further inputs'
+    page.assert_selector 'a', text: 'Run'
+  end
+
+  test "Provenance graph shown on committed container requests" do
+    cr = api_fixture('container_requests', 'completed')
+    visit page_with_token("active", "/container_requests/#{cr['uuid']}")
+    assert page.has_text? 'Provenance'
+    click_link 'Provenance'
+    wait_for_ajax
+    # Check for provenance graph existance
+    page.assert_selector '#provenance_svg'
+    page.assert_selector 'ellipse+text', text: cr['name'], visible: false
+    page.assert_selector 'g.node>title', text: cr['uuid'], visible: false
+  end
+
+  test "index page" do
+    visit page_with_token("active", "/container_requests")
+
+    within(".arv-recent-container-requests") do
+      page.execute_script "window.scrollBy(0,999000)"
+      wait_for_ajax
+    end
+
+    running_owner_active = api_fixture("container_requests", "requester_for_running")
+    anon_accessible_cr = api_fixture("container_requests", "running_anonymous_accessible")
+
+    # both of these CRs should be accessible to the user
+    assert_selector "a[href=\"/container_requests/#{running_owner_active['uuid']}\"]", text: running_owner_active[:name]
+    assert_selector "a[href=\"/container_requests/#{anon_accessible_cr['uuid']}\"]", text: anon_accessible_cr[:name]
+
+    # user can delete the "running" container_request
+    within(".cr-#{running_owner_active['uuid']}") do
+      assert_not_nil first('.glyphicon-trash')
+    end
+
+    # user can not delete the anonymously accessible container_request
+    within(".cr-#{anon_accessible_cr['uuid']}") do
+      assert_nil first('.glyphicon-trash')
+    end
+
+    # verify the search box in the page
+    find('.recent-container-requests-filterable-control').set("anonymous")
+    sleep 0.350 # Wait for 250ms debounce timer (see filterable.js)
+    wait_for_ajax
+    assert_no_selector "a[href=\"/container_requests/#{running_owner_active['uuid']}\"]", text: running_owner_active[:name]
+    assert_selector "a[href=\"/container_requests/#{anon_accessible_cr['uuid']}\"]", text: anon_accessible_cr[:name]
   end
 end