Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital Object delete #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ AllCops:
Metrics/AbcSize:
Max: 50

Metrics/BlockLength:
Max: 80

Layout/LineLength:
Max: 200

Expand All @@ -18,9 +15,6 @@ Metrics/MethodLength:
Metrics/BlockLength:
Max: 90

Layout/LineLength:
Max: 180

Layout/ElseAlignment:
Enabled: false

Expand Down
32 changes: 32 additions & 0 deletions staff_features/digital_objects/digital_object_delete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 modal
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 modal
Then the Digital Objects page is displayed
And the 'Digital Object' deleted message is displayed
And the Digital Object is deleted
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

@donaldjosephsmith donaldjosephsmith Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you finding that wait_for_ajax is actually necessary here? It probably doesn't hurt (other than the time taken by sleep), but there shouldn't be any AJAX stuff going on here as the Save button just does a standard form submit.

Copy link
Collaborator

@blacksmith-welder blacksmith-welder Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you click on Save, the page reloads and then you are in the digital object edit page, which loads the edit form by doing a request at digital_objects/20/edit?inline=true. After the wait_for_ajax, we are expecting a success message, which is part of this inline form.

Running this test locally, seems to always succeed without wait_for_ajax, but we have experienced failing tests in similar occasions, that is why it is used here.

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
Loading