From 648bcf7dda3a68d09bec6f7d6473c8996697f7cd Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Sun, 26 Apr 2015 18:01:25 -0400 Subject: [PATCH] 5622: add test for infinite scrolling for hash matches page. --- .../app/controllers/collections_controller.rb | 23 +++++++++++------- .../test/integration/collections_test.rb | 24 +++++++++++++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 9d8932f85b..badb38a132 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -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 diff --git a/apps/workbench/test/integration/collections_test.rb b/apps/workbench/test/integration/collections_test.rb index 96e1d47132..25998ccca9 100644 --- a/apps/workbench/test/integration/collections_test.rb +++ b/apps/workbench/test/integration/collections_test.rb @@ -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']}") -- 2.30.2