From e3a6c90ed67adf3177f3381e23b1bf2bd29f94b2 Mon Sep 17 00:00:00 2001 From: delasthanos Date: Wed, 28 Aug 2024 20:41:56 +0300 Subject: [PATCH] Update resource basic information step definitions --- helpers/helpers.rb | 48 +++++++++++++ .../resources/add-additional-info.feature | 25 ------- .../update-basic-information.feature | 23 +++++++ .../resources/update-basic-information.rb | 69 +++++++++++++++++++ staff-features/shared/step_definitions.rb | 33 +++------ 5 files changed, 150 insertions(+), 48 deletions(-) delete mode 100644 staff-features/resources/add-additional-info.feature create mode 100644 staff-features/resources/update-basic-information.feature create mode 100644 staff-features/resources/update-basic-information.rb diff --git a/helpers/helpers.rb b/helpers/helpers.rb index 30628f33..9fa6c3c6 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -1,5 +1,53 @@ # frozen_string_literal: true +def search(uuid) + visit STAFF_URL + + fill_in 'global-search-box', with: uuid + find('#global-search-button').click +end + +def login_admin + visit STAFF_URL + + fill_in 'username', with: 'admin' + fill_in 'password', with: 'admin' + + click_on 'Sign In' + + expect(page).to have_content 'Welcome to ArchivesSpace' + expect(page).to have_content 'Your friendly archives management tool.' + element = find('.global-header .user-container') + expect(element.text.strip).to eq 'admin' +end + +def create_resource(uuid) + fill_in 'resource_title_', with: "Resource #{uuid}" + fill_in 'resource_id_0_', with: "Resource #{uuid}" + select 'Class', from: 'resource_level_' + element = find('#resource_lang_materials__0__language_and_script__language_') + element.send_keys('AU') + element.send_keys(:tab) + + select 'Single', from: 'resource_dates__0__date_type_' + fill_in 'resource_dates__0__begin_', with: '2024' + + fill_in 'resource_extents__0__number_', with: '10' + select 'Cassettes', from: 'resource_extents__0__extent_type_' + + 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) + + find('button', text: 'Save Resource', match: :first).click + + expect(page).to have_text "Resource Resource #{uuid} created" +end + def expect_record_to_be_in_search_results(search_term) fill_in 'global-search-box', with: search_term find('#global-search-button').click diff --git a/staff-features/resources/add-additional-info.feature b/staff-features/resources/add-additional-info.feature deleted file mode 100644 index 5d8f0ec1..00000000 --- a/staff-features/resources/add-additional-info.feature +++ /dev/null @@ -1,25 +0,0 @@ -Feature: Resources management - Add additional information - Background: - Given I am signed in as administrator - And I am in the edit mode of a resource record - - Scenario: Successfully add additional information about resource type by clicking on the Save button in the toolbar - When I click on "Basic Information" in the left sidebar - And I select "Records" from the "Resource Type" dropdown menu in the basic information section - And I click on the "Save" button in the resource toolbar - Then the additional information is added - And the message "Resource updated" is displayed - - Scenario: Successfully add additional information about publishing by clicking on the Save button at the bottom of the sidebar - When I click on "Basic Information" in the left sidebar - And I check the "Publish" checkbox in the basic information section - And I click on the "Save" button at the bottom of the sidebar - Then the additional information is added - And the message "Resource updated" is displayed - - Scenario: Discard changes by clicking on the Revert Changes button - When I click on "Basic Information" in the left sidebar - And I check the "Restrictions apply" checkbox in the basic information section - And I click on the "Revert Changes" button in the resource toolbar - Then the additional information has not been added - And the "Revert Changes" button disappears \ No newline at end of file diff --git a/staff-features/resources/update-basic-information.feature b/staff-features/resources/update-basic-information.feature new file mode 100644 index 00000000..1d068be9 --- /dev/null +++ b/staff-features/resources/update-basic-information.feature @@ -0,0 +1,23 @@ +Feature: Update Resource Basic Information + Background: + Given I am logged in as an admin user + Given a resource has been created + Scenario: Successfully update resource basic information + Given I am on the resource edit page + When I select "Records" from "Resource Type" + When I check Publish? + When I check Restrictions Apply? + When I fill in Repository Processing Note with "Repository Processing Note" + When I click on "Save Resource" + Then the resource is successfully updated + Then Resource Type has value Records + Then Publish? is checked + Then Restrictions Apply? is checked + Then Repository Processing Note has value "Repository Processing Note" + Scenario: Revert changes + Given I am on the resource edit page + When I change the resource Title + When I change the resource Identifier + When I click on "Revert Changes" + Then the resource Title does not change + Then the resource Identifier does not change diff --git a/staff-features/resources/update-basic-information.rb b/staff-features/resources/update-basic-information.rb new file mode 100644 index 00000000..f8f6c931 --- /dev/null +++ b/staff-features/resources/update-basic-information.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +Given 'a resource has been created' do + @uuid = SecureRandom.uuid + + visit "#{STAFF_URL}/resources/new" + + create_resource(@uuid) +end + +Given 'I am on the resource edit page' do + search(@uuid) + + click_on 'Edit' +end + +When 'I check Publish?' do + find('#resource_publish_').check +end + +When 'I check Restrictions Apply?' do + find('#resource_restrictions_').check +end + +When 'I fill in Repository Processing Note with {string}' do |value| + fill_in 'Repository Processing Note', with: value +end + +When 'I change the resource Title' do + uuid = SecureRandom.uuid + + fill_in 'resource_title_', with: "Resource title chagned" +end + +When 'I change the resource Identifier' do + fill_in 'resource_id_0_', with: "Resource identifier chagned" +end + +Then 'the resource is successfully updated' do + element = find('.alert.alert-success.with-hide-alert') + expect(element.text).to eq "Resource Resource #{@uuid} updated" +end + +Then 'Resource Type has value Records' do + # search(@uuid) + # click_on 'Edit' + element = find('#resource_resource_type_') + expect(element.value).to eq 'records' +end + +Then 'Publish? is checked' do + expect(find('#resource_publish_').check.checked?).to eq true +end + +Then 'Restrictions Apply? is checked' do + expect(find('#resource_restrictions_').check.checked?).to eq true +end + +Then 'Repository Processing Note has value {string}' do |value| + expect(find('#resource_repository_processing_note_').value).to eq value +end + +Then('the resource Title does not change') do + expect(find('#resource_title_').value).to eq "Resource #{@uuid}" +end + +Then('the resource Identifier does not change') do + expect(find('#resource_id_0_').value).to eq "Resource #{@uuid}" +end diff --git a/staff-features/shared/step_definitions.rb b/staff-features/shared/step_definitions.rb index d5919f7f..ad982c3c 100644 --- a/staff-features/shared/step_definitions.rb +++ b/staff-features/shared/step_definitions.rb @@ -1,32 +1,11 @@ # frozen_string_literal: true Given 'the user is logged in as admin' do - visit STAFF_URL - - fill_in 'username', with: 'admin' - fill_in 'password', with: 'admin' - - click_on 'Sign In' - - expect(page).to have_content 'Welcome to ArchivesSpace' - expect(page).to have_content 'Your friendly archives management tool.' - element = find('.global-header .user-container') - expect(element.text.strip).to eq 'admin' + login_admin end Given 'I am logged in as an admin user' do - visit "#{STAFF_URL}/logout" - visit STAFF_URL - - fill_in 'username', with: 'admin' - fill_in 'password', with: 'admin' - - click_on 'Sign In' - - expect(page).to have_content 'Welcome to ArchivesSpace' - expect(page).to have_content 'Your friendly archives management tool.' - element = find('.global-header .user-container') - expect(element.text.strip).to eq 'admin' + login_admin end Given 'I am signed in as a view-only user' do @@ -73,6 +52,14 @@ elements.first.click end +When 'I fill in {string} with {string}' do |label, value| + fill_in label, with: value +end + +When 'I select {string} from {string}' do |option, label| + select option, from: label +end + Then 'the message {string} is displayed' do |string| expect(page).to have_text string end