-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Digital Object Components Reorder (#72)
- Loading branch information
Showing
2 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
staff_features/digital_objects/digital_object_components_reorder.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Feature: Digital Object Component Reorder | ||
Background: | ||
Given an administrator user is logged in | ||
Scenario: Activate reorder mode | ||
Given a Digital Object with two Digital Object Components has been created | ||
And the Digital Object is opened in edit mode | ||
When the user clicks on 'Enable Reorder Mode' | ||
Then the button has text 'Disable Reorder Mode' | ||
Scenario: Cut and Paste a Digital Object Component | ||
Given a Digital Object with two Digital Object Components has been created | ||
And the Digital Object is opened in edit mode | ||
When the user clicks on 'Enable Reorder Mode' | ||
And the user selects the second Digital Object Component | ||
And the user clicks on 'Cut' | ||
And the user selects the first Digital Object Component | ||
And the user clicks on 'Paste' | ||
Then the second Digital Object Component is pasted as a child of the Digital Object Component | ||
Scenario: Move a Digital Object Component up a level | ||
Given a Digital Object with two nested Digital Object Components has been created | ||
When the user selects the second Digital Object Component | ||
When the user clicks on 'Enable Reorder Mode' | ||
And the user clicks on 'Move' | ||
And the user clicks on 'Up a Level' in the dropdown menu | ||
Then the second Digital Object Component moves a level up | ||
Scenario: Move a Digital Object Component up | ||
Given a Digital Object with two Digital Object Components has been created | ||
And the Digital Object is opened in edit mode | ||
When the user selects the second Digital Object Component | ||
And the user clicks on 'Enable Reorder Mode' | ||
And the user clicks on 'Move' | ||
And the user clicks on 'Up' in the dropdown menu | ||
Then the second Digital Object Component moves one position up | ||
Scenario: Move Down Into a Digital Object Component | ||
Given a Digital Object with two Digital Object Components has been created | ||
And the Digital Object is opened in edit mode | ||
When the user selects the second Digital Object Component | ||
And the user clicks on 'Enable Reorder Mode' | ||
And the user clicks on 'Move' | ||
And the user clicks on 'Down Into' in the dropdown menu | ||
And the user selects the first Digital Object Component from the dropdown menu | ||
Then the second Digital Object Component moves as a child into the first Digital Object Component |
133 changes: 133 additions & 0 deletions
133
staff_features/digital_objects/step_definitions/digital_object_component_reorder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# frozen_string_literal: true | ||
|
||
Given 'a Digital Object with two Digital Object Components 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 'Add Date' | ||
select 'Single', from: 'digital_object_dates__0__date_type_' | ||
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01' | ||
|
||
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 | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Label', with: "Digital Object Component A Label #{@uuid}" | ||
click_on 'Save' | ||
wait_for_ajax | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" | ||
@digital_object_component_first_id = current_url.split('::digital_object_component_').pop | ||
|
||
within '#tree-container' do | ||
click_on "Digital Object Title #{@uuid}" | ||
end | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Label', with: "Digital Object Component B Label #{@uuid}" | ||
click_on 'Save' | ||
wait_for_ajax | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" | ||
@digital_object_component_second_id = current_url.split('::digital_object_component_').pop | ||
end | ||
|
||
Given 'a Digital Object with two nested Digital Object Components 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 'Add Date' | ||
select 'Single', from: 'digital_object_dates__0__date_type_' | ||
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01' | ||
|
||
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 | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Label', with: "Digital Object Component A Label #{@uuid}" | ||
click_on 'Save' | ||
wait_for_ajax | ||
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" | ||
@digital_object_component_first_id = current_url.split('::digital_object_component_').pop | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Label', with: "Digital Object Component B Label #{@uuid}" | ||
click_on 'Save' | ||
wait_for_ajax | ||
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}" | ||
@digital_object_component_second_id = current_url.split('::digital_object_component_').pop | ||
end | ||
|
||
When 'the user selects the second Digital Object Component' do | ||
click_on "Digital Object Component B Label #{@uuid}" | ||
|
||
wait_for_ajax | ||
end | ||
|
||
When 'the user selects the first Digital Object Component' do | ||
click_on "Digital Object Component A Label #{@uuid}" | ||
|
||
wait_for_ajax | ||
end | ||
|
||
Then 'the button has text {string}' do |text| | ||
expect(page).to have_text text | ||
end | ||
|
||
Then 'the second Digital Object Component is pasted as a child of the Digital Object Component' do | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2" | ||
end | ||
|
||
Then 'the second Digital Object Component moves a level up' do | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-1" | ||
end | ||
|
||
Then 'the second Digital Object Component moves one position up' do | ||
wait_for_ajax | ||
|
||
elements = all('.table-row.largetree-node.indent-level-1') | ||
|
||
tries = 0 | ||
while elements[0][:id] == '' | ||
break if tries == 3 | ||
|
||
sleep 3 | ||
tries += 1 | ||
elements = all('.table-row.largetree-node.indent-level-1') | ||
end | ||
|
||
puts "\n\n\n\nelements[0][:id].inspect" | ||
puts elements[0][:id].inspect | ||
puts elements[1][:id].inspect | ||
|
||
expect(elements[0][:id]).to eq "digital_object_component_#{@digital_object_component_second_id}" | ||
expect(elements[1][:id]).to eq "digital_object_component_#{@digital_object_component_first_id}" | ||
end | ||
|
||
When 'the user selects the first Digital Object Component from the dropdown menu' do | ||
within '.dropdown-menu' do | ||
find('.rounded-0.dropdown-item.cursor-default.move-node.move-node-down-into', match: :first).hover | ||
end | ||
|
||
element = find("[data-tree_id=\"digital_object_component_#{@digital_object_component_first_id}\"]") | ||
element.click | ||
end | ||
|
||
Then 'the second Digital Object Component moves as a child into the first Digital Object Component' do | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_first_id}.indent-level-1" | ||
expect(page).to have_css "#digital_object_component_#{@digital_object_component_second_id}.indent-level-2" | ||
end |