9319: /all_processes index page.
authorradhika <radhika@curoverse.com>
Tue, 5 Jul 2016 23:13:13 +0000 (19:13 -0400)
committerradhika <radhika@curoverse.com>
Tue, 19 Jul 2016 20:03:08 +0000 (16:03 -0400)
33 files changed:
apps/workbench/app/assets/javascripts/infinite_scroll.js
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/projects_controller.rb
apps/workbench/app/controllers/work_units_controller.rb [new file with mode: 0644]
apps/workbench/app/models/pipeline_instance.rb
apps/workbench/app/models/proxy_work_unit.rb
apps/workbench/app/models/work_unit.rb
apps/workbench/app/views/application/_delete_object_button.html.erb
apps/workbench/app/views/container_requests/_show_log.html.erb
apps/workbench/app/views/container_requests/_show_status.html.erb
apps/workbench/app/views/containers/_show_log.html.erb
apps/workbench/app/views/containers/_show_status.html.erb
apps/workbench/app/views/jobs/_show_status.html.erb
apps/workbench/app/views/pipeline_instances/_show_components.html.erb
apps/workbench/app/views/projects/_show_dashboard.html.erb
apps/workbench/app/views/work_unit/_show_status.html.erb [deleted file]
apps/workbench/app/views/work_units/_component_detail.html.erb [moved from apps/workbench/app/views/work_unit/_component_detail.html.erb with 97% similarity]
apps/workbench/app/views/work_units/_progress.html.erb [moved from apps/workbench/app/views/work_unit/_progress.html.erb with 100% similarity]
apps/workbench/app/views/work_units/_show_all_processes.html.erb [new file with mode: 0644]
apps/workbench/app/views/work_units/_show_all_processes_rows.html.erb [new file with mode: 0644]
apps/workbench/app/views/work_units/_show_child.html.erb [moved from apps/workbench/app/views/work_unit/_show_child.html.erb with 89% similarity]
apps/workbench/app/views/work_units/_show_component.html.erb [moved from apps/workbench/app/views/work_unit/_show_component.html.erb with 89% similarity]
apps/workbench/app/views/work_units/_show_log.html.erb [moved from apps/workbench/app/views/work_unit/_show_log.html.erb with 100% similarity]
apps/workbench/app/views/work_units/_show_output.html.erb [new file with mode: 0644]
apps/workbench/app/views/work_units/_show_outputs.html.erb [moved from apps/workbench/app/views/work_unit/_show_outputs.html.erb with 100% similarity]
apps/workbench/app/views/work_units/_show_status.html.erb [new file with mode: 0644]
apps/workbench/app/views/work_units/index.html.erb [new file with mode: 0644]
apps/workbench/config/initializers/time_format.rb [new file with mode: 0644]
apps/workbench/config/routes.rb
apps/workbench/test/controllers/projects_controller_test.rb
apps/workbench/test/controllers/work_units_controller_test.rb [new file with mode: 0644]
apps/workbench/test/integration/application_layout_test.rb
apps/workbench/test/integration/work_units_test.rb [new file with mode: 0644]

index a0c9efc5231e5b2d27a66e6af6e1489770b12009..b89ac817cba242b6e25decae674420217e46c604 100644 (file)
@@ -130,6 +130,7 @@ function maybe_load_more_content(event) {
                 $container.find(".spinner").detach();
                 $container.append(data.content);
                 $container.attr('data-infinite-content-href', data.next_page_href);
+                ping_all_scrollers();
             });
      }
 }
index 648cae85a67006dc46e2410f3b7e3afc99637f8e..10c33c3f0af801520c6659aed2aade5d1e53cba7 100644 (file)
@@ -241,6 +241,28 @@ class ApplicationController < ActionController::Base
     end
   end
 
+  helper_method :next_page_filters
+  def next_page_filters nextpage_operator
+    next_page_filters = @filters.reject do |attr, op, val|
+      (attr == 'created_at' and op == nextpage_operator) or
+      (attr == 'uuid' and op == 'not in')
+    end
+
+    if @objects.any?
+      last_created_at = @objects.last.created_at
+
+      last_uuids = []
+      @objects.each do |obj|
+        last_uuids << obj.uuid if obj.created_at.eql?(last_created_at)
+      end
+
+      next_page_filters += [['created_at', nextpage_operator, last_created_at]]
+      next_page_filters += [['uuid', 'not in', last_uuids]]
+    end
+
+    next_page_filters
+  end
+
   def show
     if !@object
       return render_not_found("object not found")
index 3674e314a835742dc8071770fe771e41dcef7352..8ec8d5e1ddf33a620ef2f01705c6802f1150f6a4 100644 (file)
@@ -230,23 +230,9 @@ class ProjectsController < ApplicationController
       @objects = @objects.to_a.sort_by(&:created_at)
       @objects.reverse! if nextpage_operator == '<='
       @objects = @objects[0..@limit-1]
-      @next_page_filters = @filters.reject do |attr,op,val|
-        (attr == 'created_at' and op == nextpage_operator) or
-          (attr == 'uuid' and op == 'not in')
-      end
 
       if @objects.any?
-        last_created_at = @objects.last.created_at
-
-        last_uuids = []
-        @objects.each do |obj|
-          last_uuids << obj.uuid if obj.created_at.eql?(last_created_at)
-        end
-
-        @next_page_filters += [['created_at',
-                                nextpage_operator,
-                                last_created_at]]
-        @next_page_filters += [['uuid', 'not in', last_uuids]]
+        @next_page_filters = next_page_filters(nextpage_operator)
         @next_page_href = url_for(partial: :contents_rows,
                                   limit: @limit,
                                   filters: @next_page_filters.to_json)
diff --git a/apps/workbench/app/controllers/work_units_controller.rb b/apps/workbench/app/controllers/work_units_controller.rb
new file mode 100644 (file)
index 0000000..ff69d89
--- /dev/null
@@ -0,0 +1,37 @@
+class WorkUnitsController < ApplicationController
+  def find_objects_for_index
+    # If it's not the index rows partial display, just return
+    # The /index request will again be invoked to display the
+    # partial at which time, we will be using the objects found.
+    return if !params[:partial]
+
+    @limit = 20
+    @filters = @filters || []
+
+    # get next page of pipeline_instances
+    filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
+    pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
+
+    # get next page of jobs
+    filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
+    jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
+
+    # get next page of container_requests
+    filters = @filters + [["uuid", "is_a", ["arvados#containerRequest"]]]
+    crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters)
+    @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit)
+
+    if @objects.any?
+      @next_page_filters = next_page_filters('<=')
+      @next_page_href = url_for(partial: :all_processes_rows,
+                                filters: @next_page_filters.to_json)
+      preload_links_for_objects(@objects.to_a)
+    else
+      @next_page_href = nil
+    end
+  end
+
+  def next_page_href with_params={}
+    @next_page_href
+  end
+end
index b51f07c40b36e0324b09e14c81dbf632dbcd7a68..0541ce5d1792aee37fd6c40303a589a5637c128c 100644 (file)
@@ -13,7 +13,7 @@ class PipelineInstance < ArvadosBase
       template = if lookup and lookup[self.pipeline_template_uuid]
                    lookup[self.pipeline_template_uuid]
                  else
-                   PipelineTemplate.where(uuid: self.pipeline_template_uuid).first
+                   PipelineTemplate.find(self.pipeline_template_uuid) if self.pipeline_template_uuid
                  end
       if template
         template.name
index f672c8c64cea79c46e7dc99b8f1e37a3ce09c3a6..53b49085660e3d0a5b4c55dc63626f2818aa4fe3 100644 (file)
@@ -23,6 +23,10 @@ class ProxyWorkUnit < WorkUnit
     get(:modified_by_user_uuid)
   end
 
+  def owner_uuid
+    get(:owner_uuid)
+  end
+
   def created_at
     t = get(:created_at)
     t = Time.parse(t) if (t.is_a? String)
@@ -51,6 +55,8 @@ class ProxyWorkUnit < WorkUnit
     state = get(:state)
     if ["Running", "RunningOnServer", "RunningOnClient"].include? state
       "Running"
+    elsif state == 'New'
+      "Not started"
     else
       state
     end
index dee6a609c8ebd53672eb8ec255ab8c93d2da96ec..7b52365cfb9085baead007e69797451efbc38ae6 100644 (file)
@@ -17,6 +17,10 @@ class WorkUnit
     # returns uuid of the user who modified this work unit most recently
   end
 
+  def owner_uuid
+    # returns uuid of the owner of this work unit
+  end
+
   def created_at
     # returns created_at timestamp
   end
index 6ece8606a839a1e974386cffdcb081cc217faadf..744839c2d863c3dfa6abf2f12f7c2ab0123c07bc 100644 (file)
@@ -1,5 +1,5 @@
 <% if object.deletable? %>
-  <%= link_to({action: 'destroy', id: object.uuid}, method: :delete, remote: true, data: {confirm: "Really delete #{object.class_for_display.downcase} '#{object.friendly_link_name}'?"}) do %>
+  <%= link_to({controller: object.class.table_name, action: 'destroy', id: object.uuid}, method: :delete, remote: true, data: {confirm: "Really delete #{object.class_for_display.downcase} '#{object.friendly_link_name}'?"}) do %>
     <i class="glyphicon glyphicon-trash"></i>
   <% end %>
 <% end %>
index 4126f12a5dfea67238966cf7112cfc85a98cdf3b..f623fd6344393d665dc244b7beb81d3c420647dd 100644 (file)
@@ -1 +1 @@
-<%= render(partial: 'work_unit/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
+<%= render(partial: 'work_units/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
index d6d8c67ecc1f21e4faea88d589cddc4ac7a8508d..fc3f7be506e818b5d3cfb7dbab0ae9004f69a809 100644 (file)
@@ -1 +1 @@
-<%= render(partial: 'work_unit/show_status', locals: {current_obj: @object, name: @object[:name] || 'this container'}) %>
+<%= render(partial: 'work_units/show_status', locals: {current_obj: @object, name: @object[:name] || 'this container'}) %>
index 4126f12a5dfea67238966cf7112cfc85a98cdf3b..f623fd6344393d665dc244b7beb81d3c420647dd 100644 (file)
@@ -1 +1 @@
-<%= render(partial: 'work_unit/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
+<%= render(partial: 'work_units/show_log', locals: {obj: @object, name: @object[:name] || 'this container'}) %>
index 00a55926136172135087e835c64f01a183ebbc22..b6a23719345ad4712eb2a345f55690a6840471d1 100644 (file)
@@ -1,4 +1,4 @@
-<%= render(partial: 'work_unit/show_status', locals: {current_obj: @object, name: @object[:name] || 'this container'}) %>
+<%= render(partial: 'work_units/show_status', locals: {current_obj: @object, name: @object[:name] || 'this container'}) %>
 
 <div class="panel panel-default">
   <div class="panel-heading">
index 6b1ea03c2ba63ee0dfcaf9d183076b57519df64d..bb5444f238fb89df9eb477d8d8642c1dbbfaf240 100644 (file)
@@ -1,4 +1,4 @@
-<%= render(partial: 'work_unit/show_status', locals: {current_obj: @object, name: @object[:name] || 'this job'}) %>
+<%= render(partial: 'work_units/show_status', locals: {current_obj: @object, name: @object[:name] || 'this job'}) %>
 
 <div class="panel panel-default">
   <div class="panel-heading">
index 4196558b3c07570c2d0e84b059cba20145b4fa41..b79759f989181564dc380e4dce55bdd5c27f292d 100644 (file)
@@ -9,7 +9,7 @@
        data-object-uuids="<%= @object.uuid %> <%= job_uuids.join(' ') %>"
        ></div>
 
-  <%= render partial: 'work_unit/show_component', locals: {wu: @object.work_unit(@object.name)} %>
+  <%= render partial: 'work_units/show_component', locals: {wu: @object.work_unit(@object.name)} %>
 
 <% else %>
   <%# state is either New or Ready %>
index 6dfa1bc880ed13ee04cf3b0a5d0c57aad5eb1d4c..afca2468d7aa86193d349d1aefee9b6f82d1170f 100644 (file)
@@ -18,8 +18,8 @@
                 <% end %>
               </span>
               <span>
-                  <%= link_to pipeline_instances_path, class: 'btn btn-default btn-xs' do %>
-                    All pipelines <i class="fa fa-fw fa-arrow-circle-right"></i>
+                  <%= link_to all_processes_path, class: 'btn btn-default btn-xs' do %>
+                    All processes <i class="fa fa-fw fa-arrow-circle-right"></i>
                   <% end %>
               </span>
             </span>
                     Active for <%= render_runtime(wu_time, false) %>
                   <% end %>
 
-                  <span class="pull-right text-overflow-ellipsis" style="max-width: 100%">
-                    <% outputs = wu.outputs %>
-                    <% if outputs.size == 0 %>
-                      No output.
-                    <% elsif outputs.size == 1 %>
-                      <i class="fa fa-fw fa-archive"></i> <%= link_to_if_arvados_object outputs[0], friendly_name: true %>
-                    <% else %>
-                      <%= render partial: 'work_unit/show_outputs', locals: {id: wu.uuid, outputs: outputs, align:"pull-right"} %>
-                    <% end %>
-                  </span>
+                  <%= render partial: 'work_units/show_output', locals: {wu: wu, align: 'pull-right', include_icon: true} %>
                 </div>
               </div>
 
                 <% end %>
               </span>
             <% end %>
-            <span>
-              <%= link_to jobs_path, class: 'btn btn-default btn-xs' do %>
-                All jobs <i class="fa fa-fw fa-arrow-circle-right"></i>
-              <% end %>
-            </span>
           </span>
         </div>
         <div class="panel-body compute-node-summary-pane">
diff --git a/apps/workbench/app/views/work_unit/_show_status.html.erb b/apps/workbench/app/views/work_unit/_show_status.html.erb
deleted file mode 100644 (file)
index 0c1e80e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<div class="arv-log-refresh-control"
-     data-load-throttle="15000"
-     ></div>
-<%=
-   render(partial: 'work_unit/show_component', locals: {wu: current_obj.work_unit(name)})
-%>
similarity index 97%
rename from apps/workbench/app/views/work_unit/_component_detail.html.erb
rename to apps/workbench/app/views/work_units/_component_detail.html.erb
index ba9d3cee7b12b66f9f87a4a93f42373bfe861bf0..e15cc443a93ca9062b4edb8bc99554ca42e48c2b 100644 (file)
@@ -27,7 +27,7 @@
                       <% if val.size == 1 %>
                         <%= link_to_arvados_object_if_readable(val[0], 'Output data not available', friendly_name: true) %>
                       <% else %>
-                        <%= render partial: 'work_unit/show_outputs', locals: {id: current_obj.uuid, outputs: val, align:""} %>
+                        <%= render partial: 'work_units/show_outputs', locals: {id: current_obj.uuid, outputs: val, align:""} %>
                       <% end %>
                     <% else %>
                       <%= val %>
diff --git a/apps/workbench/app/views/work_units/_show_all_processes.html.erb b/apps/workbench/app/views/work_units/_show_all_processes.html.erb
new file mode 100644 (file)
index 0000000..ea17843
--- /dev/null
@@ -0,0 +1,51 @@
+<div class="container">
+  <div class="row">
+    <div class="pull-right">
+      <input type="text" class="form-control filterable-control recent-all-processes-filterable-control"
+             placeholder="Search all processes"
+             data-filterable-target="#all-processes-scroll"
+             value="<%= params[:search] %>">
+      </input>
+    </div>
+  </div>
+  <div>
+    <div>
+      <table class="table table-condensed table-fixedlayout arv-recent-all-processes">
+        <colgroup>
+          <col width="25%" />
+          <col width="10%" />
+          <col width="20%" />
+          <col width="20%" />
+          <col width="20%" />
+          <col width="5%" />
+        </colgroup>
+
+        <thead>
+          <tr class="contain-align-left">
+            <th>
+              Process
+            </th>
+            <th>
+              Status
+            </th>
+            <th>
+              Owner
+            </th>
+            <th>
+              Created at
+            </th>
+            <th>
+              Output
+            </th>
+            <th>
+            </th>
+          </tr>
+        </thead>
+
+        <tbody data-infinite-scroller="#all-processes-scroll" id="all-processes-scroll"
+               data-infinite-content-href="<%= url_for partial: :all_processes_rows %>" >
+        </tbody>
+      </table>
+    </div>
+  </div>
+</div>
diff --git a/apps/workbench/app/views/work_units/_show_all_processes_rows.html.erb b/apps/workbench/app/views/work_units/_show_all_processes_rows.html.erb
new file mode 100644 (file)
index 0000000..0652a9d
--- /dev/null
@@ -0,0 +1,23 @@
+<% @objects.each do |obj| %>
+  <% wu = obj.work_unit %>
+  <tr data-object-uuid="<%= wu.uuid %>" >
+    <td>
+      <%= link_to_if_arvados_object obj, friendly_name: true %>
+    </td>
+    <td>
+      <span class="label label-<%= wu.state_bootstrap_class %>"><%= wu.state_label %></span>
+    </td>
+    <td>
+      <%= link_to_if_arvados_object wu.owner_uuid, friendly_name: true %>
+    </td>
+    <td>
+      <%= render_localized_date(wu.created_at) %>
+    </td>
+    <td>
+      <%= render partial: 'work_units/show_output', locals: {wu: wu, align: ''} %>
+    </td>
+    <td>
+      <%= render partial: 'delete_object_button', locals: {object:obj} %>
+    </td>
+  </tr>
+<% end %>
similarity index 89%
rename from apps/workbench/app/views/work_unit/_show_child.html.erb
rename to apps/workbench/app/views/work_units/_show_child.html.erb
index a9c8d2f2268c632c4a1de4b811092fb7bc607265..1d5ae63785421d79fe3d7778a17b0a895b40ce0b 100644 (file)
@@ -11,7 +11,7 @@
         </div>
 
         <div class="col-md-2 pipeline-instance-spacing">
-          <%= render partial: 'work_unit/progress', locals: {wu: current_obj} %>
+          <%= render partial: 'work_units/progress', locals: {wu: current_obj} %>
         </div>
 
         <% if not current_obj %>
@@ -48,7 +48,7 @@
                 <% if outputs.size == 1 %>
                   <%= link_to_arvados_object_if_readable(outputs[0], 'Output data not available', link_text: "Output of #{current_obj.label}") %>
                 <% else %>
-                  <%= render partial: 'work_unit/show_outputs', locals: {id: current_obj.uuid, outputs: outputs, align:"pull-right"} %>
+                  <%= render partial: 'work_units/show_outputs', locals: {id: current_obj.uuid, outputs: outputs, align:"pull-right"} %>
                 <% end %>
               <% else %>
                 No output.
@@ -71,7 +71,7 @@
 
   <div id="collapse<%= i %>" class="panel-collapse collapse <%= if expanded then 'in' end %>">
     <div class="panel-body">
-      <%= render partial: 'work_unit/show_component', locals: {wu: current_obj} %>
+      <%= render partial: 'work_units/show_component', locals: {wu: current_obj} %>
     </div>
   </div>
 </div>
similarity index 89%
rename from apps/workbench/app/views/work_unit/_show_component.html.erb
rename to apps/workbench/app/views/work_units/_show_component.html.erb
index da3e5a787b18b1ef338f5dca1c45991911af9dfe..43f5692410ff8bf9116a162956a730e214c05f07 100644 (file)
@@ -14,7 +14,7 @@
             <% end %>
             </div>
             <div class="col-md-3">
-              <%= render partial: 'work_unit/progress', locals: {wu: wu} %>
+              <%= render partial: 'work_units/progress', locals: {wu: wu} %>
             </div>
             <div class="col-md-1">
               <% if wu.can_cancel? and @object.editable? %>
@@ -43,7 +43,7 @@
   </div>
 
 <p>
-  <%= render(partial: 'work_unit/component_detail', locals: {current_obj: wu}) %>
+  <%= render(partial: 'work_units/component_detail', locals: {current_obj: wu}) %>
 </p>
 
 <%# Work unit children %>
@@ -71,6 +71,6 @@
   <% @descendent_count = 0 if !@descendent_count %>
   <% wu.children.each do |c| %>
     <% @descendent_count += 1 %>
-    <%= render(partial: 'work_unit/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
+    <%= render(partial: 'work_units/show_child', locals: {current_obj: c, i: @descendent_count, expanded: false}) %>
   <% end %>
 <% end %>
diff --git a/apps/workbench/app/views/work_units/_show_output.html.erb b/apps/workbench/app/views/work_units/_show_output.html.erb
new file mode 100644 (file)
index 0000000..83dabd1
--- /dev/null
@@ -0,0 +1,13 @@
+<span class="<%=align%> text-overflow-ellipsis" style="max-width: 100%">
+  <% outputs = wu.outputs %>
+  <% if outputs.size == 0 %>
+    No output
+  <% elsif outputs.size == 1 %>
+    <% if defined?(include_icon) && include_icon %>
+      <i class="fa fa-fw fa-archive"></i>
+    <% end %>
+    <%= link_to_if_arvados_object outputs[0], friendly_name: true %>
+  <% else %>
+    <%= render partial: 'work_units/show_outputs', locals: {id: wu.uuid, outputs: outputs, align:align} %>
+  <% end %>
+</span>
diff --git a/apps/workbench/app/views/work_units/_show_status.html.erb b/apps/workbench/app/views/work_units/_show_status.html.erb
new file mode 100644 (file)
index 0000000..4b629c8
--- /dev/null
@@ -0,0 +1,6 @@
+<div class="arv-log-refresh-control"
+     data-load-throttle="15000"
+     ></div>
+<%=
+   render(partial: 'work_units/show_component', locals: {wu: current_obj.work_unit(name)})
+%>
diff --git a/apps/workbench/app/views/work_units/index.html.erb b/apps/workbench/app/views/work_units/index.html.erb
new file mode 100644 (file)
index 0000000..b6e978d
--- /dev/null
@@ -0,0 +1 @@
+<%= render partial: 'work_units/show_all_processes' %>
diff --git a/apps/workbench/config/initializers/time_format.rb b/apps/workbench/config/initializers/time_format.rb
new file mode 100644 (file)
index 0000000..d476781
--- /dev/null
@@ -0,0 +1,5 @@
+class ActiveSupport::TimeWithZone
+  def as_json *args
+    strftime "%Y-%m-%dT%H:%M:%S.%NZ"
+  end
+end
index 41614846791c8c091ad8e10ba492a15d7c666e5b..3a756e9939014cfc78d0053537641636e52d89cb 100644 (file)
@@ -13,6 +13,7 @@ ArvadosWorkbench::Application.routes.draw do
   get "report_issue_popup" => 'actions#report_issue_popup', :as => :report_issue_popup
   post "report_issue" => 'actions#report_issue', :as => :report_issue
   get "star" => 'actions#star', :as => :star
+  get "all_processes" => 'work_units#index', :as => :all_processes
   resources :nodes
   resources :humans
   resources :traits
index c0519bcedfd6457ed3aca4608cc6e14289a9c473..fa87e849a26ce01f2068675d33ff740f82418d89 100644 (file)
@@ -387,14 +387,26 @@ class ProjectsControllerTest < ActionController::TestCase
   end
 
   [
-    ["jobs", "/jobs"],
-    ["pipelines", "/pipeline_instances"],
-    ["collections", "/collections"],
-  ].each do |target,path|
-    test "test dashboard button all #{target}" do
-      get :index, {}, session_for(:active)
-      assert_includes @response.body, "href=\"#{path}\""
-      assert_includes @response.body, "All #{target}"
+    [:admin, true],
+    [:active, false],
+  ].each do |user, expect_all_nodes|
+    test "in dashboard other index page links as #{user}" do
+      get :index, {}, session_for(user)
+
+      [["processes", "/all_processes"],
+       ["collections", "/collections"],
+      ].each do |target, path|
+        assert_includes @response.body, "href=\"#{path}\""
+        assert_includes @response.body, "All #{target}"
+      end
+
+      if expect_all_nodes
+        assert_includes @response.body, "href=\"/nodes\""
+        assert_includes @response.body, "All nodes"
+      else
+        assert_not_includes @response.body, "href=\"/nodes\""
+        assert_not_includes @response.body, "All nodes"
+      end
     end
   end
 
diff --git a/apps/workbench/test/controllers/work_units_controller_test.rb b/apps/workbench/test/controllers/work_units_controller_test.rb
new file mode 100644 (file)
index 0000000..12e0271
--- /dev/null
@@ -0,0 +1,68 @@
+require 'test_helper'
+
+class WorkUnitsControllerTest < ActionController::TestCase
+  # These tests don't do state-changing API calls.
+  # Save some time by skipping the database reset.
+  reset_api_fixtures :after_each_test, false
+  reset_api_fixtures :after_suite, true
+
+  [
+    ['foo', 10, 25,
+      ['/pipeline_instances/zzzzz-d1hrv-1xfj6xkicf2muk2',
+       '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+       '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7'],
+      ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
+       '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+       '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
+    ['pipeline_with_tagged_collection_input', 1, 1,
+      ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3'],
+      ['/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+       '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
+       '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+       '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
+    ['no_such_match', 0, 0,
+      [],
+      ['/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+       '/jobs/zzzzz-8i9sb-pshmckwoma9plh7',
+       '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+       '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
+  ].each do |search_filter, expected_min, expected_max, expected, not_expected|
+    test "all_processes page for search filter '#{search_filter}'" do
+      work_units_index(filters: [['any','@@', search_filter]])
+      assert_response :success
+
+      # Verify that expected number of processes are found
+      found_count = json_response['content'].scan('<tr').count
+      if expected_min == expected_max
+        assert_equal(true, found_count == expected_min,
+          "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
+      else
+        assert_equal(true, found_count>=expected_min,
+          "Found too few items. Expected at least #{expected_min} and found #{found_count}")
+        assert_equal(true, found_count<=expected_max,
+          "Found too many items. Expected at most #{expected_max} and found #{found_count}")
+      end
+
+      # verify that all expected uuid links are found
+      expected.each do |link|
+        assert_match /href="#{link}"/, json_response['content']
+      end
+
+      # verify that none of the not_expected uuid links are found
+      not_expected.each do |link|
+        assert_no_match /href="#{link}"/, json_response['content']
+      end
+    end
+  end
+
+  def work_units_index params
+    params = {
+      partial: :all_processes_rows,
+      format: :json,
+    }.merge(params)
+    encoded_params = Hash[params.map { |k,v|
+                            [k, (v.is_a?(Array) || v.is_a?(Hash)) ? v.to_json : v]
+                          }]
+    get :index, encoded_params, session_for(:active)
+  end
+end
index 61905f31b2e21b9735755ab4715263f1e93ab6bc..40ec31d74e47eacedd672ee9f4ef8064b629a3ad 100644 (file)
@@ -252,7 +252,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
       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')
+        assert page.has_link?('All processes')
       end
 
       within('.recent-processes') do
@@ -278,7 +278,6 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
         else
           assert page.has_no_link?('All nodes')
         end
-        assert page.has_link? 'All jobs'
       end
 
       within('.compute-node-summary-pane') do
diff --git a/apps/workbench/test/integration/work_units_test.rb b/apps/workbench/test/integration/work_units_test.rb
new file mode 100644 (file)
index 0000000..63ba275
--- /dev/null
@@ -0,0 +1,58 @@
+require 'integration_helper'
+
+class WorkUnitsTest < ActionDispatch::IntegrationTest
+  setup do
+    need_javascript
+  end
+
+  test "scroll all_processes page" do
+      expected_min, expected_max, expected, not_expected = [
+        25, 100,
+        ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
+         '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+         '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
+         '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+         '/container_requests/zzzzz-xvhdp-cr4completedcr2',
+         '/container_requests/zzzzz-xvhdp-cr4requestercn2'],
+        ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
+         '/container_requests/zzzzz-xvhdp-oneof60crs00001']
+      ]
+
+      visit page_with_token('active', "/all_processes")
+
+      page_scrolls = expected_max/20 + 2
+      within('.arv-recent-all-processes') do
+        (0..page_scrolls).each do |i|
+          page.driver.scroll_to 0, 999000
+          begin
+            wait_for_ajax
+          rescue
+          end
+        end
+      end
+
+      # Verify that expected number of processes are found
+      found_items = page.all('tr[data-object-uuid]')
+      found_count = found_items.count
+      if expected_min == expected_max
+        assert_equal(true, found_count == expected_min,
+          "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
+        assert page.has_no_text? 'request failed'
+      else
+        assert_equal(true, found_count>=expected_min,
+          "Found too few items. Expected at least #{expected_min} and found #{found_count}")
+        assert_equal(true, found_count<=expected_max,
+          "Found too many items. Expected at most #{expected_max} and found #{found_count}")
+      end
+
+      # verify that all expected uuid links are found
+      expected.each do |link|
+        assert_selector "a[href=\"#{link}\"]"
+      end
+
+      # verify that none of the not_expected uuid links are found
+      not_expected.each do |link|
+        assert_no_selector "a[href=\"#{link}\"]"
+      end
+  end
+end