From 7f30ee5465598fc195ba244ad2f06ee5780eba9b Mon Sep 17 00:00:00 2001 From: dinadi Date: Thu, 19 Dec 2024 09:42:39 +0200 Subject: [PATCH 1/2] digital object delete --- .../digital_object_delete.feature | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 staff_features/digital_objects/digital_object_delete.feature diff --git a/staff_features/digital_objects/digital_object_delete.feature b/staff_features/digital_objects/digital_object_delete.feature new file mode 100644 index 00000000..21ee4fac --- /dev/null +++ b/staff_features/digital_objects/digital_object_delete.feature @@ -0,0 +1,33 @@ +Feature: Digital Object Delete + Background: + Given an administrator user is logged in + And a Digital Object has been created + Scenario: Digital Object is deleted from the search results + When the user clicks on 'Browse' + And the user clicks on 'Digital Objects' + And the user filters by text with the Digital Object title + And the user checks the checkbox of the Digital Object + And the user clicks on 'Delete' + And the user clicks on 'Delete Records' + Then the 'Records' deleted message is displayed + And the Digital Object is deleted + Scenario: Digital Object is deleted from the view page + Given the user is on the Digital Object view page + When the user clicks on 'Delete' + And the user clicks on 'Delete' in the confirm popup + Then the Digital Objects page is displayed + And the 'Digital Object' deleted message is displayed + And the Digital Object is deleted + Scenario: Cancel Digital Object delete from the view page + Given the user is on the Digital Object view page + When the user clicks on 'Delete' + And the user clicks on 'Cancel' + Then the user is still on the Digital Object view page + Scenario: Digital Object is deleted from the edit page + Given the user is on the Digital Object edit page + When the user clicks on 'Delete' + And the user clicks on 'Delete' in the confirm popup + Then the Digital Objects page is displayed + And the 'Digital Object' deleted message is displayed + And the Digital Object is deleted + \ No newline at end of file From b87b02fad6f63f8b18babd11e50ca030e3e6f77c Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Sat, 21 Dec 2024 10:46:09 +0200 Subject: [PATCH 2/2] Digital object delete --- .rubocop.yml | 6 --- .../digital_object_delete.feature | 7 ++- .../step_definitions/digital_object_delete.rb | 16 ++++++ .../step_definitions/digital_object_shared.rb | 53 +++++++++++++++++++ 4 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 staff_features/digital_objects/step_definitions/digital_object_delete.rb create mode 100644 staff_features/digital_objects/step_definitions/digital_object_shared.rb 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/staff_features/digital_objects/digital_object_delete.feature b/staff_features/digital_objects/digital_object_delete.feature index 21ee4fac..110530e6 100644 --- a/staff_features/digital_objects/digital_object_delete.feature +++ b/staff_features/digital_objects/digital_object_delete.feature @@ -14,10 +14,10 @@ Feature: Digital Object Delete Scenario: Digital Object is deleted from the view page Given the user is on the Digital Object view page When the user clicks on 'Delete' - And the user clicks on 'Delete' in the confirm popup + And the user clicks on 'Delete' in the modal Then the Digital Objects page is displayed And the 'Digital Object' deleted message is displayed - And the Digital Object is deleted + And the Digital Object is deleted Scenario: Cancel Digital Object delete from the view page Given the user is on the Digital Object view page When the user clicks on 'Delete' @@ -26,8 +26,7 @@ Feature: Digital Object Delete Scenario: Digital Object is deleted from the edit page Given the user is on the Digital Object edit page When the user clicks on 'Delete' - And the user clicks on 'Delete' in the confirm popup + And the user clicks on 'Delete' in the modal Then the Digital Objects page is displayed And the 'Digital Object' deleted message is displayed And the Digital Object is deleted - \ No newline at end of file diff --git a/staff_features/digital_objects/step_definitions/digital_object_delete.rb b/staff_features/digital_objects/step_definitions/digital_object_delete.rb new file mode 100644 index 00000000..4e5b9656 --- /dev/null +++ b/staff_features/digital_objects/step_definitions/digital_object_delete.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +When 'the user checks the checkbox of the Digital Object' do + find('#multiselect-item').check +end + +Then 'the Digital Object is deleted' do + expect(@digital_object_id).to_not eq nil + + visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit" + + expect(find('h2').text).to eq 'Record Not Found' + + expected_text = "The record you've tried to access may no longer exist or you may not have permission to view it." + expect(page).to have_text expected_text +end diff --git a/staff_features/digital_objects/step_definitions/digital_object_shared.rb b/staff_features/digital_objects/step_definitions/digital_object_shared.rb new file mode 100644 index 00000000..eb74163a --- /dev/null +++ b/staff_features/digital_objects/step_definitions/digital_object_shared.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +Given 'a Digital Object has been created' do + visit "#{STAFF_URL}/digital_objects/new" + + fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}" + fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}" + + click_on 'Save' + + wait_for_ajax + expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created" + @digital_object_id = current_url.split('::digital_object_').pop +end + +When 'the user filters by text with the Digital Object title' do + fill_in 'Filter by text', with: "Digital Object Identifier #{@uuid}" + + find('#filter-text').send_keys(:enter) + + rows = [] + checks = 0 + + while checks < 5 + checks += 1 + + begin + rows = all('tr', text: @uuid) + rescue Selenium::WebDriver::Error::JavascriptError + sleep 1 + end + + break if rows.length == 1 + end +end + +Given 'the user is on the Digital Object view page' do + visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}" +end + +Given 'the user is on the Digital Object edit page' do + visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit" +end + +Then 'the Digital Objects page is displayed' do + expect(find('h2').text).to have_text 'Digital Objects' + expect(current_url).to include "#{STAFF_URL}/digital_objects" +end + +Then 'the user is still on the Digital Object view page' do + expect(find('h2').text).to eq "Digital Object Title #{@uuid} Digital Object" + expect(current_url).to include "#{STAFF_URL}/digital_objects/#{@digital_object_id}" +end