Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhoubk committed Jan 3, 2025
1 parent 6ef9a91 commit 6207321
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 109 deletions.
39 changes: 1 addition & 38 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
# require 'factory_bot'

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
Expand Down Expand Up @@ -46,55 +45,19 @@
url: "http://#{ENV['SELENIUM_HOST'] || 'selenium.test'}:4444/")
end

# Capybara.register_driver :remote_chrome do |app|
# Capybara::Selenium::Driver.new(
# app,
# browser: :chrome,
# url: 'http://selenium.test:4444',
# options: Selenium::WebDriver::Chrome::Options.new
# )
# end

Capybara.default_driver = Capybara.javascript_driver = :remote_chrome
# Capybara.app_host = 'http://app.test:3000'
# Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}" if ENV['SELENIUM_HOST'].present?
# setup for CI later
Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}:3000"
Capybara.server_host = '0.0.0.0'
Capybara.always_include_port = true
Capybara.run_server = false

#############

RSpec.configure do |config|
config.before(:each, type: :system) do
# driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {
# browser: :remote,
# url: 'http://selenium.test:4444'
# }
driven_by :remote_chrome
end
config.use_transactional_fixtures = false

# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false

# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, type: :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
# config.infer_spec_type_from_file_location!

# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
69 changes: 0 additions & 69 deletions spec/system/public_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
expect(page).to have_css('a.pill-metadata.nav-link.active[data-ref-endpoint="https://spatial.lib.berkeley.edu/metadata/berkeley-s7038h/iso19139.xml"]')
expect(page).to have_css('a.pill-metadata.nav-link.active[data-toggle="pill"]')
end

xit 'not triggers the modal' do
find('#metadataLink').click
expect(page).to have_current_path('/catalog/berkeley-s7038h/metadata')
end
end

context 'downloading button available' do
Expand Down Expand Up @@ -88,67 +83,3 @@
it_behaves_like 'download link visible', 'Export GeoJSON', href, css_downloads
end
end

# RSpec.shared_examples 'download link visible' do |page, text, href, css_downloads|
# it "it has link #{text}" do
# expect(page).to have_link(text: text, href: href)
# end

# it 'is has download css attributes' do
# expect(page).to have_css(css_downloads[:location])
# expect(page).to have_css(css_downloads[:style])
# expect(page).to have_css(css_downloads[:type])
# expect(page).to have_css(css_downloads[:id])

# end
# end

# RSpec.shared_examples 'download link invisible' do |page, text|
# it "it has no link #{text}" do
# expect(page).not_to have_link(text: text)
# end

# end

# <a data-download-path="/download/berkeley-s7038h?type=kmz" data-download="trigger" data-download-type="kmz" data-download-id="berkeley-s7038h" href="">Export KMZ</a>

# it_behaves_like 'download link visible', page, 'Export Shapefile'
# it_behaves_like 'download link visible', page, 'Export KMZ'
# it_behaves_like 'download link visible', page, 'Export GeoJSON'

# expect(page).to have_link(text: 'Original Shapefile', href: 'https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip')
# expect(page).to have_css('a[contenturl="https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip"]')
# expect(page).to have_css('a[data-download="trigger"]')
# expect(page).to have_css('a[data-download-type="shapefile"]')
# expect(page).to have_css('a[data-download-id="berkeley-s7038h"]')

# expect(page).to have_link(text: 'Export Shapefile', href: '')
# # expect(page).to have_link(text: 'Export KMZ')
# expect(page).to have_link(text: 'Export GeoJSON')
#
# find('a[data-download-type="direct"]').click
# # expect(File).to exist('/tmp/data.zip')
# expect(find('a[data-download-type="direct"]').text).to eq('Original Shapefile')
# end

# <a data-download-path="/download/berkeley-s7038h?type=shapefile"
# data-download="trigger" data-download-type="shapefile"
# data-download-id="berkeley-s7038h"
# href="">Export Shapefile</a>

# it 'clicking button to show downloading options' do
# find('#downloads-button').click
# expect(page).to have_link(text: 'Original Shapefile', href: 'https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip')
# expect(page).to have_css('a[contenturl="https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip"]')
# expect(page).to have_css('a[data-download="trigger"]')
# expect(page).to have_css('a[data-download-type="direct"]')
# expect(page).to have_css('a[data-download-id="berkeley-s7038h"]')

# expect(page).to have_link(text: 'Export Shapefile', href: '')
# # expect(page).to have_link(text: 'Export KMZ')
# # expect(page).to have_link(text: 'Export GeoJSON')
# #
# find('a[data-download-type="direct"]').click
# # expect(File).to exist('/tmp/data.zip')
# expect(find('a[data-download-type="direct"]').text).to eq('Original Shapefile')
# end
2 changes: 0 additions & 2 deletions spec/system/restrict_record_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'rails_helper'

# RSpec.describe 'View Restricted Data', type: :system do
RSpec.describe 'View Restricted Data', type: :system do
let(:app_hostname) { IPSocket.getaddress(Socket.gethostname) }
let(:cas_url) { "/cas/login?service=http://#{app_hostname}:3000/users/auth/calnet/callback?url=http://#{app_hostname}:3000/catalog/berkeley-s7b12n" }
Expand All @@ -14,7 +13,6 @@

it 'clicking login to view and download link' do
find('.btn.btn-default').click
# login_url = '/cas/login?service=http://app.test:3000/users/auth/calnet/callback?url=http%3A%2F%2Fapp.test%3A3000%2Fcatalog%2Fberkeley-s7b12n'
raw_url = page.current_url
uri = URI.parse(raw_url)
decoded_query = URI.decode_www_form_component(uri.query)
Expand Down

0 comments on commit 6207321

Please sign in to comment.