Skip to content

Commit

Permalink
use valkyrie for setup on spec/features/browse_dashboard_works_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
tamsin johnson authored and dunn committed Oct 31, 2023
1 parent 4bf29bd commit 4ba0f32
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions spec/features/browse_dashboard_works_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
# frozen_string_literal: true
RSpec.describe "Browse Dashboard", type: :feature do
let(:user) { create(:user) }
RSpec.describe "Browse Dashboard", :clean_repo, type: :feature do
let(:user) { FactoryBot.create(:user) }

let!(:dissertation) do
create(:public_work, user: user, title: ["Fake PDF Title"], subject: %w[lorem ipsum dolor sit amet])
FactoryBot.valkyrie_create(:monograph,
:public,
depositor: user.user_key,
edit_users: [user],
title: ["Fake PDF Title"],
subject: %w[lorem ipsum dolor sit amet])
end

let!(:mp3_work) do
create(:public_work, user: user, title: ["Test Document MP3"], subject: %w[consectetur adipisicing elit])
FactoryBot.valkyrie_create(:monograph,
:public,
depositor: user.user_key,
edit_users: [user],
title: ["Test Document MP3"],
subject: %w[consectetur adipisicing elit])
end

let!(:wav_work) do
FactoryBot.valkyrie_create(:monograph,
:public,
depositor: user.user_key,
edit_users: [user],
title: ["Fake Wav Files"],
subject: %w[sed do eiusmod tempor incididunt ut labore])
end

before do
# Grant the user access to deposit into an admin set.
create(:permission_template_access,
:deposit,
permission_template: create(:permission_template, with_admin_set: true),
agent_type: 'user',
agent_id: user.user_key)
FactoryBot.create(:permission_template_access,
:deposit,
permission_template: create(:permission_template, with_admin_set: true),
agent_type: 'user',
agent_id: user.user_key)

sign_in user
create(:public_work, user: user, title: ["Fake Wav Files"], subject: %w[sed do eiusmod tempor incididunt ut labore])

visit "/dashboard/my/works"
end

Expand All @@ -37,7 +58,7 @@
click_link "Published"
within("#document_#{mp3_work.id}") do
expect(page).to have_link("Display all details of Test Document MP3",
href: hyrax_generic_work_path(mp3_work, locale: 'en'))
href: hyrax_monograph_path(mp3_work, locale: 'en'))
end
click_link("Remove constraint Status: Published")

Expand All @@ -49,9 +70,10 @@

it "allows me to delete works in upload_sets", js: true do
first('input#check_all').click

expect do
accept_confirm { click_button('Delete Selected') }
expect(page).to have_content('Batch delete complete')
end.to change { GenericWork.count }.by(-3)
end.to change { Hyrax.query_service.count_all_of_model(model: Monograph) }.by(-3)
end
end

0 comments on commit 4ba0f32

Please sign in to comment.