From 7b8c732107dfb232353d15af8e48930b135f2971 Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Mon, 2 Dec 2024 17:59:37 +0200 Subject: [PATCH] Resource unpublish --- .rubocop.yml | 6 ------ helpers/helpers.rb | 2 +- helpers/original_values.rb | 1 + .../resources/resource_unpublish.feature | 16 ++++++++-------- .../resources/step_definitions/resource_edit.rb | 6 +----- .../step_definitions/resource_shared.rb | 4 ++++ staff_features/shared/step_definitions.rb | 10 +++++++++- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 117c4aa5..339fecec 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,9 +6,6 @@ AllCops: Metrics/AbcSize: Max: 50 -Metrics/BlockLength: - Max: 80 - Layout/LineLength: Max: 200 @@ -18,9 +15,6 @@ Metrics/MethodLength: Metrics/BlockLength: Max: 90 -Layout/LineLength: - Max: 180 - Layout/ElseAlignment: Enabled: false diff --git a/helpers/helpers.rb b/helpers/helpers.rb index f0eebd17..0d84f9cf 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -192,7 +192,7 @@ def create_resource(uuid) find('#resource_publish_').check select 'Class', from: 'resource_level_' element = find('#resource_lang_materials__0__language_and_script__language_') - element.send_keys('AU') + element.send_keys(ORIGINAL_LANGUAGE) element.send_keys(:tab) select 'Single', from: 'resource_dates__0__date_type_' diff --git a/helpers/original_values.rb b/helpers/original_values.rb index 64a3c60b..c51261a5 100644 --- a/helpers/original_values.rb +++ b/helpers/original_values.rb @@ -3,3 +3,4 @@ ORIGINAL_ACCESSION_DATE = '2000-01-01' ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE = '2000-01-01' ORIGINAL_RESOURCE_DATE = '2000-01-01' +ORIGINAL_LANGUAGE = 'Australian languages' diff --git a/staff_features/resources/resource_unpublish.feature b/staff_features/resources/resource_unpublish.feature index 4834740c..152db76b 100644 --- a/staff_features/resources/resource_unpublish.feature +++ b/staff_features/resources/resource_unpublish.feature @@ -1,13 +1,13 @@ Feature: Resource Unpublish Background: Given an administrator user is logged in - And a Resource has been created - And the Resource is opened in edit mode + And a Resource has been created + And the Resource is opened in edit mode Scenario: Unpublish the Resource record from toolbar - When the user clicks on 'Unpublish All' - And the user clicks on 'Unpublish All' in the confirm popup - Then the 'Resource' published message is displayed + When the user clicks on 'Unpublish All' + And the user clicks on 'Unpublish All' in the modal + Then the 'Resource' unpublished message is displayed Scenario: Unpublish the Resource record from the Publish checkbox in the Basic Information section - When the user unchecks 'Publish' - And the user clicks on 'Save' - Then the 'Resource' updated message is displayed + When the user unchecks 'Publish' + And the user clicks on 'Save' + Then the 'Resource' updated message is displayed diff --git a/staff_features/resources/step_definitions/resource_edit.rb b/staff_features/resources/step_definitions/resource_edit.rb index dbe814b2..12b592ea 100644 --- a/staff_features/resources/step_definitions/resource_edit.rb +++ b/staff_features/resources/step_definitions/resource_edit.rb @@ -19,10 +19,6 @@ end end -Given 'the Resource is opened in the view mode' do - visit "#{STAFF_URL}/resources/#{@resource_id}" -end - Given 'the Resource has one Language' do languages = all('#resource_lang_materials_ .subrecord-form-list .subrecord-form-wrapper') @@ -66,7 +62,7 @@ languages = all('#resource_lang_materials_ .subrecord-form-wrapper') expect(languages.length).to eq 1 - expect(find('#resource_lang_materials__0__language_and_script__language_').value).to eq 'Australian languages' + expect(find('#resource_lang_materials__0__language_and_script__language_').value).to eq ORIGINAL_LANGUAGE end Then 'the Resource does not have Notes' do diff --git a/staff_features/resources/step_definitions/resource_shared.rb b/staff_features/resources/step_definitions/resource_shared.rb index ec6185b1..06c1b745 100644 --- a/staff_features/resources/step_definitions/resource_shared.rb +++ b/staff_features/resources/step_definitions/resource_shared.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +Given 'the Resource is opened in the view mode' do + visit "#{STAFF_URL}/resources/#{@resource_id}" +end + Given 'the Resource is opened in edit mode' do visit "#{STAFF_URL}/resources/#{@resource_id}/edit" wait_for_ajax diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index fb4348f3..ff571097 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -200,6 +200,10 @@ check label, match: :first end +When 'the user unchecks {string}' do |label| + uncheck label, match: :first +end + When 'the user changes the {string} field to {string}' do |field, value| fill_in field, with: value, match: :first end @@ -223,7 +227,11 @@ end Then('the {string} published message is displayed') do |string| - expect(find('.alert.alert-success.with-hide-alert').text).to match(/#{string} .* its subrecords and components have been published.*$/i) + expect(find('.alert.alert-success.with-hide-alert').text).to match(/#{string} .* subrecords and components have been published.*$/i) +end + +Then('the {string} unpublished message is displayed') do |string| + expect(find('.alert.alert-success.with-hide-alert').text).to match(/#{string} .* subrecords and components have been unpublished.*$/i) end Then 'the following message is displayed' do |messages|