5622: add test for infinite scrolling for hash matches page.
authorRadhika Chippada <radhika@curoverse.com>
Sun, 26 Apr 2015 22:01:25 +0000 (18:01 -0400)
committerRadhika Chippada <radhika@curoverse.com>
Sun, 26 Apr 2015 22:01:25 +0000 (18:01 -0400)
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/test/integration/collections_test.rb

index 9d8932f85b4c2c9fac061ea4036cfcbdf0945eef..badb38a132a6417ba2b7f80317cacffb12315c19 100644 (file)
@@ -18,10 +18,13 @@ class CollectionsController < ApplicationController
   RELATION_LIMIT = 5
 
   def show_pane_list
-    return @panes if @panes.andand.any?
-    @panes = %w(Files Upload Provenance_graph Used_by Advanced)
-    @panes = @panes - %w(Upload) unless (@object.editable? rescue false)
-    @panes
+    if current_user and CollectionsHelper.match(@object.uuid)
+      panes = %w(Hash_matches)
+    else
+      panes = %w(Files Upload Provenance_graph Used_by Advanced)
+      panes = panes - %w(Upload) unless (@object.editable? rescue false)
+      panes
+    end
   end
 
   def set_persistent
@@ -238,7 +241,6 @@ class CollectionsController < ApplicationController
         end
 
         # This pdh has more than one uuid matching. Show the hash matches page listing those uuids.
-        @panes = %w(Hash_matches)
       else
         jobs_with = lambda do |conds|
           Job.limit(RELATION_LIMIT).where(conds)
@@ -277,11 +279,14 @@ class CollectionsController < ApplicationController
   end
 
   def tab_counts
-    @limit = 1
-    @filters = [["portable_data_hash", "=", @object.portable_data_hash]]
-    @objects = find_objects_for_index
     @tab_counts = {}
-    @tab_counts['Hash_matches'] = @objects.andand.items_available
+    if show_pane_list.include? "Hash_matches"
+      @limit = 1
+      @filters = [["portable_data_hash", "=", @object.portable_data_hash]]
+      @objects = find_objects_for_index
+      @tab_counts['Hash_matches'] = @objects.andand.items_available
+    end
+    @tab_counts
   end
 
   def sharing_popup
index 96e1d471322926427d1f8f892d37ec46024b096b..25998ccca95af4bcec0305b4b581045d6f1ad52d 100644 (file)
@@ -225,6 +225,30 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     assert page.has_no_text?("Sharing and permissions")
   end
 
+  test "Collection portable data hash with more than one page of multiple matches" do
+    pdh = api_fixture('collections')['baz_file']['portable_data_hash']
+    visit page_with_token('admin', "/collections/#{pdh}")
+
+    matches = api_fixture('collections').select {|k,v| v["portable_data_hash"] == pdh}
+    assert matches.size > 1
+
+    (0..10).each do
+      within(".arv-collection-Hash_matches") do
+        page.execute_script "window.scrollBy(0,999000)"
+        begin
+          wait_for_ajax
+        rescue
+        end
+      end
+    end
+
+    matches.each do |k,v|
+      assert page.has_link?(v["name"]), "Page /collections/#{pdh} should contain link '#{v['name']}'"
+    end
+    assert page.has_no_text?("Activity")
+    assert page.has_no_text?("Sharing and permissions")
+  end
+
   test "Filtering collection files by regexp" do
     col = api_fixture('collections', 'multilevel_collection_1')
     visit page_with_token('active', "/collections/#{col['uuid']}")