diff --git a/staff_features/accessions/step_definitions/accession_shared.rb b/staff_features/accessions/step_definitions/accession_shared.rb index 9757ddb2..368684cc 100644 --- a/staff_features/accessions/step_definitions/accession_shared.rb +++ b/staff_features/accessions/step_definitions/accession_shared.rb @@ -95,6 +95,30 @@ expect(page).to have_text "Accession Accession Title #{@uuid} created" end +Given 'an Accession with a Top Container has been created' do + visit "#{STAFF_URL}/accessions/new" + + fill_in 'accession_id_0_', with: "Accession #{@uuid}" + fill_in 'Title', with: "Accession Title #{@uuid}" + fill_in 'Accession Date', with: ORIGINAL_ACCESSION_DATE + check 'Publish?' + + click_on 'Add Container Instance' + select 'Accession', from: 'accession_instances__0__instance_type_' + + within '#accession_instances__0__sub_container__top_container__ref__combobox' do + find('button').click + + click_on 'Create' + end + + fill_in 'top_container_indicator_', with: @uuid + click_on 'Create and Link' + + click_on 'Save' + expect(page).to have_text "Accession Accession Title #{@uuid} created" +end + Given 'the Accession is opened in edit mode' do visit "#{STAFF_URL}/accessions" diff --git a/staff_features/resources/step_definitions/resource_shared.rb b/staff_features/resources/step_definitions/resource_shared.rb index 1a429ae9..c0fdfe89 100644 --- a/staff_features/resources/step_definitions/resource_shared.rb +++ b/staff_features/resources/step_definitions/resource_shared.rb @@ -1,5 +1,58 @@ # frozen_string_literal: true +Given 'a Resource with a Top Container has been created' do + visit "#{STAFF_URL}/resources/new" + + visit "#{STAFF_URL}/resources/new" + + fill_in 'resource_title_', with: "Resource #{@uuid}" + fill_in 'resource_id_0_', with: "Resource #{@uuid}" + find('#resource_publish_').check + select 'Class', from: 'resource_level_' + + click_on 'Add Container Instance' + select 'Accession', from: 'resource_instances__0__instance_type_' + + within '#resource_instances__0__sub_container__top_container__ref__combobox' do + find('button').click + + click_on 'Create' + end + + fill_in 'top_container_indicator_', with: @uuid + click_on 'Create and Link' + + languages = all('#resource_lang_materials_ .subrecord-form-list li') + click_on 'Add Language' if languages.length == 0 + element = find('#resource_lang_materials__0__language_and_script__language_') + element.send_keys(ORIGINAL_LANGUAGE) + element.send_keys(:tab) + + select 'Single', from: 'resource_dates__0__date_type_' + fill_in 'resource_dates__0__begin_', with: ORIGINAL_RESOURCE_DATE + @resource_number_of_dates = 1 + + fill_in 'resource_extents__0__number_', with: '10' + select 'Cassettes', from: 'resource_extents__0__extent_type_' + @resource_number_of_extents = 1 + + element = find('#resource_finding_aid_language_') + element.send_keys('ENG') + element.send_keys(:tab) + + element = find('#resource_finding_aid_script_') + element.send_keys('Latin') + element.send_keys(:tab) + + click_on 'Save' + + expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Resource Resource #{@uuid} created" + + uri_parts = current_url.split('/') + uri_parts.pop + @resource_id = uri_parts.pop +end + Given 'the Resource is opened in the view mode' do visit "#{STAFF_URL}/resources/#{@resource_id}" end diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index f810220a..59820b79 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -421,3 +421,9 @@ Then 'the button has text {string}' do |text| expect(page).to have_text text end + +When 'the user clicks on the gear icon' do + within '.repo-container' do + find('.btn.btn-default.navbar-btn.dropdown-toggle').click + end +end diff --git a/staff_features/top_containers/step_definitions/step_definitions.rb b/staff_features/top_containers/step_definitions/step_definitions.rb new file mode 100644 index 00000000..cfd5b8bb --- /dev/null +++ b/staff_features/top_containers/step_definitions/step_definitions.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +When 'the user fills in {string} with the Resource title' do |label| + fill_in label, with: @uuid +end + +When 'the user fills in {string} with the Accession title' do |label| + fill_in label, with: @uuid +end + +Then 'the Top Container associated with the Resource is in the search results' do + results = all('#bulk_operation_results tbody tr') + expect(results.length).to eq 1 + expect(results[0].text).to include @uuid +end + +Then 'the Top Container associated with the Accession is in the search results' do + results = all('#bulk_operation_results tbody tr') + expect(results.length).to eq 1 + expect(results[0].text).to include @uuid +end diff --git a/staff_features/top_containers/top_container_search.feature b/staff_features/top_containers/top_container_search.feature index 2e076059..453ec823 100644 --- a/staff_features/top_containers/top_container_search.feature +++ b/staff_features/top_containers/top_container_search.feature @@ -2,14 +2,16 @@ Feature: Top container Search Background: Given an administrator user is logged in Scenario: Search Top Container associated with a Resource - Given a Top Container has been created for a Resource + Given a Resource with a Top Container has been created When the user clicks on the gear icon And the user clicks on 'Manage Top Containers' - And the user filters by text with the Resource title + And the user fills in 'Keyword' with the Resource title + And the user clicks on 'Search' Then the Top Container associated with the Resource is in the search results Scenario: Search Top Container associated with an Accession - Given a Top Container has been created for an Accession + Given an Accession with a Top Container has been created When the user clicks on the gear icon And the user clicks on 'Manage Top Containers' - And the user filters by text with the Accession title - Then the Top Container associated with the Accession is in the search results \ No newline at end of file + And the user fills in 'Keyword' with the Accession title + And the user clicks on 'Search' + Then the Top Container associated with the Accession is in the search results