Skip to content

Commit

Permalink
Merge pull request #492 from gwu-libraries/initial-tests
Browse files Browse the repository at this point in the history
Initial tests
  • Loading branch information
alepbloyd authored Jan 23, 2024
2 parents 5909556 + 279de7c commit 3b12696
Show file tree
Hide file tree
Showing 20 changed files with 466 additions and 156 deletions.
9 changes: 0 additions & 9 deletions spec/actors/hyrax/actors/gw_etd_actor_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/actors/hyrax/actors/gw_work_actor_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/controllers/hyrax/gw_etds_controller_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/controllers/hyrax/gw_works_controller_spec.rb

This file was deleted.

33 changes: 0 additions & 33 deletions spec/features/create_gw_etd_spec.rb

This file was deleted.

26 changes: 0 additions & 26 deletions spec/features/create_gw_work_spec.rb

This file was deleted.

81 changes: 81 additions & 0 deletions spec/features/dashboard_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
require 'rails_helper'

RSpec.describe "Dashboard page" do

it 'displays all admin controls when logged in as an admin user' do
admin_user = FactoryBot.create(:admin_user)

visit "/users/sign_in"

fill_in("user_email", with: admin_user.email)
fill_in("user_password", with: admin_user.password)

click_button("Log in")

within ".sidebar" do
expect(page).to have_content("Dashboard")
expect(page).to have_content("Your activity")
expect(page).to have_content("Profile")
expect(page).to have_content("Notifications")
expect(page).to have_content("Transfers")
expect(page).to have_content("Manage Proxies")

expect(page).to have_content("Statistics")

expect(page).to have_content("Collections")
expect(page).to have_content("Works")
expect(page).to have_content("Importers")
expect(page).to have_content("Exporters")

expect(page).to have_content("Review Submissions")
expect(page).to have_content("Manage Embargoes")
expect(page).to have_content("Manage Leases")

expect(page).to have_content("Appearance")
expect(page).to have_content("Collection Types")
expect(page).to have_content("Pages")
expect(page).to have_content("Content Blocks")
expect(page).to have_content("Features")

expect(page).to have_content("Workflow Roles")
end
end

it 'displays all content-admin controls when logged in as a content-admin user' do
content_admin_user = FactoryBot.create(:content_admin_user)

visit "/users/sign_in"

fill_in("user_email", with: content_admin_user.email)
fill_in("user_password", with: content_admin_user.password)

click_button("Log in")

within ".sidebar" do
expect(page).to have_content("Dashboard")
expect(page).to have_content("Your activity")
expect(page).to have_content("Profile")
expect(page).to have_content("Notifications")
expect(page).to have_content("Transfers")
expect(page).to have_content("Manage Proxies")
expect(page).to have_content("Collections")
expect(page).to have_content("Works")
expect(page).to have_content("Importers")
expect(page).to have_content("Exporters")

expect(page).to_not have_content("Statistics")
expect(page).to_not have_content("Review Submissions")
expect(page).to_not have_content("Manage Embargoes")
expect(page).to_not have_content("Manage Leases")

expect(page).to_not have_content("Appearance")
expect(page).to_not have_content("Collection Types")
expect(page).to_not have_content("Pages")
expect(page).to_not have_content("Content Blocks")
expect(page).to_not have_content("Features")

expect(page).to_not have_content("Workflow Roles")
end
end

end
39 changes: 39 additions & 0 deletions spec/features/deposit_pdf_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'rails_helper'

RSpec.describe "Deposit a PDF through dashboard" do

let(:admin_user) { FactoryBot.create(:admin_user) }
let(:pdf_path) { "#{Rails.root}/spec/fixtures/public_etds/hamlet.pdf" }

it 'can deposit a pdf' do
visit "/users/sign_in"

fill_in("user_email", with: admin_user.email)
fill_in("user_password", with: admin_user.password)
click_button("Log in")

visit new_hyrax_gw_etd_path

fill_in('gw_etd_title', with: "This is a PDF ETD")
select('Article', from: 'gw_etd_resource_type')
fill_in('gw_etd_creator', with: "Sandwich P. Kitty")
select('Attribution 4.0 International', from: 'gw_etd_license')
select('In Copyright', from: 'gw_etd_rights_statement')

click_link "Files"

within "#add-files" do
attach_file("files[]", pdf_path, visible: false)
end

find('body').click
choose('gw_etd_visibility_open')
check('agreement')

click_on('Save')

expect(page).to have_content("Your files are being processed by ScholarSpace in the background.")
expect(page).to have_content("This is a PDF ETD")
end

end
Loading

0 comments on commit 3b12696

Please sign in to comment.