Skip to content

Commit

Permalink
Merge pull request #649 from sul-dlss/fix-int-tests
Browse files Browse the repository at this point in the history
Fix integration tests
  • Loading branch information
Jessie Keck committed Aug 4, 2014
2 parents 734b5ae + 08b77cc commit 930ede5
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 73 deletions.
6 changes: 3 additions & 3 deletions spec/integration/external-data/access_panels_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

within(".panel-online") do
within("ul.links") do
expect(page).to have_css("li a", text: "purl.access.gpo.gov")
expect(page).to have_css("li a", text: "Pt. [1]: text version:")
end
end
end
Expand Down Expand Up @@ -51,7 +51,7 @@
visit catalog_path('10020587')

within(".panel-course-reserve") do
expect(page).to have_css("li a", text: "ACCT-212-01-02 -- Managerial Accounting: Base")
expect(page).to have_css("dl dd a", text: "ACCT-212-01-02 -- Managerial Accounting: Base")
end
end
end
Expand All @@ -63,7 +63,7 @@
end
it "should be displayed for objects held at libraries" do
visit catalog_path('3195844')
expect(page).to have_css(".panel-library-location", count:6)
expect(page).to have_css(".panel-library-location", count:7)
end
end
end
86 changes: 44 additions & 42 deletions spec/integration/external-data/advanced_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "spec_helper"

number_pattern = /[1-9](?:\d{0,2})(?:,\d{3})*(?:\.\d*[1-9])?|0?\.\d*[1-9]|0/

describe "Legacy Advanced Search Tests", js: true, feature: true, :"data-integration" => true do
before do
visit advanced_search_path
Expand All @@ -19,8 +21,6 @@
fill_in "search_author", with: "Zukofsky"
fill_in "search_title", with: "A"
click_on "advanced-search-submit"
click_link "10 per page"
click_link "20"
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
expect(docs.index("9082824")).to_not be_nil
expect(docs.index("1398728")).to_not be_nil
Expand All @@ -40,17 +40,17 @@
click_on "Resource type"
check "f_inclusive_format_main_ssim_book"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.find("strong", text: /^.*,+.*$/).text, 4000000)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 4000000)).to be_true
end
end
end
describe "No facet searching" do
it "should return at least 500 results" do
fill_in "search_title", with: "something"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.find("strong", text: /^.*,+.*$/).text, 500)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 500)).to be_true
end
end
end
Expand Down Expand Up @@ -82,8 +82,8 @@
click_on "Resource type"
check "f_inclusive_format_main_ssim_book"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.find("strong", text: /^.*,+.*$/).text, 100000)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 100000)).to be_true
end
end
end
Expand Down Expand Up @@ -126,8 +126,8 @@
it "should get at most 2,000,000" do
fill_in "search", with: "NOT p"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.find("strong", text: /^.*,+.*$/).text, 2000000)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 2000000)).to be_true
end
end
end
Expand All @@ -139,8 +139,8 @@
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
# This only checks first page of results
expect(docs.index("6865307")).to be_nil
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 1520000)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 1520000)).to be_true
end
end
end
Expand All @@ -159,8 +159,8 @@
fill_in "search", with: "IEEE Xplore"
fill_in "subject_terms", with: "-Congresses"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 1500)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 1500)).to be_true
end
end
end
Expand All @@ -170,10 +170,12 @@
fill_in "search_author", with: "John Steinbeck"
fill_in "search_title", with: "Pearl OR Grapes"
click_on "advanced-search-submit"
click_link "10 per page"
click_button "20 per page"
click_link "100"
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 225)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 225)).to be_true
end
expect(docs.index("6746743")).to_not be_nil
expect(docs.index("6747313")).to_not be_nil
end
Expand All @@ -182,26 +184,26 @@
it "should return at least 400 results" do
fill_in "search_title", with: "nossa OR nuestra america"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 400)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 400)).to be_true
end
end
end
describe "color OR colour photography (SW-939)" do
it "should return at least 80 results" do
fill_in "search_title", with: "color OR colour photography"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 80)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 80)).to be_true
end
end
end
describe "AND query" do
it "should return at least 50 results and these keys in first 5 results" do
fill_in "search_title", with: "Hello AND Goodbye"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 50)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 50)).to be_true
end
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
expect(docs.index("6502314")).to be < 5
Expand All @@ -214,8 +216,8 @@
it "should return at most 3 results and this key" do
fill_in "search_author", with: "nabokov OR hofstadter AND pushkin"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 4)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 4)).to be_true
end
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
expect(docs.index("4076380")).to_not be_nil
Expand All @@ -225,8 +227,8 @@
pending "should return at most 3 results and not this key" do
fill_in "search_author", with: "hofstadter OR nabokov AND pushkin"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 3)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 3)).to be_true
end
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
# TODO: Fails and actually is returned as first result
Expand All @@ -237,9 +239,9 @@
it "should get between 5 and 7 results" do
fill_in "search_author", with: "(nabokov OR hofstadter) AND pushkin"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 5)).to be_true
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 7)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 5)).to be_true
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 7)).to be_true
end
docs = page.all(:xpath, "//form[@data-doc-id]").map{|e| e["data-doc-id"]}
expect(docs.index("4076380")).to_not be_nil
Expand All @@ -250,9 +252,9 @@
fill_in "subject_terms", with: "(Dutch OR Netherlands) AND painting"
fill_in "search", with: "trade OR commerce"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 8)).to be_true
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 12)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 8)).to be_true
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 12)).to be_true
end
end
end
Expand All @@ -261,8 +263,8 @@
fill_in "subject_terms", with: "Dutch OR Netherlands"
fill_in "search", with: "(trade OR commerce) AND painting"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 15)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 15)).to be_true
end
end
end
Expand All @@ -272,7 +274,7 @@
click_on "Library"
check "f_inclusive_building_facet_art-architecture"
click_on "advanced-search-submit"
expect(page).to have_css(".page_entries", text: "1 entry found")
expect(page).to have_css(".search_num_of_results", text: "1 result")
end
end
describe "Title Plus Format Facet Value (SW-326)" do
Expand All @@ -291,8 +293,8 @@
click_on "Language"
check "f_inclusive_language_english"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 100)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 100)).to be_true
end
end
end
Expand Down Expand Up @@ -336,8 +338,8 @@
fill_in "subject_terms", with: '"Home Schooling"'
fill_in "search", with: "Socialization"
click_on "advanced-search-submit"
within ".page_entries" do
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 150)).to be_true
within ".search_num_of_results" do
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 150)).to be_true
end
end
end
Expand All @@ -363,9 +365,9 @@
fill_in "range_pub_year_tisim_begin", with: "1789"
fill_in "range_pub_year_tisim_end", with: "1800"
click_on "advanced-search-submit"
within ".page_entries" do
expect(less_than_integer(page.all("strong").map{|e| e.text}[2], 5000)).to be_true
expect(greater_than_integer(page.all("strong").map{|e| e.text}[2], 6000)).to be_true
within ".search_num_of_results" do
expect(less_than_integer(page.find("h2", text: number_pattern).text, 5000)).to be_true
expect(greater_than_integer(page.find("h2", text: number_pattern).text, 6000)).to be_true
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
end

# Second embedded gallery documents and browse more elements
expect(page).to have_css(".gallery-document", count: 23)
expect(page).to have_css(".gallery-document", count: 27)
expect(page).to have_css(".gallery-document a", text: "The Dickinson composites")
expect(page).to have_css(".gallery-document a", text: "The Silverado squatters", visible: false)
# Click previous
page.find(".left.embed-browse-control").click
expect(page).to have_css(".gallery-document a", text: "The Silverado squatters", visible: true)
# Browse more links
expect(page).to have_css(".gallery-document a", text: "Browse more selections", count: 2)
expect(page).to have_css(".gallery-document a", text: "Continue to full page", count: 2)
click_link("Z239 .G75 B477 2012")
expect(page).to have_css(".gallery-document", visible: false)

# First embedded gallery documents
click_link("PS3552 .E74 B4 2012")
expect(page).to have_css(".gallery-document", count: 23)
expect(page).to have_css(".gallery-document", count: 27)
expect(page).to have_css(".gallery-document a", text: "A certain slant of sunlight")
expect(page).to have_css(".gallery-document a", text: "Great stories of the chair", visible: false)
# Click next
page.find(".right.embed-browse-control").click
expect(page).to have_css(".gallery-document a", text: "Great stories of the chair", visible: true)
# Browse more links

expect(page).to have_css(".gallery-document a", text: "Browse more selections", count: 2)
expect(page).to have_css(".gallery-document a", text: "Continue to full page", count: 2)


end
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/external-data/facets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
within('.facet_limit.blacklight-language') do
expect(page).to have_css('li .facet-label', count: 20)
end
end
end
end
it "should include pluralized and downcased facet labels" do
within('#facets') do
Expand All @@ -26,8 +26,8 @@
describe "for special facets" do
it "should include more than 20 values" do
within('#facets') do
within('.facet_limit.blacklight-building_facet') do
expect(page).to have_css('li .facet-label', count: 21)
within('.facet_limit.blacklight-language') do
expect(page).to have_css('li', count: 21)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/external-data/location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
visit catalog_path('10160087')

within('.panel-library-location') do
within('ul.items') do
within(page.all('ul.items').first) do
expect(page).to have_css('i.noncirc', count: 3)
end
end
Expand All @@ -26,7 +26,7 @@
visit catalog_path('10458422')

within('.panel-library-location') do
within('ul.items') do
within(page.all('ul.items').first) do
expect(page).to_not have_css('i.noncirc')
end
end
Expand All @@ -37,7 +37,7 @@
visit catalog_path('10424524')

within('.panel-library-location') do
within('ul.items') do
within(page.all('ul.items').first) do
expect(page).to have_css('i.unknown')
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/integration/external-data/mhld_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
expect(page).to have_content('At the library')
within('.accordion-section.location') do
find('a.header').click
expect(page).to have_css('tr td strong', text: 'Current Periodicals')
expect(page).to have_css('tr td .public-note', text: 'Latest issues in CURRENT PERIODICALS; earlier issues in STACKS.')
expect(page).to have_css('tr th strong', text: 'Current Periodicals')
expect(page).to have_css('tr th .public-note', text: 'Latest issues in CURRENT PERIODICALS; earlier issues in STACKS.')
expect(page).to have_css('tr td', text: 'Latest: v.21:no.4 (2013)')
end

end
end
end
end
end
3 changes: 0 additions & 3 deletions spec/integration/external-data/mods_subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
expect(page).to have_css('.filterName', text: 'Subject')
expect(page).to have_css('.filterValue', text: '"Addison, Joseph, 1672-1719"')
end
within('.page_links') do
expect(page).to have_css('.page_entries', text: /^1 - 10 of \d{3}$/)
end
expect(page).to have_css('.index_title', text: 'Joseph Addison as literary critic')
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/external-data/selected_databases_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
scenario "online link" do
within(".selected-databases") do
within(first(".panel")) do
expect(page).to have_css("span.label.label-success", text: "Search database")
expect(page).to have_css("a.selected-database", text: "Search database")
expect(page).to have_css("a", text: "search.ebscohost.com")
end
end
Expand Down
12 changes: 2 additions & 10 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,9 @@
end

def greater_than_integer value, integer
if value.gsub(',', '').to_i > integer
true
else
value
end
value.gsub(',', '').to_i > integer ? true : value
end

def less_than_integer value, integer
if value.gsub(',', '').to_i < integer
true
else
value
end
value.gsub(',', '').to_i < integer ? true : value
end

0 comments on commit 930ede5

Please sign in to comment.