10037: Test enhancement to check for other statuses on the dashboard, also adding...
authorLucas Di Pentima <lucas@curoverse.com>
Thu, 22 Sep 2016 15:31:23 +0000 (12:31 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Thu, 22 Sep 2016 15:31:23 +0000 (12:31 -0300)
apps/workbench/test/controllers/projects_controller_test.rb

index 7848444efdeb84bcd2fc375ee6806b096b2153c9..741fa7afe1babfa58783258c203f8ca994c7b64c 100644 (file)
@@ -410,18 +410,55 @@ class ProjectsControllerTest < ActionController::TestCase
     end
   end
 
-  test "in dashboard the progress bar should only show on running containers" do
+  test "dashboard should show the correct status for containers and processes" do
     get :index, {}, session_for(:active)
     assert_select 'div.panel-body.recent-processes' do
       [
-        ['completed', false],
-        ['uncommitted', false],
-        ['queued', false],
-        ['running', true],
-      ].each do |cr_state, should_show|
-        uuid = api_fixture('container_requests')[cr_state]['uuid']
+        {
+          fixture: 'container_requests',
+          state: 'completed',
+          selectors: [['div.progress', false],
+                      ['span.label.label-success', true, 'Complete']]
+        },
+        {
+          fixture: 'container_requests',
+          state: 'uncommitted',
+          selectors: [['div.progress', false],
+                      ['span.label.label-default', true, 'Uncommitted']]
+        },
+        {
+          fixture: 'container_requests',
+          state: 'queued',
+          selectors: [['div.progress', false],
+                      ['span.label.label-default', true, 'Queued']]
+        },
+        {
+          fixture: 'container_requests',
+          state: 'running',
+          selectors: [['div.progress', true]]
+        },
+        {
+          fixture: 'pipeline_instances',
+          state: 'new_pipeline',
+          selectors: [['div.progress', false],
+                      ['span.label.label-default', true, 'Not started']]
+        },
+        {
+          fixture: 'pipeline_instances',
+          state: 'pipeline_in_running_state',
+          selectors: [['div.progress', true]]
+        },
+      ].each do |c|
+        uuid = api_fixture(c[:fixture])[c[:state]]['uuid']
         assert_select "div.dashboard-panel-info-row.row-#{uuid}" do
-          assert_select 'div.progress', should_show
+          if c.include? :selectors
+            c[:selectors].each do |selector, should_show, label|
+              assert_select selector, should_show, "UUID #{uuid} should #{should_show ? '' : 'not'} show '#{selector}'"
+              if should_show and not label.nil?
+                assert_select selector, label, "UUID #{uuid} state label should show #{label}"
+              end
+            end
+          end
         end
       end
     end