diff --git a/spec/actors/hyrax/actors/gw_etd_actor_spec.rb b/spec/actors/hyrax/actors/gw_etd_actor_spec.rb deleted file mode 100644 index 36da553b..00000000 --- a/spec/actors/hyrax/actors/gw_etd_actor_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwEtd` -require 'rails_helper' - -RSpec.describe Hyrax::Actors::GwEtdActor do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/actors/hyrax/actors/gw_work_actor_spec.rb b/spec/actors/hyrax/actors/gw_work_actor_spec.rb deleted file mode 100644 index 353606c2..00000000 --- a/spec/actors/hyrax/actors/gw_work_actor_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwWork` -require 'rails_helper' - -RSpec.describe Hyrax::Actors::GwWorkActor do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/controllers/hyrax/gw_etds_controller_spec.rb b/spec/controllers/hyrax/gw_etds_controller_spec.rb deleted file mode 100644 index 5c57917e..00000000 --- a/spec/controllers/hyrax/gw_etds_controller_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwEtd` -require 'rails_helper' - -RSpec.describe Hyrax::GwEtdsController do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/controllers/hyrax/gw_works_controller_spec.rb b/spec/controllers/hyrax/gw_works_controller_spec.rb deleted file mode 100644 index 37771f4a..00000000 --- a/spec/controllers/hyrax/gw_works_controller_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwWork` -require 'rails_helper' - -RSpec.describe Hyrax::GwWorksController do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/features/create_gw_etd_spec.rb b/spec/features/create_gw_etd_spec.rb deleted file mode 100644 index 5f2e3cf4..00000000 --- a/spec/features/create_gw_etd_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwEtd` -require 'rails_helper' -include Warden::Test::Helpers - -# NOTE: If you generated more than one work, you have to set "js: true" -RSpec.feature 'Create a GwEtd', js: false do - context 'a logged in user' do - let(:user_attributes) do - { email: 'test@example.com' } - end - let(:user) do - User.new(user_attributes) { |u| u.save(validate: false) } - end - - before do - AdminSet.find_or_create_default_admin_set_id - login_as user - end - - scenario do - visit '/dashboard' - click_link "Works" - click_link "Add new work" - - # If you generate more than one work uncomment these lines - # choose "payload_concern", option: "GwEtd" - # click_button "Create work" - - expect(page).to have_content "Add New Gw etd" - end - end -end diff --git a/spec/features/create_gw_work_spec.rb b/spec/features/create_gw_work_spec.rb deleted file mode 100644 index 1b136342..00000000 --- a/spec/features/create_gw_work_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwWork` -require 'rails_helper' -include Warden::Test::Helpers - -RSpec.feature 'Create a GwWork' do - context 'a logged in user' do - let(:user_attributes) do - { email: 'test@example.com' } - end - let(:user) do - User.new(user_attributes) { |u| u.save(validate: false) } - end - - before do - login_as user - end - - scenario do - visit new_curation_concerns_gw_work_path - fill_in 'Title', with: 'Test GwWork' - click_button 'Create GwWork' - expect(page).to have_content 'Test GwWork' - end - end -end diff --git a/spec/features/dashboard_spec.rb b/spec/features/dashboard_spec.rb new file mode 100644 index 00000000..b5065197 --- /dev/null +++ b/spec/features/dashboard_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/deposit_pdf_spec.rb b/spec/features/deposit_pdf_spec.rb new file mode 100644 index 00000000..a2b8beaf --- /dev/null +++ b/spec/features/deposit_pdf_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/homepage_spec.rb b/spec/features/homepage_spec.rb new file mode 100644 index 00000000..ee4b6f41 --- /dev/null +++ b/spec/features/homepage_spec.rb @@ -0,0 +1,175 @@ +require 'rails_helper' + +RSpec.describe "Homepage" do + + before :each do + visit root_path + end + + context "masthead" do + it 'displays GW logo in masthead of page' do + within "#masthead" do + within "#logo" do + expect(page).to have_css("img") + end + end + end + + it 'displays application title' do + within "#masthead" do + within ".title-wrap" do + expect(page).to have_content("ScholarSpace") + end + end + end + + it 'take user to homepage when clicking title' do + within "#masthead" do + within ".title-wrap" do + click_on "ScholarSpace" + end + end + + expect(current_path).to eq(root_path) + end + + it 'displays application subtitle' do + within "#masthead" do + within ".title-wrap" do + within ".subtitle-wrap" do + expect(page).to have_content("A service of GW Libraries and Academic Innovation") + end + end + end + end + end + + context "navigation bar" do + it 'has a link to "Information for Authors" page' do + within ".navigation-wrap" do + expect(page).to have_content("Information for Authors") + end + end + + it 'takes user to "Information for Authors" page when clicked' do + within ".navigation-wrap" do + click_on "Information for Authors" + end + + expect(current_path).to eq("/terms") + end + + it 'has a link to "About" page' do + within ".navigation-wrap" do + expect(page).to have_content("About") + end + end + + it 'takes user to "About" page when clicked' do + within ".navigation-wrap" do + click_on "About" + end + + expect(current_path).to eq("/about") + end + + it 'has a link to the "Help" page' do + within ".navigation-wrap" do + expect(page).to have_content("Help") + end + end + + it 'takes user to "Help" page when clicked' do + within ".navigation-wrap" do + click_on "Help" + end + + expect(current_path).to eq("/help") + end + + it 'has a link to the "Contact" page' do + within ".navigation-wrap" do + expect(page).to have_content("Contact") + end + end + + it 'takes user to "Contact" page when clicked' do + within ".navigation-wrap" do + click_on "Contact" + end + + expect(current_path).to eq("/contact") + end + + it 'takes user to search result page when clicking magnifying glass icon' do + click_button "search-submit-header" + expect(current_path).to eq("/catalog") + end + end + + context "footer" do + + it 'has a link to "staff login"' do + within "#footer-links" do + click_on "Staff login" + + expect(current_path).to eq("/users/sign_in") + end + end + + it 'has a link to "Campus Advisories"' do + within "#footer-links" do + expect(page).to have_content("Campus Advisories") + end + end + + it 'has a link to "EO/Nondiscrimination Policy"' do + within "#footer-links" do + expect(page).to have_content("EO/Nondiscrimination Policy") + end + end + + it 'has a link to "Privacy Notice"' do + within "#footer-links" do + expect(page).to have_content("Privacy Notice") + end + end + + it 'has a link to "Contact GW"' do + within "#footer-links" do + expect(page).to have_content("Contact GW") + end + end + + it 'has a link to "Accessibility"' do + within "#footer-links" do + expect(page).to have_content("Accessibility") + end + end + + it 'has a link to "Terms of Use"' do + within "#footer-links" do + expect(page).to have_content("Terms of Use") + end + end + + it 'has a link to "Copyright"' do + within "#footer-links" do + expect(page).to have_content("Copyright") + end + end + + it 'has a link to "A-Z Index"' do + within "#footer-links" do + expect(page).to have_content("A-Z Index") + end + end + + it 'has a link to "Accessibility Feedback Form"' do + within "#footer-links" do + expect(page).to have_content("Accessibility Feedback Form") + end + end + end + +end \ No newline at end of file diff --git a/spec/features/sidekiq_dashboard_spec.rb b/spec/features/sidekiq_dashboard_spec.rb index c4848de1..14770119 100644 --- a/spec/features/sidekiq_dashboard_spec.rb +++ b/spec/features/sidekiq_dashboard_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' RSpec.describe "Sidekiq Dashboard Access" do diff --git a/spec/features/sign_in_spec.rb b/spec/features/sign_in_spec.rb new file mode 100644 index 00000000..ee1e92e7 --- /dev/null +++ b/spec/features/sign_in_spec.rb @@ -0,0 +1,82 @@ +require 'rails_helper' + +RSpec.describe 'user sign-in' do + + let(:admin_user) { FactoryBot.create(:admin_user) } + let(:content_admin_user) { FactoryBot.create(:content_admin_user) } + + it 'has link to login page on homepage' do + visit root_path + + within "#login-link" do + click_on "Staff login" + end + + expect(current_path).to eq("/users/sign_in") + end + + it 'can sign in an admin user' 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") + + expect(current_path).to eq("/dashboard") + + within "#user_utility_links" do + expect(page).to have_content(admin_user.email) + end + end + + it 'can sign in a content-admin user' do + 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") + + expect(current_path).to eq("/dashboard") + + within "#user_utility_links" do + expect(page).to have_content(content_admin_user.email) + end + end + + it 'can sign out a user' do + 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 "#user_utility_links" do + click_on "Logout" + end + + expect(current_path).to eq(root_path) + expect(page).to have_content("Staff login") + end + + it 'does not sign in a non-existent user' do + visit "/users/sign_in" + + fill_in("user_email", with: "im-not-a-user@example.com") + fill_in("user_password", with: "beefaroni2002") + click_button("Log in") + + expect(current_path).to eq("/users/sign_in") + expect(page).to have_content("Invalid Email or password") + end + + it 'does not sign in a user with an incorrect password' do + visit "/users/sign_in" + + fill_in("user_email", with: content_admin_user.email) + fill_in("user_password", with: "beefaroni2002") + click_button("Log in") + + expect(current_path).to eq("/users/sign_in") + expect(page).to have_content("Invalid Email or password") + end +end \ No newline at end of file diff --git a/spec/features/sort_catalog_spec.rb b/spec/features/sort_catalog_spec.rb new file mode 100644 index 00000000..9c63c6a8 --- /dev/null +++ b/spec/features/sort_catalog_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +RSpec.describe 'catalog page' do + + let(:solr) { Blacklight.default_index.connection } + let(:admin_user) { FactoryBot.create(:admin_user) } + let(:admin_set) { FactoryBot.create(:admin_set) } + let(:earliest_work) { FactoryBot.create(:gw_work, admin_set: admin_set, + date_uploaded: "2000-01-01", + date_modified: "2010-01-01") } + let(:middle_work) { FactoryBot.create(:gw_work, admin_set: admin_set, + date_uploaded: "2001-01-01", + date_modified: "2009-01-01") } + let(:latest_work) { FactoryBot.create(:gw_work, admin_set: admin_set, + date_uploaded: "2002-01-01", + date_modified: "2008-01-01") } + + before do + ActiveFedora::Cleaner.clean! + solr.delete_by_query("*:*") + + [earliest_work, middle_work, latest_work].map { |work| solr.add(work.to_solr) } + + solr.commit + end + + after do + ActiveFedora::Cleaner.clean! + solr.delete_by_query("*:*") + solr.commit + end + + it 'defaults to showing results in order of most recent upload to least recently upload' do + visit search_catalog_path + + expect(latest_work.title.first).to appear_before(middle_work.title.first) + expect(middle_work.title.first).to appear_before(earliest_work.title.first) + end + + it 'can order results by least recent upload to most recent upload' do + visit search_catalog_path + + within "#sort-dropdown" do + within ".dropdown-menu" do + click_on "date uploaded ▲" + end + end + + expect(earliest_work.title.first).to appear_before(middle_work.title.first) + expect(middle_work.title.first).to appear_before(latest_work.title.first) + end + + it 'can order results by most recent modification to least recent modification' do + visit search_catalog_path + + within "#sort-dropdown" do + within ".dropdown-menu" do + click_on "date modified ▼" + end + end + + expect(latest_work.title.first).to appear_before(middle_work.title.first) + expect(middle_work.title.first).to appear_before(earliest_work.title.first) + end + + it 'can order results by least recent modification to most recent modification' do + visit search_catalog_path + + within "#sort-dropdown" do + within ".dropdown-menu" do + click_on "date modified ▲" + end + end + + expect(earliest_work.title.first).to appear_before(middle_work.title.first) + expect(middle_work.title.first).to appear_before(latest_work.title.first) + end + + it 'displays only relevant results in search' do + visit search_catalog_path + + fill_in("search-field-header", with: "beefaroni") + + click_button "Submit" + + expect(page).to have_content("No results found for your search") + end +end \ No newline at end of file diff --git a/spec/forms/hyrax/gw_etd_form_spec.rb b/spec/forms/hyrax/gw_etd_form_spec.rb deleted file mode 100644 index af80fca8..00000000 --- a/spec/forms/hyrax/gw_etd_form_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwEtd` -require 'rails_helper' - -RSpec.describe Hyrax::GwEtdForm do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/forms/hyrax/gw_work_form_spec.rb b/spec/forms/hyrax/gw_work_form_spec.rb deleted file mode 100644 index 037c4678..00000000 --- a/spec/forms/hyrax/gw_work_form_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwWork` -require 'rails_helper' - -RSpec.describe Hyrax::GwWorkForm do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb deleted file mode 100644 index 7919e5b2..00000000 --- a/spec/models/collection_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'rails_helper' - -RSpec.describe Collection do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/models/file_set_spec.rb b/spec/models/file_set_spec.rb deleted file mode 100644 index 7198576a..00000000 --- a/spec/models/file_set_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'rails_helper' - -RSpec.describe FileSet do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/models/gw_etd_spec.rb b/spec/models/gw_etd_spec.rb deleted file mode 100644 index da21a258..00000000 --- a/spec/models/gw_etd_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwEtd` -require 'rails_helper' - -RSpec.describe GwEtd do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/models/gw_work_spec.rb b/spec/models/gw_work_spec.rb deleted file mode 100644 index 6731c44c..00000000 --- a/spec/models/gw_work_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Generated via -# `rails generate hyrax:work GwWork` -require 'rails_helper' - -RSpec.describe GwWork do - it "has tests" do - skip "Add your tests here" - end -end diff --git a/spec/models/qa/local_authority_entry_spec.rb b/spec/models/qa/local_authority_entry_spec.rb deleted file mode 100644 index 031019d9..00000000 --- a/spec/models/qa/local_authority_entry_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Qa::LocalAuthorityEntry, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/qa/local_authority_spec.rb b/spec/models/qa/local_authority_spec.rb deleted file mode 100644 index dda462a5..00000000 --- a/spec/models/qa/local_authority_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Qa::LocalAuthority, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end