diff --git a/spec/features/download_zipfile_spec.rb b/spec/features/download_zipfile_spec.rb index 4d2f90a..cca6e0b 100644 --- a/spec/features/download_zipfile_spec.rb +++ b/spec/features/download_zipfile_spec.rb @@ -27,7 +27,7 @@ def wait_for_download(zip_file_path, timeout: 5) loop do elapsed_time = Time.current - start_time - raise "Timeout waiting for downloading #{zip_file_path}" if elapsed_time > timeout + raise "Error: Timeout waiting for downloading #{zip_file_path}" if elapsed_time > timeout return true if File.exist?(zip_file_path) sleep 1 @@ -45,15 +45,14 @@ def wait_for_download(zip_file_path, timeout: 5) find_link('Original Shapefile').click download_completed = wait_for_download(zip_file_path) if download_completed - expect(File.exist?(zip_file_path)).to be_truthy, "Download completed but data.zip file not found: #{zip_file_path}" + expect(File.exist?(zip_file_path)).to be_truthy, "Error: Downloaded data.zip file not found: #{zip_file_path}" Zip::File.open(zip_file_path) do |zip_file| file_names = zip_file.map(&:name) - puts "Contents: #{file_names}" - expect(file_names).to include('SanBenito_Intersections_2016.shp'), 'SanBenito_Intersections_2016.shp not found in data.zip' + expect(file_names).to include('SanBenito_Intersections_2016.shp'), 'Error: SanBenito_Intersections_2016.shp not found in data.zip' end else - expect(File.exist?(crdownload_file)).to be_truthy, "Download not completed and incompleted data.zip.crdownload file found: #{crdownload_file}" - expect(File.size(crdownload_file)).to be > 130_000, 'Incompleted data.zip.crdownload file size <= 130000' + expect(File.exist?(crdownload_file)).to be_truthy, "Error: Download not completed and incompleted data.zip.crdownload file found: #{crdownload_file}" + expect(File.size(crdownload_file)).to be > 130_000, 'Error: Incompleted data.zip.crdownload file size <= 130000' end end end diff --git a/spec/system/public_result_spec.rb b/spec/system/public_result_spec.rb index 55e4bf1..7c60e58 100644 --- a/spec/system/public_result_spec.rb +++ b/spec/system/public_result_spec.rb @@ -6,13 +6,13 @@ visit 'catalog/berkeley-s7038h' end - it 'has the record title' do + it 'Record title' do within('#document') do expect(find('h2')).to have_text('Intersections, San Benito County, California, 2016') end end - context 'has metadata link' do + context 'metadata link' do it 'displays the metadata link' do expect(page).to have_link('Metadata', href: '/catalog/berkeley-s7038h/metadata') end @@ -29,7 +29,7 @@ end end - context 'downloading button available' do + context 'downloading button' do it 'displays the download button' do expect(page).to have_button('downloads-button') end @@ -39,39 +39,4 @@ it_behaves_like 'download link invisible', 'Export GeoJSON' end - # context 'downloading links available' do - # before do - # find('#downloads-button').click - # end - - # href = 'https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip' - # css_downloads = { location: 'a[contenturl="https://spatial.lib.berkeley.edu/public/berkeley-s7038h/data.zip"]', - # style: 'a[data-download="trigger"]', - # type: 'a[data-download-type="direct"]', - # id: 'a[data-download-id="berkeley-s7038h"]' } - # it_behaves_like 'download link visible', 'Original Shapefile', href, css_downloads - - # href = '' - # css_downloads[:location] = 'a[data-download-path="/download/berkeley-s7038h?type=shapefile"]' - # css_downloads[:type] = 'a[data-download-type="shapefile"]' - # it_behaves_like 'download link visible', 'Export Shapefile', href, css_downloads - - # css_downloads[:location] = 'a[data-download-path="/download/berkeley-s7038h?type=kmz"]' - # css_downloads[:type] = 'a[data-download-type="kmz"]' - # it_behaves_like 'download link visible', 'Export KMZ', href, css_downloads - - # css_downloads[:location] = 'a[data-download-path="/download/berkeley-s7038h?type=geojson"]' - # css_downloads[:type] = 'a[data-download-type="geojson"]' - # it_behaves_like 'download link visible', 'Export GeoJSON', href, css_downloads - # end - # - context 'downloading links available' do - before do - find('#downloads-button').click - end - it 'displays the download button' do - find_link('Original Shapefile').click - # sleep(10) - end - end end diff --git a/spec/system/restricted_access_spec.rb b/spec/system/restricted_access_spec.rb index 1858f86..d4bf2e3 100644 --- a/spec/system/restricted_access_spec.rb +++ b/spec/system/restricted_access_spec.rb @@ -7,16 +7,19 @@ visit '/catalog/berkeley-s7b12n' end + def decoded_url(url) + uri = URI.parse(url) + decoded_query = URI.decode_www_form_component(uri.query) + URI.decode_www_form_component("#{uri.path}?#{decoded_query}") + end + it 'display login to view and download link' do expect(page).to have_link('Login to View and Download') end it 'open calnet login page when clicking login to view and download link' do find('.btn.btn-default').click - raw_url = page.current_url - uri = URI.parse(raw_url) - decoded_query = URI.decode_www_form_component(uri.query) - decoded_path_and_query = URI.decode_www_form_component("#{uri.path}?#{decoded_query}") + decoded_path_and_query = decoded_url(page.current_url) expect(decoded_path_and_query).to eq(cas_url) end end