Skip to content

Commit d408001

Browse files
Digital object component reorder
1 parent 07bb6be commit d408001

File tree

2 files changed

+159
-17
lines changed

2 files changed

+159
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
Feature: Digital Object Component Reorder
22
Background:
33
Given an administrator user is logged in
4-
And a Digital Object with 2 Digital Object Components has been created
5-
And the Digital Object is opened in edit mode
64
Scenario: Activate reorder mode
5+
Given a Digital Object with two Digital Object Components has been created
6+
And the Digital Object is opened in edit mode
77
When the user clicks on 'Enable Reorder Mode'
8-
Then button turns green
9-
And the button has text 'Disable Reorder Mode'
8+
Then the button has text 'Disable Reorder Mode'
109
Scenario: Cut and Paste a Digital Object Component
11-
When the user selects a Digital Object Component
10+
Given a Digital Object with two Digital Object Components has been created
11+
And the Digital Object is opened in edit mode
12+
When the user clicks on 'Enable Reorder Mode'
13+
And the user selects the second Digital Object Component
1214
And the user clicks on 'Cut'
13-
And the user clicks on the component that represents the desired position in the tree
15+
And the user selects the first Digital Object Component
1416
And the user clicks on 'Paste'
15-
Then the component is pasted as a child of the selected component
16-
Scenario: Move a Digital Object Component Up a Level
17-
Given a Digital Object Component has a child
18-
When the user selects the child Digital Object Component
17+
Then the second Digital Object Component is pasted as a child of the Digital Object Component
18+
Scenario: Move a Digital Object Component up a level
19+
Given a Digital Object with two nested Digital Object Components has been created
20+
When the user selects the second Digital Object Component
21+
When the user clicks on 'Enable Reorder Mode'
1922
And the user clicks on 'Move'
2023
And the user clicks on 'Up a Level' in the dropdown menu
21-
Then the selected Digital Object Component moves a level up
22-
Scenario: Move Up a Digital Object Component
23-
When the user selects a Digital Object Component
24+
Then the second Digital Object Component moves a level up
25+
Scenario: Move a Digital Object Component up
26+
Given a Digital Object with two Digital Object Components has been created
27+
And the Digital Object is opened in edit mode
28+
When the user selects the second Digital Object Component
29+
And the user clicks on 'Enable Reorder Mode'
2430
And the user clicks on 'Move'
2531
And the user clicks on 'Up' in the dropdown menu
26-
Then the Digital Object Component moves one position up
32+
Then the second Digital Object Component moves one position up
2733
Scenario: Move Down Into a Digital Object Component
28-
When the user selects a Digital Object Component
34+
Given a Digital Object with two Digital Object Components has been created
35+
And the Digital Object is opened in edit mode
36+
When the user selects the second Digital Object Component
37+
And the user clicks on 'Enable Reorder Mode'
2938
And the user clicks on 'Move'
3039
And the user clicks on 'Down Into' in the dropdown menu
31-
And the user selects a Digital Object Component from the dropdown menu
32-
Then the Digital Object Component moves as a child into the selected Digital Object Component
40+
And the user selects the first Digital Object Component from the dropdown menu
41+
Then the second Digital Object Component moves as a child into the first Digital Object Component
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# frozen_string_literal: true
2+
3+
Given 'a Digital Object with two Digital Object Components has been created' do
4+
visit "#{STAFF_URL}/digital_objects/new"
5+
6+
fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}"
7+
fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
8+
9+
click_on 'Add Date'
10+
select 'Single', from: 'digital_object_dates__0__date_type_'
11+
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
12+
13+
click_on 'Save'
14+
15+
wait_for_ajax
16+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created"
17+
@digital_object_id = current_url.split('::digital_object_').pop
18+
19+
click_on 'Add Child'
20+
wait_for_ajax
21+
fill_in 'Label', with: "Digital Object Component A Label #{@uuid}"
22+
click_on 'Save'
23+
wait_for_ajax
24+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}"
25+
@digital_object_component_first_id = current_url.split('::digital_object_component_').pop
26+
27+
within '#tree-container' do
28+
click_on "Digital Object Title #{@uuid}"
29+
end
30+
31+
click_on 'Add Child'
32+
wait_for_ajax
33+
fill_in 'Label', with: "Digital Object Component B Label #{@uuid}"
34+
click_on 'Save'
35+
wait_for_ajax
36+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}"
37+
@digital_object_component_second_id = current_url.split('::digital_object_component_').pop
38+
end
39+
40+
Given 'a Digital Object with two nested Digital Object Components has been created' do
41+
visit "#{STAFF_URL}/digital_objects/new"
42+
43+
fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}"
44+
fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
45+
46+
click_on 'Add Date'
47+
select 'Single', from: 'digital_object_dates__0__date_type_'
48+
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
49+
50+
click_on 'Save'
51+
52+
wait_for_ajax
53+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created"
54+
@digital_object_id = current_url.split('::digital_object_').pop
55+
56+
click_on 'Add Child'
57+
wait_for_ajax
58+
fill_in 'Label', with: "Digital Object Component A Label #{@uuid}"
59+
click_on 'Save'
60+
wait_for_ajax
61+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}"
62+
@digital_object_component_first_id = current_url.split('::digital_object_component_').pop
63+
64+
click_on 'Add Child'
65+
wait_for_ajax
66+
fill_in 'Label', with: "Digital Object Component B Label #{@uuid}"
67+
click_on 'Save'
68+
wait_for_ajax
69+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created as child of on Digital Object Digital Object Title #{@uuid}"
70+
@digital_object_component_second_id = current_url.split('::digital_object_component_').pop
71+
end
72+
73+
When 'the user selects the second Digital Object Component' do
74+
click_on "Digital Object Component B Label #{@uuid}"
75+
76+
wait_for_ajax
77+
end
78+
79+
When 'the user selects the first Digital Object Component' do
80+
click_on "Digital Object Component A Label #{@uuid}"
81+
82+
wait_for_ajax
83+
end
84+
85+
Then 'the button has text {string}' do |text|
86+
expect(page).to have_text text
87+
end
88+
89+
Then 'the second Digital Object Component is pasted as a child of the Digital Object Component' do
90+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1"
91+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2"
92+
end
93+
94+
Then 'the second Digital Object Component moves a level up' do
95+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1"
96+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-1"
97+
end
98+
99+
Then 'the second Digital Object Component moves one position up' do
100+
wait_for_ajax
101+
102+
elements = all('.table-row.largetree-node.indent-level-1')
103+
104+
tries = 0
105+
while elements[0][:id] == ''
106+
break if tries == 3
107+
108+
sleep 3
109+
tries += 1
110+
elements = all('.table-row.largetree-node.indent-level-1')
111+
end
112+
113+
puts "\n\n\n\nelements[0][:id].inspect"
114+
puts elements[0][:id].inspect
115+
puts elements[1][:id].inspect
116+
117+
expect(elements[0][:id]).to eq "digital_object_component_#{@digital_object_component_second_id}"
118+
expect(elements[1][:id]).to eq "digital_object_component_#{@digital_object_component_first_id}"
119+
end
120+
121+
When 'the user selects the first Digital Object Component from the dropdown menu' do
122+
within '.dropdown-menu' do
123+
find('.rounded-0.dropdown-item.cursor-default.move-node.move-node-down-into', match: :first).hover
124+
end
125+
126+
element = find("[data-tree_id=\"digital_object_component_#{@digital_object_component_first_id}\"]")
127+
element.click
128+
end
129+
130+
Then 'the second Digital Object Component moves as a child into the first Digital Object Component' do
131+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1"
132+
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2"
133+
end

0 commit comments

Comments
 (0)