11580: add container_requests index page
[arvados.git] / apps / workbench / test / integration / container_requests_test.rb
index bd3a813f72af4b8ea77c35568b6f737a1389237d..51b6b247bf7f4e33593adecc93807aa8c21a6f8b 100644 (file)
@@ -109,4 +109,53 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     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
+
+  [
+    'active',
+    'admin',
+  ].each do |token|
+    test "index page as #{token} user" do
+      visit page_with_token(token, "/container_requests")
+
+      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]
+
+      # both the active user (owner) and admin can delete the "running" container_request
+      within(".cr-#{running_owner_active['uuid']}") do
+        assert_not_nil first('.glyphicon-trash')
+      end
+
+      # only admin user can delete the anonymously accessible container_request
+      within(".cr-#{anon_accessible_cr['uuid']}") do
+        if token == 'admin'
+          assert_not_nil first('.glyphicon-trash')
+        else
+          assert_nil first('.glyphicon-trash')
+        end
+      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
 end