Skip to content

Commit

Permalink
Merge pull request #6412 from samvera/valk-col-feat-spec
Browse files Browse the repository at this point in the history
Valkyrize collection feature spec
  • Loading branch information
dlpierce authored Nov 3, 2023
2 parents 5eeb009 + 2ea1dd0 commit 3e3e134
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def show

respond_to do |format|
format.html
format.json { render json: @curation_concern }
format.json { render 'hyrax/base/show' }
end
end

Expand Down
49 changes: 36 additions & 13 deletions spec/features/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,49 @@
RSpec.describe 'collection', type: :feature do
let(:user) { FactoryBot.create(:user) }

let(:collection1) { FactoryBot.create(:public_collection_lw, user: user) }
let(:collection2) { FactoryBot.create(:public_collection_lw, user: user) }

before { sign_in(user) }

# Ensure CollectionResource is the collection model so it is not excluded by solr search builder filters.
# This can likely be removed alongside Wings.
around(:each) do |example|
current_collection_model = Hyrax.config.collection_model
Hyrax.config.collection_model = 'CollectionResource'
example.run
Hyrax.config.collection_model = current_collection_model
end

shared_context 'with many indexed members' do
let(:collection) { FactoryBot.create(:named_collection_lw, user: user) }
let(:collection) { FactoryBot.valkyrie_create(:collection_resource, user: user, title: ['collection title'], description: ['collection description']) }

before do
docs = (0..12).map do |n|
{ "has_model_ssim" => [model_name], :id => "zs25x871q#{n}",
"title_tesim" => ["Test Resource #{n}"],
"system_modified_dtsi" => Time.new(2023, 11, 2, n).utc,
"depositor_ssim" => [user.user_key],
"suppressed_bsi" => false,
"member_of_collection_ids_ssim" => [collection.id],
"nesting_collection__parent_ids_ssim" => [collection.id],
"member_of_collection_ids_ssim" => [collection.id.to_s],
"nesting_collection__parent_ids_ssim" => [collection.id.to_s],
"edit_access_person_ssim" => [user.user_key] }
end
docs.shuffle!
Hyrax::SolrService.add(docs, commit: true)
end
end

describe 'collection show page' do
let(:collection) do
FactoryBot.create(:public_collection_lw, user: user, description: ['collection description'], collection_type_settings: :nestable)
FactoryBot.valkyrie_create(:collection_resource,
user: user,
description: ['collection description'],
collection_type_gid: collection_type.to_global_id.to_s,
members: [work1, work2, col1, col2])
end
let!(:work1) { FactoryBot.create(:work, title: ["King Louie"], member_of_collections: [collection], user: user) }
let!(:work2) { FactoryBot.create(:work, title: ["King Kong"], member_of_collections: [collection], user: user) }
let!(:col1) { FactoryBot.create(:public_collection_lw, title: ["Sub-collection 1"], member_of_collections: [collection], user: user) }
let!(:col2) { FactoryBot.create(:public_collection_lw, title: ["Sub-collection 2"], member_of_collections: [collection], user: user) }
let(:collection_type) { FactoryBot.create(:collection_type, :nestable) }
let(:work1) { FactoryBot.valkyrie_create(:monograph, title: ["King Louie"], read_users: [user]) }
let(:work2) { FactoryBot.valkyrie_create(:monograph, title: ["King Kong"], read_users: [user]) }
let(:col1) { FactoryBot.valkyrie_create(:collection_resource, title: ["Sub-collection 1"], read_users: [user]) }
let(:col2) { FactoryBot.valkyrie_create(:collection_resource, title: ["Sub-collection 2"], read_users: [user]) }

it "shows a collection with a listing of Descriptive Metadata and catalog-style search results" do
visit "/collections/#{collection.id}"
Expand Down Expand Up @@ -84,8 +98,12 @@

context "with a non-nestable collection type" do
let(:collection) do
FactoryBot.create(:public_collection_lw, user: user, description: ['collection description'], collection_type_settings: :not_nestable, with_solr_document: true, with_permission_template: true)
FactoryBot.valkyrie_create(:collection_resource,
user: user,
description: ['collection description'],
collection_type_gid: collection_type.to_global_id.to_s)
end
let(:collection_type) { FactoryBot.create(:collection_type, :not_nestable) }

it "displays basic information on its show page" do
visit "/collections/#{collection.id}"
Expand All @@ -105,12 +123,17 @@
visit "/collections/#{collection.id}"

expect(page).to have_css(".pagination")

select('date modified ▲', from: 'Sort')
click_button 'Refresh'

expect(page).to have_text(/Test Resource 0.+1.+2.+3.+4.+5.+6.+7.+8.+9/m)
end
end

describe 'show subcollection pages of a collection' do
include_context 'with many indexed members' do
let(:model_name) { 'Collection' }
let(:model_name) { 'CollectionResource' }
end

it "shows a collection with a listing of Descriptive Metadata and catalog-style search results" do
Expand Down

0 comments on commit 3e3e134

Please sign in to comment.