-
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.
- Loading branch information
1 parent
1fe67ab
commit 7968a72
Showing
2 changed files
with
148 additions
and
20 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
Feature: Navigating a Resource Record Tree | ||
Feature: Resource Tree navigate | ||
Background: | ||
Given an administrator user is logged in | ||
And a Resource has been created | ||
And 2 Archival Objects attached to the Resource record have been created | ||
Scenario: Viewing the Resource Record tree | ||
And a Resource with two Archival Objects has been created | ||
Scenario: View the Resource Record tree | ||
When the Resource is opened in edit mode | ||
Then the Resource Record is displayed as the top level of the navigation tree | ||
And the tree includes the 2 attached Archival Object Records | ||
And the current record is highlighted in the tree | ||
Scenario: Expanding all levels of the tree | ||
Given the Resource Record tree is displayed | ||
Then the Resource is displayed as the top level of the navigation tree | ||
And the Resource is highlighted in the tree | ||
And only the top-level Archival Objects are displayed | ||
Scenario: Expand all levels of the tree | ||
Given the Resource is opened in edit mode | ||
And only the first-level Archival Objects are displayed | ||
When the user clicks on 'Auto-Expand All' | ||
Then all files of Archival Objects are displayed | ||
And the button has the label 'Disable Auto-Expand' | ||
And the expand arrow is disabled | ||
Scenario: Disabling auto-expand | ||
Given all levels of hierarchy in the tree are expanded | ||
Then all Archival Objects are displayed | ||
And the button has text 'Disable Auto-Expand' | ||
And the expand arrows are disabled | ||
Scenario: Disable auto-expand | ||
Given the Resource is opened in edit mode | ||
And all levels of hierarchy in the tree are expanded | ||
When the user clicks on 'Disable Auto-Expand' | ||
Then the button has the label 'Auto-Expand All' | ||
And the expand arrow is enabled | ||
And all sections remain expanded until manually collapsed | ||
Scenario: Collapsing all levels of the tree | ||
Given the Resource Record tree is displayed | ||
Then the button has text 'Auto-Expand All' | ||
And the expand arrows are enabled | ||
Scenario: Collapse all levels of the tree | ||
Given the Resource is opened in edit mode | ||
And all levels of hierarchy in the tree are expanded | ||
When the user clicks on 'Collapse Tree' | ||
Then the Resource Record and its top-level Archival Object Records are displayed | ||
Then only the top-level Archival Objects are displayed |
127 changes: 127 additions & 0 deletions
127
staff_features/resources/step_definitions/resource_tree_navigate.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,127 @@ | ||
# frozen_string_literal: true | ||
|
||
Given 'a Resource with two Archival Objects has been created' do | ||
visit "#{STAFF_URL}/resources/new" | ||
|
||
fill_in 'resource_title_', with: "Resource #{@uuid}" | ||
fill_in 'resource_id_0_', with: "Resource #{@uuid}" | ||
select 'Class', from: 'resource_level_' | ||
element = find('#resource_lang_materials__0__language_and_script__language_') | ||
element.send_keys('AU') | ||
element.send_keys(:tab) | ||
|
||
select 'Single', from: 'resource_dates__0__date_type_' | ||
fill_in 'resource_dates__0__begin_', with: '2024' | ||
|
||
fill_in 'resource_extents__0__number_', with: '10' | ||
select 'Cassettes', from: 'resource_extents__0__extent_type_' | ||
|
||
element = find('#resource_finding_aid_language_') | ||
element.send_keys('ENG') | ||
element.send_keys(:tab) | ||
|
||
element = find('#resource_finding_aid_script_') | ||
element.send_keys('Latin') | ||
element.send_keys(:tab) | ||
|
||
find('button', text: 'Save Resource', match: :first).click | ||
|
||
wait_for_ajax | ||
expect(page).to have_text "Resource Resource #{@uuid} created" | ||
|
||
url_parts = current_url.split('/') | ||
url_parts.pop | ||
@resource_id = url_parts.pop | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Title', with: "Archival Object 1 #{@uuid}" | ||
select 'Class', from: 'Level of Description' | ||
click_on 'Save' | ||
wait_for_ajax | ||
expect(page).to have_text "Archival Object Archival Object 1 #{@uuid} on Resource Resource #{@uuid} created" | ||
|
||
click_on 'Add Child' | ||
wait_for_ajax | ||
fill_in 'Title', with: "Archival Object 2 #{@uuid}" | ||
select 'Class', from: 'Level of Description' | ||
click_on 'Save' | ||
wait_for_ajax | ||
expect(page).to have_text "Archival Object Archival Object 2 #{@uuid} created as child of Archival Object 1 #{@uuid} on Resource Resource #{@uuid}" | ||
end | ||
|
||
Then 'the Resource is displayed as the top level of the navigation tree' do | ||
rows = all('#tree-container .table .table-row', visible: :all) | ||
|
||
expect(rows.length).to eq 4 | ||
expect(rows[0].text).to include "Resource #{@uuid}" | ||
end | ||
|
||
Then 'the Resource is highlighted in the tree' do | ||
rows = all('#tree-container .table .table-row') | ||
|
||
expect(rows.length).to eq 2 | ||
expect(rows[0].text).to include "Resource #{@uuid}" | ||
expect(rows[0][:class]).to include 'current' | ||
end | ||
|
||
Given 'only the first-level Archival Objects are displayed' do | ||
rows = all('#tree-container .table .table-row') | ||
|
||
expect(rows.length).to eq 2 | ||
expect(rows[1].text).to include "Archival Object 1 #{@uuid}" | ||
end | ||
|
||
Then 'the button has text {string}' do |button_text| | ||
expect(page).to have_text button_text | ||
end | ||
|
||
Then 'the expand arrows are disabled' do | ||
arrows = all('.expandme') | ||
|
||
expect(arrows.length).to eq 1 | ||
|
||
expect(arrows[0][:class]).to include 'disabled' | ||
arrows[0].click | ||
expect(page).to have_text "Archival Object 2 #{@uuid}" | ||
end | ||
|
||
Then 'all Archival Objects are displayed' do | ||
wait_for_ajax | ||
|
||
rows = all('#tree-container .table .table-row') | ||
|
||
expect(rows.length).to eq 3 | ||
expect(rows[1].text).to include "Archival Object 1 #{@uuid}" | ||
expect(rows[2].text).to include "Archival Object 2 #{@uuid}" | ||
end | ||
|
||
Then 'only the top-level Archival Objects are displayed' do | ||
rows = all('#tree-container .table .table-row') | ||
|
||
tries = 0 | ||
loop do | ||
break if rows.length == 2 || tries == 3 | ||
|
||
sleep 1 | ||
tries += 1 | ||
rows = all('#tree-container .table .table-row') | ||
end | ||
|
||
expect(rows.length).to eq 2 | ||
expect(rows[1].text).to include "Archival Object 1 #{@uuid}" | ||
end | ||
|
||
Given 'all levels of hierarchy in the tree are expanded' do | ||
click_on 'Auto-Expand All' | ||
|
||
wait_for_ajax | ||
end | ||
|
||
Then 'the expand arrows are enabled' do | ||
arrows = all('.expandme') | ||
|
||
arrows.each do |arrow| | ||
expect(arrow[:class]).to_not include 'disabled' | ||
end | ||
end |