Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 0a718e2

Browse files
authored
Digital Object Merge (#67)
1 parent 804fdd3 commit 0a718e2

File tree

3 files changed

+177
-2
lines changed

3 files changed

+177
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Feature: Digital Object merge
2+
Background:
3+
Given an administrator user is logged in
4+
And two Digital Objects A & B have been created
5+
Scenario: Merge two Digital Objects by browsing
6+
Given the Digital Object A is opened in edit mode
7+
When the user clicks on 'Merge'
8+
And the user clicks on the dropdown in the merge dropdown form
9+
And the user clicks on 'Browse' in the merge dropdown form
10+
And the user filters by text with the Digital Object B title in the modal
11+
And the user selects the Digital Object B from the search results in the modal
12+
And the user clicks on 'Link' in the modal
13+
And the user clicks on 'Merge' in the merge dropdown form
14+
And the user clicks on 'Merge' in the modal
15+
Then the 'Digital Object(s)' merged message is displayed
16+
And the Digital Object B is deleted
17+
And the following linked records from the Digital Object B are appended to the Digital Object A
18+
| Agent Links |
19+
| Subjects |
20+
| Classifications |
21+
Scenario: Merge two Digital Objects by searching
22+
Given the Digital Object A is opened in edit mode
23+
When the user clicks on 'Merge'
24+
And the user fills in and selects the Digital Object B in the merge dropdown form
25+
And the user clicks on 'Merge' in the merge dropdown form
26+
And the user clicks on 'Merge' in the modal
27+
Then the 'Digital Object(s)' merged message is displayed
28+
And the Digital Object B is deleted
29+
And the following linked records from the Digital Object B are appended to the Digital Object A
30+
| Agent Links |
31+
| Subjects |
32+
| Classifications |
33+
Scenario: Merge two Digital Objects by creating the second Digital Object
34+
Given the Digital Object A is opened in edit mode
35+
When the user clicks on 'Merge'
36+
And the user clicks on the dropdown in the merge dropdown form
37+
And the user clicks on 'Create' in the merge dropdown form
38+
And the user fills in 'Title' with 'B' in the modal
39+
And the user fills in 'Identifier' in the modal
40+
And the user clicks on 'Create and Link' in the modal
41+
And the user clicks on 'Merge' in the dropdown menu
42+
And the user clicks on 'Merge' in the modal
43+
Then the 'Digital Object(s)' merged message is displayed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# frozen_string_literal: true
2+
3+
Given 'two Digital Objects A & B have been created' do
4+
visit "#{STAFF_URL}/digital_objects/new"
5+
6+
fill_in 'digital_object_digital_object_id_', with: "Digital Object A #{@uuid}"
7+
fill_in 'digital_object_title_', with: "Digital Object A #{@uuid}"
8+
9+
click_on 'Save'
10+
wait_for_ajax
11+
12+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object A #{@uuid} Created"
13+
@digital_object_first_id = current_url.split('::digital_object_').pop
14+
15+
visit "#{STAFF_URL}/digital_objects/new"
16+
17+
fill_in 'digital_object_digital_object_id_', with: "Digital Object B #{@uuid}"
18+
fill_in 'digital_object_title_', with: "Digital Object B #{@uuid}"
19+
20+
click_on 'Add Agent Link'
21+
select 'Creator', from: 'digital_object_linked_agents__0__role_'
22+
fill_in 'digital_object_linked_agents__0__title_', with: "Resource #{@uuid} Agent Title"
23+
fill_in 'digital_object_linked_agents__0__relator_', with: 'annotator'
24+
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
25+
dropdown_items.first.click
26+
fill_in 'token-input-digital_object_linked_agents__0__ref_', with: 'test_agent'
27+
dropdown_items = all('li.token-input-dropdown-item2')
28+
dropdown_items.first.click
29+
30+
click_on 'Add Subject'
31+
fill_in 'token-input-digital_object_subjects__0__ref_', with: 'test_subject'
32+
dropdown_items = all('li.token-input-dropdown-item2')
33+
dropdown_items.first.click
34+
35+
click_on 'Add Classification'
36+
fill_in 'token-input-digital_object_classifications__0__ref_', with: 'test_classification'
37+
dropdown_items = all('li.token-input-dropdown-item2')
38+
dropdown_items.first.click
39+
40+
click_on 'Save'
41+
wait_for_ajax
42+
43+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object B #{@uuid} Created"
44+
@digital_object_second_id = current_url.split('::digital_object_').pop
45+
end
46+
47+
Given 'the Digital Object A is opened in edit mode' do
48+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_first_id}/edit"
49+
end
50+
51+
When 'the user selects the Digital Object B from the search results in the modal' do
52+
within '.modal-content' do
53+
within '#tabledSearchResults' do
54+
rows = all('tr', text: "Digital Object B #{@uuid}")
55+
expect(rows.length).to eq 1
56+
57+
find('input[type="radio"]').click
58+
end
59+
end
60+
end
61+
62+
When 'the user filters by text with the Digital Object B title in the modal' do
63+
within '.modal-content' do
64+
fill_in 'Filter by text', with: "Digital Object B #{@uuid}"
65+
find('.search-filter button').click
66+
67+
rows = []
68+
checks = 0
69+
70+
while checks < 5
71+
checks += 1
72+
73+
begin
74+
rows = all('tr', text: "Digital Object B #{@uuid}")
75+
rescue Selenium::WebDriver::Error::JavascriptError
76+
sleep 1
77+
end
78+
79+
break if rows.length == 1
80+
end
81+
end
82+
end
83+
84+
When 'the user fills in and selects the Digital Object B in the merge dropdown form' do
85+
fill_in 'token-input-merge_ref_', with: "Digital Object B #{@uuid}"
86+
dropdown_items = all('li.token-input-dropdown-item2')
87+
dropdown_items.first.click
88+
end
89+
90+
Then 'the Digital Object B is deleted' do
91+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_second_id}"
92+
93+
expect(page).to have_text 'Record Not Found'
94+
end
95+
96+
Then 'the following linked records from the Digital Object B are appended to the Digital Object A' do |forms|
97+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_first_id}/edit"
98+
99+
forms.raw.each do |form_title|
100+
form_title = form_title[0]
101+
102+
section_title = find('h3', text: form_title)
103+
section = section_title.ancestor('section')
104+
expect(section[:id]).to_not eq nil
105+
106+
case form_title
107+
when 'Agent Links'
108+
expect(find('#digital_object_linked_agents__0__role_').value).to eq 'creator'
109+
expect(find('#digital_object_linked_agents__0__title_').value).to eq "Resource #{@uuid} Agent Title"
110+
expect(find('#digital_object_linked_agents__0__relator_').value).to eq 'Annotator'
111+
expect(find('#digital_object_linked_agents__0__ref__combobox .token-input-token').text).to include 'test_agent'
112+
when 'Related Accessions'
113+
expect(find('#digital_object_related_accessions__0__ref__combobox').text).to include 'test_accession'
114+
when 'Subjects'
115+
expect(find('#digital_object_subjects__0_ .token-input-token').text).to include 'test_subject_term'
116+
when 'Classifications'
117+
expect(find('#digital_object_classifications__0__ref__combobox').text).to include 'test_classification'
118+
else
119+
raise "Invalid form provided: #{form_title}"
120+
end
121+
end
122+
end

staff_features/shared/step_definitions.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
end
7171

7272
When 'the user clicks on {string} in the dropdown menu' do |string|
73-
within '.dropdown-menu' do |dropdown_menu|
73+
dropdown_menu = all('.dropdown-menu').first
74+
75+
within dropdown_menu do
7476
elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]")
7577

7678
elements.each do |element|
@@ -128,6 +130,14 @@
128130
fill_in label, with: @uuid, match: :first
129131
end
130132

133+
When 'the user fills in {string} in the modal' do |label|
134+
@uuid = SecureRandom.uuid if @uuid.nil?
135+
136+
within '.modal-content' do
137+
fill_in label, with: @uuid, match: :first
138+
end
139+
end
140+
131141
When 'the user clears the {string} field' do |label|
132142
fill_in label, with: '', match: :first
133143
end
@@ -264,7 +274,7 @@
264274
end
265275

266276
Then('the {string} merged message is displayed') do |string|
267-
expect(find('.alert.alert-success.with-hide-alert').text).to eq("#{string} Merged")
277+
expect(find('.alert.alert-success.with-hide-alert').text.downcase).to eq("#{string} Merged".downcase)
268278
end
269279

270280
Then 'the following message is displayed' do |messages|

0 commit comments

Comments
 (0)