Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first smoke tests #441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ group :development, :test do
gem 'byebug'
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'capybara-mechanize'
gem 'equivalent-xml'
gem 'factory_bot_rails'
gem 'rspec-collection_matchers'
Expand Down
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
capybara-mechanize (1.11.0)
capybara (>= 2.4.4, < 4)
mechanize (~> 2.7.0)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chronic (0.10.2)
Expand All @@ -134,6 +137,8 @@ GEM
devise
diff-lcs (1.3)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.1)
dotenv-rails (2.7.1)
dotenv (= 2.7.1)
Expand All @@ -155,6 +160,8 @@ GEM
globalid (0.4.2)
activesupport (>= 4.2.0)
hashdiff (0.3.8)
http-cookie (1.0.3)
domain_name (~> 0.5)
httparty (0.16.4)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
Expand Down Expand Up @@ -189,6 +196,15 @@ GEM
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
mechanize (2.7.6)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
mime-types (>= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (>= 2.5.2)
nokogiri (~> 1.6)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
Expand All @@ -200,12 +216,16 @@ GEM
multi_xml (0.6.0)
multipart-post (2.0.0)
mysql2 (0.5.2)
net-http-digest_auth (1.4.1)
net-http-persistent (3.0.1)
connection_pool (~> 2.2)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
ntlm-http (0.1.1)
openseadragon (0.5.0)
rails (> 3.2.0)
orm_adapter (0.5.0)
Expand Down Expand Up @@ -356,6 +376,9 @@ GEM
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.5.0)
warden (1.2.8)
rack (>= 2.0.6)
Expand All @@ -368,6 +391,7 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
webrobots (0.1.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
Expand Down Expand Up @@ -397,6 +421,7 @@ DEPENDENCIES
capistrano-rails
capistrano-sidekiq (~> 0.20.0)
capybara (~> 2.13)
capybara-mechanize
coveralls
devise
devise-guests (~> 0.6)
Expand Down
70 changes: 70 additions & 0 deletions spec/smoketests/number_of_items_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# frozen_string_literal: true
require 'rails_helper'
require 'cgi'

RSpec.describe 'total number of items in a particular collection', :clean, type: :system, smoketest: true, js: true do
let(:url) { 'https://ursus.library.ucla.edu/' }
let(:ladnn_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Los+Angeles+Daily+News+Negatives' }
let(:arkatov_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Arkatov+%28James%29+Collection' }
let(:bennett_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Bennett+%28Walter+E.%29+Photographic+Collection%2C+1937-1983+%28bulk+1952-1982%29' }
let(:connell_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Connell+%28Will%29+Papers' }
let(:postcards_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Collection+of+California+Postcards' }
let(:ethiopic_url) { 'https://ursus.library.ucla.edu/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Ethiopic+Manuscripts' }

it 'number of items in the Digital Collection' do
visit(url)
click_on 'Search'
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 6000
expect(number_of_search_results).to eq 6625
expect(number_of_search_results).to be < 10_000
end

it 'number of items in the LADNN Collection' do
visit(ladnn_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 5000
expect(number_of_search_results).to eq 5172
expect(number_of_search_results).to be < 6000
end

it 'number of items in in the Arkatov Collection' do
visit(arkatov_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 800
expect(number_of_search_results).to eq 840
expect(number_of_search_results).to be < 900
end

it 'number of items in the Bennett Collection' do
visit(bennett_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 75
expect(number_of_search_results).to eq 79
expect(number_of_search_results).to be < 80
end

it 'number of items in the Connell Collection' do
visit(connell_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 500
expect(number_of_search_results).to eq 502
expect(number_of_search_results).to be < 550
end

it 'number of items in the Ethiopic Manuscripts Collection' do
visit(ethiopic_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 1
expect(number_of_search_results).to eq 5
expect(number_of_search_results).to be < 10
end

it 'number of items in the Postcard Collection' do
visit(postcards_url)
number_of_search_results = page.find(:css, 'h4.catalog-results').text.split.first.to_i
expect(number_of_search_results).to be > 15
expect(number_of_search_results).to eq 20
expect(number_of_search_results).to be < 25
end
end
17 changes: 17 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Capybara.register_driver :mechanize do |app|
driver = Capybara::Mechanize::Driver.new(app)
driver.configure do |agent|
# Configure other Mechanize options here.
agent.log = Logger.new "mech.log"
agent.user_agent_alias = 'Mac Safari'
end
driver
end

Capybara.javascript_driver = :chrome_headless

# Setup rspec
Expand All @@ -24,4 +34,11 @@
config.before(:each, type: :system, js: true) do
driven_by :chrome_headless
end

config.before(:each, smoketest: true) do
driven_by :mechanize
Capybara.run_server = false
# Uncomment this to see tests in browser
Capybara.current_driver = :selenium
end
end