From d02d0d1edebf9199c7d6da3af3eb1feb0b848f49 Mon Sep 17 00:00:00 2001 From: Carolyn Cole Date: Thu, 4 Apr 2019 11:13:38 -0400 Subject: [PATCH] Making the test less dependant on the Display Name in the data dictionary --- spec/blacklight/catalog_spec.rb | 10 ++++----- .../archival_collections/index_spec.rb | 4 ++-- .../curated_collections/index_spec.rb | 4 ++-- .../library_collections/index_spec.rb | 4 ++-- spec/cho/work/file_set/show_spec.rb | 2 +- spec/cho/work/import/create_spec.rb | 2 +- spec/cho/work/submissions/index_spec.rb | 6 +++--- spec/cho/work/submissions/new_spec.rb | 21 +++++++++---------- spec/cho/work/submissions/show_spec.rb | 10 ++++----- 9 files changed, 31 insertions(+), 32 deletions(-) diff --git a/spec/blacklight/catalog_spec.rb b/spec/blacklight/catalog_spec.rb index d24a122e..87a039fc 100644 --- a/spec/blacklight/catalog_spec.rb +++ b/spec/blacklight/catalog_spec.rb @@ -18,23 +18,23 @@ # Check facets within('div.blacklight-home_collection_id_ssim') do - expect(page).to have_selector('h3', text: 'Collection') + expect(page).to have_selector('h3[data-target="#facet-home_collection_id_ssim"]') expect(page).to have_link('Searching Collection') end within('div.blacklight-work_type_ssim') do - expect(page).to have_selector('h3', text: 'Resource Type') + expect(page).to have_selector('h3[data-target="#facet-work_type_ssim"]') expect(page).to have_link('Generic') end within('div.blacklight-collection_type_ssim') do - expect(page).to have_selector('h3', text: 'Collection Type') + expect(page).to have_selector('h3[data-target="#facet-collection_type_ssim"]') expect(page).to have_link('Archival Collection') end within('div.blacklight-generic_field_ssim') do - expect(page).to have_selector('h3', text: 'Generic Field') + expect(page).to have_selector('h3[data-target="#facet-generic_field_ssim"]') expect(page).to have_link('Faceted Value') end within('div.blacklight-creator_role_ssim') do - expect(page).to have_selector('h3', text: 'Role') + expect(page).to have_selector('h3[data-target="#facet-creator_role_ssim"]') expect(page).to have_link('blasting') end diff --git a/spec/cho/collection/archival_collections/index_spec.rb b/spec/cho/collection/archival_collections/index_spec.rb index 2c3c7765..81ccd864 100644 --- a/spec/cho/collection/archival_collections/index_spec.rb +++ b/spec/cho/collection/archival_collections/index_spec.rb @@ -12,9 +12,9 @@ end within('div.documents-list') do expect(page).to have_link('Archival collection index view') - expect(page).to have_blacklight_label('title_tesim').with('Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('Archival collection index view') - expect(page).to have_blacklight_label('collection_type_ssim').with('Collection Type') + expect(page).to have_blacklight_label('collection_type_ssim') expect(page).to have_blacklight_field('collection_type_ssim').with('Archival Collection') end end diff --git a/spec/cho/collection/curated_collections/index_spec.rb b/spec/cho/collection/curated_collections/index_spec.rb index 6af5699a..ecffade5 100644 --- a/spec/cho/collection/curated_collections/index_spec.rb +++ b/spec/cho/collection/curated_collections/index_spec.rb @@ -12,9 +12,9 @@ end within('div.documents-list') do expect(page).to have_link('Curated collection index view') - expect(page).to have_blacklight_label('title_tesim').with('Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('Curated collection index view') - expect(page).to have_blacklight_label('collection_type_ssim').with('Collection Type') + expect(page).to have_blacklight_label('collection_type_ssim') expect(page).to have_blacklight_field('collection_type_ssim').with('Curated Collection') end end diff --git a/spec/cho/collection/library_collections/index_spec.rb b/spec/cho/collection/library_collections/index_spec.rb index 43c1c2bd..6a3b4920 100644 --- a/spec/cho/collection/library_collections/index_spec.rb +++ b/spec/cho/collection/library_collections/index_spec.rb @@ -12,9 +12,9 @@ end within('div.documents-list') do expect(page).to have_link('Library collection index view') - expect(page).to have_blacklight_label('title_tesim').with('Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('Library collection index view') - expect(page).to have_blacklight_label('collection_type_ssim').with('Collection Type') + expect(page).to have_blacklight_label('collection_type_ssim') expect(page).to have_blacklight_field('collection_type_ssim').with('Library Collection') end end diff --git a/spec/cho/work/file_set/show_spec.rb b/spec/cho/work/file_set/show_spec.rb index 16a0bd25..56406fbd 100644 --- a/spec/cho/work/file_set/show_spec.rb +++ b/spec/cho/work/file_set/show_spec.rb @@ -9,7 +9,7 @@ visit(polymorphic_path([:solr_document], id: file_set.id)) expect(page).to have_content 'Part of: Sample Generic Work' within('div#document') do - expect(page).to have_blacklight_label('title_tesim').with('Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('Original File Name') end expect(page).to have_selector('h2', text: 'Files') diff --git a/spec/cho/work/import/create_spec.rb b/spec/cho/work/import/create_spec.rb index a0ab4baa..e60e8927 100644 --- a/spec/cho/work/import/create_spec.rb +++ b/spec/cho/work/import/create_spec.rb @@ -388,7 +388,7 @@ expect(page).to have_selector('td', text: 'work1_00002_02') expect(page).to have_content("Work type can't be blank") expect(page).to have_content("Object title can't be blank") - expect(page).to have_content('Collection missing_alt_id does not exist') + expect(page).to have_content(/missing_alt_id does not exist/) expect(page).to have_content("Creator role 'http://id.loc.gov/vocabulary/relators/asdf' does not exist") expect(page).to have_content("Creator agent 'Person, Missing' does not exist") expect(page).to have_content("Creator agent 'Guy, Bad' does not exist") diff --git a/spec/cho/work/submissions/index_spec.rb b/spec/cho/work/submissions/index_spec.rb index e440cf79..9cf09aa1 100644 --- a/spec/cho/work/submissions/index_spec.rb +++ b/spec/cho/work/submissions/index_spec.rb @@ -14,11 +14,11 @@ fill_in(:q, with: 'Work Index View') click_button('Search') within('div#documents') do - expect(page).to have_blacklight_label('title_tesim').with('Object Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('Work Index View') - expect(page).to have_blacklight_label('work_type_ssim').with('Resource Type') + expect(page).to have_blacklight_label('work_type_ssim') expect(page).to have_blacklight_field('work_type_ssim').with('Generic') - expect(page).to have_blacklight_label('home_collection_id_tesim').with('Collection') + expect(page).to have_blacklight_label('home_collection_id_tesim') expect(page).to have_blacklight_field('home_collection_id_tesim').with('Library Collection') expect(page).to have_link('Library Collection') end diff --git a/spec/cho/work/submissions/new_spec.rb b/spec/cho/work/submissions/new_spec.rb index 868f5d42..1f763452 100644 --- a/spec/cho/work/submissions/new_spec.rb +++ b/spec/cho/work/submissions/new_spec.rb @@ -31,25 +31,25 @@ click_button('Create Resource') expect(page).to have_selector('h1', text: 'New Title') within('#document') do - expect(page).to have_blacklight_label(:title_tesim, 'Object Title') + expect(page).to have_blacklight_label(:title_tesim) expect(page).to have_blacklight_field(:title_tesim, 'New Title') - expect(page).to have_blacklight_label(:subtitle_tesim, 'Subtitle') + expect(page).to have_blacklight_label(:subtitle_tesim) expect(page).to have_blacklight_field(:subtitle_tesim, 'New subtitle') - expect(page).to have_blacklight_label(:description_tesim, 'Description') + expect(page).to have_blacklight_label(:description_tesim) expect(page).to have_blacklight_field(:description_tesim, 'Description of new generic work') - expect(page).to have_blacklight_label(:created_tesim, 'Created') + expect(page).to have_blacklight_label(:created_tesim) expect(page).to have_blacklight_field(:created_tesim, 'datetime-2018-10-22T00:00:00.000Z') - expect(page).to have_blacklight_label(:generic_field_tesim, 'Generic Field') + expect(page).to have_blacklight_label(:generic_field_tesim) expect(page).to have_blacklight_field(:generic_field_tesim, 'Sample generic field value') - expect(page).to have_blacklight_label(:alternate_ids_tesim, 'Identifier') + expect(page).to have_blacklight_label(:alternate_ids_tesim) expect(page).to have_blacklight_field(:alternate_ids_tesim, 'id-asdf_1234') - expect(page).to have_blacklight_label(:work_type_ssim, 'Resource Type') + expect(page).to have_blacklight_label(:work_type_ssim) expect(page).to have_blacklight_field(:work_type_ssim, 'Generic') - expect(page).to have_blacklight_label(:home_collection_id_tesim, 'Member of Collection') + expect(page).to have_blacklight_label(:home_collection_id_tesim) expect(page).to have_blacklight_field(:home_collection_id_tesim, 'Sample Collection') expect(page).to have_blacklight_field(:home_collection_id_tesim, archival_collection.id) expect(page).to have_link('Sample Collection') - expect(page).to have_blacklight_label(:creator_tesim, 'Creator') + expect(page).to have_blacklight_label(:creator_tesim) expect(page).to have_blacklight_field(:creator_tesim, 'Christopher Kringle (climbing)') end expect(page).to have_link('Edit') @@ -67,8 +67,7 @@ click_button('Create Resource') within('.error-explanation') do expect(page).to have_selector('h2', text: '2 errors prohibited this resource from being saved:') - expect(page).to have_content("Object title can't be blank") - expect(page).to have_content("Collection can't be blank") + expect(page).to have_css('ul li', text: "can't be blank", count: 2) end fill_in('work_submission[title]', with: 'Required Title') fill_in('work_submission[home_collection_id]', with: archival_collection.id) diff --git a/spec/cho/work/submissions/show_spec.rb b/spec/cho/work/submissions/show_spec.rb index 76f09581..4e78b651 100644 --- a/spec/cho/work/submissions/show_spec.rb +++ b/spec/cho/work/submissions/show_spec.rb @@ -16,11 +16,11 @@ it 'displays only metadata' do visit(polymorphic_path([:solr_document], id: work.id)) within('div#document') do - expect(page).to have_blacklight_label('title_tesim').with('Object Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('No files') - expect(page).to have_blacklight_label('work_type_ssim').with('Resource Type') + expect(page).to have_blacklight_label('work_type_ssim') expect(page).to have_blacklight_field('work_type_ssim').with('Document') - expect(page).to have_blacklight_label('home_collection_id_tesim').with('Collection') + expect(page).to have_blacklight_label('home_collection_id_tesim') expect(page).to have_blacklight_field('home_collection_id_tesim').with('Library Collection') expect(page).to have_link('Library Collection') end @@ -34,9 +34,9 @@ it 'displays metadata and files' do visit(polymorphic_path([:solr_document], id: work.id)) within('div#document') do - expect(page).to have_blacklight_label('title_tesim').with('Title') + expect(page).to have_blacklight_label('title_tesim') expect(page).to have_blacklight_field('title_tesim').with('An editable file') - expect(page).to have_blacklight_label('work_type_ssim').with('Resource Type') + expect(page).to have_blacklight_label('work_type_ssim') expect(page).to have_blacklight_field('work_type_ssim').with('Document') end expect(page).to have_link(