Skip to content

Commit

Permalink
Merge pull request #2658 from pulibrary/fix-spec-v2
Browse files Browse the repository at this point in the history
Fix spec v2
  • Loading branch information
tpendragon authored Aug 17, 2021
2 parents 8998c32 + 6dc18d2 commit 8cef33d
Show file tree
Hide file tree
Showing 18 changed files with 27,659 additions and 15,995 deletions.
10 changes: 5 additions & 5 deletions spec/controllers/bookmarks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

it 'renders the email record mailer' do
sign_in user
user.bookmarks.create!([{ document_id: '9741216', document_type: 'SolrDocument' }])
user.bookmarks.create!([{ document_id: '9997412163506421', document_type: 'SolrDocument' }])
get :print
expect(assigns(:documents).length).to eq 1
expect(response).to render_template 'record_mailer/email_record.text.erb'
Expand All @@ -19,14 +19,14 @@
let(:user) { FactoryBot.create(:user) }
let(:headers) { 'ID,Title,Title (Original Script),Author,Author (Original Script),Format,Language,Published/Created,Date,Description,Series,Location,Call Number,Notes' }

let(:data1) { ['9741216', 'Adriaen van de Velde : Dutch master of landscape', 'Cornelis, Bart', 'Book', 'English', 'London: Paul Holberton Publishing', '2016', '224 pages : illustrations (some color) ; 29 cm', 'Marquand Library', 'ND653.V414 A4 2016', 'Published to accompany the exhibition held at the Rijksmuseum, Amsterdam, 24 June - 15 September 2016 and Dulwich Picture Gallery, London, 12 October 2016 - 15 January 2017.'] }
let(:data2) { ['3148879', 'Sin, Chae-hong', '신재홍', "Tongnipkun u\u0306i cho\u0306nt'u", '독립군의전투 /'] }
let(:data1) { ['9997412163506421', 'Adriaen van de Velde : Dutch master of landscape', 'Cornelis, Bart', 'Book', 'English', 'London: Paul Holberton Publishing', '2016', '224 pages : illustrations (some color) ; 29 cm', 'Remote Storage: Marquand Use Only', 'ND653.V414 A4 2016', 'Published to accompany the exhibition held at the Rijksmuseum, Amsterdam, 24 June - 15 September 2016 and Dulwich Picture Gallery, London, 12 October 2016 - 15 January 2017.'] }
let(:data2) { ['9935444363506421', 'Replacement migration : is it a solution to declining and ageing populations?', 'Book', 'English', 'New York: United Nations', '2001', 'viii, 151 p. : ill. ; 28 cm.', 'United Nations Collection; Wallace Hall', '01.XIII.19; JV6225 .R464 2001'] }
let(:bad_value) { 'Adriaen van de Velde : Dutch master of landscape / Bart Cornelis, Marijn Schapelhouman' }

it 'renders a CSV list of metadata' do
sign_in user
user.bookmarks.create!([{ document_id: '9741216', document_type: 'SolrDocument' }])
user.bookmarks.create!([{ document_id: '3148879', document_type: 'SolrDocument' }])
user.bookmarks.create!([{ document_id: '9997412163506421', document_type: 'SolrDocument' }])
user.bookmarks.create!([{ document_id: '9935444363506421', document_type: 'SolrDocument' }])
get :csv

body = response.body.force_encoding('UTF-8')
Expand Down
14 changes: 7 additions & 7 deletions spec/features/availability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe 'Physical Holdings are displayed on a record page', js: true do
before do
stub_holding_locations
visit '/catalog/3256177'
visit '/catalog/9932561773506421'
end

it 'within the holdings section', unless: in_ci? do
Expand Down Expand Up @@ -36,7 +36,7 @@
describe 'viewing a catalog record', js: true do
before do
stub_holding_locations
visit '/catalog/3256177'
visit '/catalog/9932561773506421'
end

xit 'does not render the holding section' do
Expand All @@ -47,7 +47,7 @@
describe 'viewing a record for an electronic holding', js: true do
before do
stub_holding_locations
visit '/catalog/857469'
visit '/catalog/998574693506421'
end

xit 'does not render the online section' do
Expand All @@ -58,7 +58,7 @@
describe 'viewing a record for a holding in a temp location', js: true do
before do
stub_holding_locations
visit '/catalog?q=7917192'
visit '/catalog?q=9979171923506421'
end

xit 'does not render the location' do
Expand All @@ -76,7 +76,7 @@
xdescribe 'An item reserved for controlled digital lending', js: true do
before do
stub_holding_locations
visit '/catalog/7699003'
visit '/catalog/9976990033506421'
end

it 'adds a link to the digital object', unless: in_ci? do
Expand All @@ -92,13 +92,13 @@
xdescribe 'Physical Holdings in temp locations', js: true do
it 'displays temp location on search results along with call number', unless: in_ci? do
stub_holding_locations
visit '/catalog?q=7917192'
visit '/catalog?q=9979171923506421'
expect(page).to have_selector '.library-location', text: 'Lewis Library - Term Loan Reserves'
expect(page).to have_selector '.library-location', text: 'QA303.2 .W45 2014'
end
it 'displays temp location and copy on record show', unless: in_ci? do
stub_holding_locations
visit 'catalog/7917192'
visit 'catalog/9979171923506421'
expect(page).to have_selector '.library-location', text: 'Lewis Library - Term Loan Reserves'
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/browsables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
before(:all) do
stub_holding_locations
stub_hathi
visit '/catalog/8237778'
visit '/catalog/9982377783506421'
end
it 'name-uniform title link, hierarchical, does not display name' do
brahms = 'Brahms, Johannes, 1833-1897.'
Expand Down
10 changes: 5 additions & 5 deletions spec/features/browsing_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
end

it 'renders an accessible icon for citing the item' do
visit 'catalog/3478898'
visit 'catalog/9934788983506421'
expect(page).to have_selector '.icon-cite[aria-hidden="true"]', visible: false
end

it 'renders an accessible icon for sending items to a printer' do
visit 'catalog/3478898'
visit 'catalog/9934788983506421'
expect(page).to have_selector '.icon-share[aria-hidden="true"]', visible: false
expect(page).to have_selector '.icon-print[aria-hidden="true"]', visible: false
end

context 'when an entry has a bib. ID for a resource published in Figgy' do
before do
visit 'catalog/3753928'
visit 'catalog/9970446223506421'
end

it 'updates the thumbnail and constructs an instance of the Universal Viewer' do
Expand All @@ -31,7 +31,7 @@

context 'when an entry has a bib. ID and ARK for a resource published in Figgy' do
before do
visit 'catalog/3395923'
visit 'catalog/9970446223506421'
end

it 'updates the thumbnail and constructs an instance of the Universal Viewer' do
Expand All @@ -40,7 +40,7 @@
end

it 'updates the link to the ARK with a fragment identifier for the UV' do
expect(page).to have_selector '.electronic-access a[href$="3395923#view"]', text: 'Digital content'
expect(page).to have_selector '.availability--online a[href$="7044622#view"]', text: 'Table of contents'
end
end
end
19 changes: 12 additions & 7 deletions spec/features/citation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
require 'rails_helper'

describe 'citation' do
let(:bibid) { '7994866' }

it 'will render successfully even if there is not a subfield a' do
stub_request(:get, "#{Requests.config['bibdata_base']}/bibliographic/#{bibid}")
.with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Faraday v0.15.3' })
.to_return(status: 200, body: '', headers: {})
visit '/catalog/7994866/citation'
expect(current_url).to include '/catalog/7994866/citation'
stub_request(:get, "#{Requests.config['bibdata_base']}/bibliographic/9979948663506421")
.with(
headers: {
'Accept' => '*/*',
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'User-Agent' => 'Faraday v0.17.4'
}
)
.to_return(status: 200, body: "", headers: {})

visit '/catalog/9979948663506421/citation'
expect(current_url).to include '/catalog/9979948663506421/citation'
expect(page.status_code).to eq 200
end
end
4 changes: 2 additions & 2 deletions spec/features/header_links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

context 'With MARC-based records' do
before do
visit '/catalog/10585552'
visit '/catalog/99115031773506421'
end

it 'displays links in the navbar, account dropdown, and record view' do
Expand Down Expand Up @@ -36,7 +36,7 @@

context 'With non-MARC-based records' do
before do
visit '/catalog/dsp01ft848s955'
visit '/catalog/dsp017s75dc44p'
end

it 'does not have cite, RefWorks, or EndNote links' do
Expand Down
9 changes: 5 additions & 4 deletions spec/features/holding_locations_sort_order_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

require 'rails_helper'

# See issue https://github.com/pulibrary/orangelight/issues/2660
# Do we still need this sort when there are recap holdings?
context 'viewing record with multiple holdings' do
it 'shows east asian holding before recap holding' do
xit 'shows east asian holding before recap holding' do
stub_holding_locations
visit '/catalog/3861539'
visit '/catalog/9938615393506421'
locations = all('.location-text').map(&:text)
expect(locations).to eq ['East Asian Library - Reference', 'ReCAP']
expect(locations).to eq ["ReCAP - Remote Storage", "East Asian Library - Reference"]
end
end
6 changes: 3 additions & 3 deletions spec/features/more_in_this_series_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
before { stub_holding_locations }

it 'does not appear for 490 series titles' do
visit '/catalog/5525311'
visit '/catalog/9955253113506421'
expect(page.all('a.more-in-series').length).to eq 0
end
it 'link to search for 8xx series titles' do
visit '/catalog/4687191'
visit '/catalog/9946871913506421'
expect(page.all('a.more-in-series').length).to eq 2
all('a.more-in-series').first.click
expect(page.body).to include('/catalog/4687191')
expect(page.body).to include('/catalog/9946871913506421')
end
end
110 changes: 17 additions & 93 deletions spec/features/request_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,46 @@
require 'rails_helper'

describe 'Request Options' do
before { stub_holding_locations }
before { stub_alma_holding_locations }

describe 'the request page', js: true do
before do
visit '/catalog/9618072'
end

it 'clicking the request button loads the request page' do
stub_request(:get, "https://bibdata-staging.princeton.edu/bibliographic/9618072/holdings/9455965/availability.json")
stub_request(:get, "#{Requests.config['bibdata_base']}/bibliographic/99113436223506421/holdings/22553672700006421/availability.json")
.to_return(status: 200, body: {}.to_json, headers: {})
stub_request(:get, "https://catalog.princeton.edu/catalog/9618072/raw")
stub_request(:get, "https://catalog.princeton.edu/catalog/99113436223506421/raw")
.to_return(status: 200, body: {}.to_json, headers: {})
stub_request(:get, "https://bibdata-staging.princeton.edu/availability?id=9618072")
stub_request(:get, "#{Requests.config['bibdata_base']}/availability?id=99113436223506421")
.to_return(status: 200, body: {}.to_json, headers: {})
stub_request(:get, "https://bibdata-staging.princeton.edu/locations/delivery_locations.json")
stub_request(:get, "#{Requests.config['bibdata_base']}/locations/delivery_locations.json")
.to_return(status: 200, body: {}.to_json, headers: {})
using_wait_time 5 do
click_link('Request')
expect(current_path).to eq "/requests/9618072"
end
visit '/catalog/99113436223506421'
end
end

describe 'Available status non-requestable location', js: true do
before do
visit '/catalog/9222024'
end

it 'does not display a request button', unless: in_ci? do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page).to have_selector('td[data-requestable="false"]')
end
end
end

describe 'Unavailable status non-requestable location', js: true do
before do
visit '/catalog/6890057'
end

it 'does not display a request button', unless: in_ci? do
it 'clicking the request button loads the request page' do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page).to have_selector('td[data-requestable="false"]')
click_link 'Request'
expect(current_path).to eq "/requests/99113436223506421"
end
end
end

describe 'In process status non-requestable location', js: true do
describe 'On site access status in non-circulate location', js: true do
before do
visit '/catalog/9618072'
visit '/catalog/99118600973506421'
end

it 'does display a request button', unless: in_ci? do
it 'displays a Reading Room Request button', unless: in_ci? do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page.find_link('Request')).to be_visible
expect(page).to have_selector('td[data-requestable="true"]')
expect(page).to have_selector('td[data-aeon="true"]')
end
end
end

describe 'Available status requestable location', js: true do
before do
visit '/catalog/9031545'
visit '/catalog/9990315453506421'
end

it 'does display a request button', unless: in_ci? do
Expand All @@ -80,7 +55,7 @@

describe 'Multi-item holding with some requestable items', js: true do
before do
visit '/catalog/6045464'
visit '/catalog/9960454643506421'
end

# This no longer tests for the request button, as CORS headers must be enabled for the bibdata installation to avoid JavaScript/AJAX errors in Chrome
Expand Down Expand Up @@ -109,7 +84,7 @@

describe 'Aeon location', js: true do
before do
visit '/catalog/7916044'
visit '/catalog/99118600973506421'
end

it 'displays an aeon request button', unless: in_ci? do
Expand All @@ -119,55 +94,4 @@
end
end
end

describe 'An In-transit discharged item', js: true do
before do
visit '/catalog/9741216'
end

it 'does not display a request button', unless: in_ci? do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page).to have_selector('td[data-requestable="false"]')
end
end
end

describe 'Paging location available status', js: true do
before do
visit '/catalog/8908514'
end

xit 'does display a paging request button' do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page.find_link('Paging Request').visible?).to be_truthy
end
end
end

describe 'Paging location that has been shelved at a temp location status', js: true do
before do
visit '/catalog/5318288'
end

xit 'does display a request button', unless: in_ci? do
using_wait_time 5 do
expect(page.all('.holding-block').length).to eq 1
expect(page).not_to have_selector('.location-services.service-conditional')
end
end
end

describe 'Paging location that has been shelved at a temp location status', js: true do
before do
visit '/catalog?search_field=all_fields&q=5318288'
end

xit 'does not display a paging request icon', unless: in_ci? do
using_wait_time 5 do
expect(page).not_to have_selector('.icon-warning.icon-paging-request')
end
end
end
end
Loading

0 comments on commit 8cef33d

Please sign in to comment.