Merge branch 'master' into 9352-many-nodes-make-workbench-faster
[arvados.git] / apps / workbench / test / integration / application_layout_test.rb
index 4685b0cec918bd374aa9ac175c967143442ee29f..61905f31b2e21b9735755ab4715263f1e93ab6bc 100644 (file)
@@ -179,7 +179,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
 
         first('button', text: 'x').click
       end
-      assert_text 'Active processes' # seeing dashboard now
+      assert_text 'Recent pipelines and processes' # seeing dashboard now
     end
   end
 
@@ -242,30 +242,98 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
     end
   end
 
-  test "dashboard panes" do
-    visit page_with_token('active')
+  [
+    ['active', false],
+    ['admin', true],
+  ].each do |token, is_admin|
+    test "visit dashboard as #{token}" do
+      visit page_with_token(token)
+
+      assert_text 'Recent pipelines and processes' # seeing dashboard now
+      within('.recent-processes-actions') do
+        assert page.has_link?('Run a pipeline')
+        assert page.has_link?('All pipelines')
+      end
+
+      within('.recent-processes') do
+        assert_text 'running_with_job'
+        within('.row-zzzzz-d1hrv-runningpipeline') do
+          assert_text 'foo'
+        end
+
+        assert_text 'zzzzz-d1hrv-twodonepipeline'
+        within('.row-zzzzz-d1hrv-twodonepipeline')do
+          assert_text 'No output'
+        end
+
+        assert_text 'completed container request'
+        within('.row-zzzzz-xvhdp-cr4completedctr')do
+          assert page.has_link? 'foo_file'
+        end
+      end
+
+      within('.compute-node-actions') do
+        if is_admin
+          assert page.has_link?('All nodes')
+        else
+          assert page.has_no_link?('All nodes')
+        end
+        assert page.has_link? 'All jobs'
+      end
 
-    assert_text 'Active processes' # seeing dashboard now
-    within('.active-processes') do
-      assert_text 'zzzzz-dz642-runningcontainr'
-      assert_text 'zzzzz-dz642-runningcontain2'
-      assert_text 'zzzzz-d1hrv-partdonepipelin'
-      assert_no_text 'zzzzz-d1hrv-twodonepipeline'
-      assert_no_text 'zzzzz-xvhdp-cr4queuedcontnr'
+      within('.compute-node-summary-pane') do
+        click_link 'Details'
+        assert_text 'compute0'
+      end
     end
-    within('.finished-processes') do
-      assert_text 'zzzzz-d1hrv-twodonepipeline'
-      assert_text 'zzzzz-dz642-compltcontainer'
-      assert_text 'zzzzz-dz642-compltcontainr2'
-      assert_no_text 'zzzzz-d1hrv-partdonepipelin'
-      assert_no_text 'zzzzz-dz642-runningcontainr'
+  end
+
+  [
+    ['jobs', 'running_job_with_components', true],
+    ['pipeline_instances', 'components_is_jobspec', false],
+    ['containers', 'running', false],
+    ['container_requests', 'running', true],
+  ].each do |type, fixture, cancelable|
+    test "cancel button for #{type}/#{fixture}" do
+      if cancelable
+        need_selenium 'to cancel'
+      end
+
+      obj = api_fixture(type)[fixture]
+      visit page_with_token "active", "/#{type}/#{obj['uuid']}"
+
+      assert_text 'created_at'
+      if cancelable
+        assert page.has_button?('Cancel'), 'No Cancel button'
+        click_button 'Cancel'
+        wait_for_ajax
+        assert page.has_no_button?('Cancel'), 'Cancel button not expected after clicking'
+      else
+        assert page.has_no_button?('Cancel'), 'Cancel button not expected'
+      end
     end
+  end
+
+  [
+    ['jobs', 'running_job_with_components'],
+    ['pipeline_instances', 'has_component_with_completed_jobs'],
+    ['container_requests', 'running'],
+    ['container_requests', 'completed'],
+  ].each do |type, fixture|
+    test "edit description for #{type}/#{fixture}" do
+      obj = api_fixture(type)[fixture]
+      visit page_with_token "active", "/#{type}/#{obj['uuid']}"
+
+      within('.arv-description-as-subtitle') do
+        find('.fa-pencil').click
+        find('.editable-input textarea').set('*Textile description for object*')
+        find('.editable-submit').click
+      end
+      wait_for_ajax
 
-    within('.compute-node-summary-pane') do
-      click_link 'Details'
-      assert_text 'zzzzz-dz642-lockedcontainer'
-      assert_text 'zzzzz-dz642-queuedcontainer'
-      assert_text '"foo" job submitted'
+      # verify description
+      assert page.has_no_text? '*Textile description for object*'
+      assert page.has_text? 'Textile description for object'
     end
   end
 end