Skip to content

Commit

Permalink
Merge pull request #6589 from samvera/updates_create_collection_spec
Browse files Browse the repository at this point in the history
Accounts for Koppie-specific behavior in `spec/features/create_collection_spec.rb`.
  • Loading branch information
dlpierce authored Jan 8, 2024
2 parents 4ea8074 + d786a6e commit a4661b9
Showing 1 changed file with 86 additions and 104 deletions.
190 changes: 86 additions & 104 deletions spec/features/create_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
end

it 'user is not offered the option to create that type of collection' do
# try and create the new admin set
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
test_for_lack_of_manage_collection
end
end

Expand All @@ -43,11 +39,7 @@
end

it 'user is not offered the option to create that type of collection' do
# try and create the new admin set
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
test_for_lack_of_manage_collection
end
end
end
Expand All @@ -60,46 +52,21 @@

it 'creates the collection' do
# create the new collection
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).to have_xpath("//h4", text: "Managed Collection")
choose "collection_type", option: "ManagedCollection"
click_button 'Create collection'
fill_in('Title', with: 'A Managed Collection')
checks_presence_of_standard_options
choose_managed_and_fill_common
fill_in('Description', with: "This collection was created by #{creator.user_key}")
click_on('Save')
expect(page).to have_content("Collection was successfully created.")

# navigate to show page for the new collection
visit '/dashboard'
click_link('Collections', match: :first)
click_on('Display all details of A Managed Collection')

# confirm creating user can view and edit the new collection
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
persist_and_confirm_managed_collection
expect(page).to have_content("This collection was created by #{creator.user_key}")
expect(page).to have_link("Edit collection")

# confirm admin can view and edit the new collection
logout
sign_in admin
click_link('Collections', match: :first)
click_link 'All Collections'
click_on('Display all details of A Managed Collection')
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
log_in_admin_get_all_collections
display_all_and_confirm_standard_content
expect(page).to have_content("This collection was created by #{creator.user_key}")
expect(page).to have_link("Edit collection")

# confirm a collection type manager can view and edit the new collection
logout
sign_in manager
click_link('Collections', match: :first)
click_link 'Managed Collections'
click_on('Display all details of A Managed Collection')
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
log_in_manager_get_their_collections
display_all_and_confirm_standard_content
expect(page).to have_content("This collection was created by #{creator.user_key}")
expect(page).to have_link("Edit collection")
end
end

Expand All @@ -111,43 +78,18 @@

it 'creates the collection' do
# create the new collection
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).to have_xpath("//h4", text: "Managed Collection")
choose "collection_type", option: "ManagedCollection"
click_button 'Create collection'
fill_in('Title', with: 'A Managed Collection')
checks_presence_of_standard_options
choose_managed_and_fill_common
fill_in('Description', with: "This collection was created by #{manager.user_key}")
click_on('Save')
expect(page).to have_content("Collection was successfully created.")

# navigate to show page for the new collection
visit '/dashboard'
click_link('Collections', match: :first)
click_on('Display all details of A Managed Collection')

# confirm creating user can view and edit the new collection
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
persist_and_confirm_managed_collection
expect(page).to have_content("This collection was created by #{manager.user_key}")
expect(page).to have_link("Edit collection")

# confirm admin can view and edit the new collection
logout
sign_in admin
click_link('Collections', match: :first)
click_link 'All Collections'
click_on('Display all details of A Managed Collection')
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
log_in_admin_get_all_collections
display_all_and_confirm_standard_content
expect(page).to have_content("This collection was created by #{manager.user_key}")
expect(page).to have_link("Edit collection")

# confirm a collection type creator can not view the new collection
logout
sign_in creator
click_link('Collections', match: :first)
expect(page).not_to have_content('Managed Collections')
expect(page).not_to have_content('A Managed Collection')
checks_lack_of_managed_options
end
end
end
Expand All @@ -160,43 +102,83 @@

it 'creates the collection' do
# create the new collection
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
expect(page).to have_xpath("//h4", text: "Managed Collection")
choose "collection_type", option: "ManagedCollection"
click_button 'Create collection'
fill_in('Title', with: 'A Managed Collection')
checks_presence_of_standard_options
choose_managed_and_fill_common
fill_in('Description', with: "This collection was created by #{admin.user_key}")
click_on('Save')
expect(page).to have_content("Collection was successfully created.")

# navigate to show page for the new collection
visit '/dashboard'
click_link('Collections', match: :first)
click_on('Display all details of A Managed Collection')

# confirm creating user can view and edit the new collection
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
persist_and_confirm_managed_collection
expect(page).to have_content("This collection was created by #{admin.user_key}")
expect(page).to have_link("Edit collection")

# confirm a collection type manager can view and edit the new collection
logout
sign_in manager
click_link('Collections', match: :first)
click_link 'Managed Collections'
click_on('Display all details of A Managed Collection')
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
log_in_manager_get_their_collections
display_all_and_confirm_standard_content
expect(page).to have_content("This collection was created by #{admin.user_key}")
expect(page).to have_link("Edit collection")

# confirm a collection type creator can not view the new collection
logout
sign_in creator
click_link('Collections', match: :first)
expect(page).not_to have_content('Managed Collections')
expect(page).not_to have_content('A Managed Collection')
checks_lack_of_managed_options
end
end

def checks_lack_of_managed_options
# confirm a collection type creator can not view the new collection
logout
sign_in creator
click_link('Collections', match: :first)

expect(page).not_to have_content('Managed Collections')
expect(page).not_to have_content('A Managed Collection')
end

def checks_presence_of_standard_options
find('#add-new-collection-button').click
expect(page).to have_xpath("//h4", text: "User Collection")
expect(page).to have_xpath("//h4", text: "Other")
end

def choose_managed_and_fill_common
expect(page).to have_xpath("//h4", text: "Managed Collection")
choose "collection_type", option: "ManagedCollection"
click_button 'Create collection'
fill_in('Title', with: 'A Managed Collection')
fill_in('Creator', with: 'Doe, Jane') if Hyrax.config.disable_wings
find('a.btn.btn-secondary.additional-fields').click
end

def persist_and_confirm_managed_collection
click_on('Save')
expect(page).to have_content("Collection was successfully created.")

# navigate to show page for the new collection
visit '/dashboard'
click_link('Collections', match: :first)
click_on('Display all details of A Managed Collection')

# confirm creating user can view and edit the new collection
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
expect(page).to have_link("Edit collection")
end

def display_all_and_confirm_standard_content
click_on('Display all details of A Managed Collection')
expect(page).to have_xpath('//h2', text: 'A Managed Collection')
expect(page).to have_link("Edit collection")
end

def log_in_manager_get_their_collections
logout
sign_in manager
click_link('Collections', match: :first)
click_link 'Managed Collections'
end

def log_in_admin_get_all_collections
logout
sign_in admin
click_link('Collections', match: :first)
click_link 'All Collections'
end

def test_for_lack_of_manage_collection
# try and create the new admin set
checks_presence_of_standard_options
expect(page).not_to have_xpath("//h4", text: "Managed Collection")
end
end

0 comments on commit a4661b9

Please sign in to comment.