Skip to content

Commit

Permalink
Agent view
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Feb 10, 2025
1 parent 7849531 commit c0ff8ad
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 7 deletions.
5 changes: 2 additions & 3 deletions staff_features/agents/agent_view.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Agent View
And the user filters by text with the Agent name
And the user clicks on 'View'
Then the Agent view page is displayed
Scenario: Sort Agents by title
Scenario: Sort Agents by name
Given two Agents have been created with a common keyword in their name
And the two Agents are displayed sorted by ascending name
When the user clicks on 'Name'
Expand All @@ -28,7 +28,7 @@ Feature: Agent View
Given two Agents have been created with a common keyword in their name
And the two Agents are displayed sorted by ascending name
When the user clicks on 'Authority ID'
Then the two Agents are displayed sorted by ascending authority ID
Then the two Agents are displayed sorted by ascending Authority ID
Scenario: Sort Agents by Source
Given two Agents have been created with a common keyword in their name
And the two Agents are displayed sorted by ascending name
Expand All @@ -53,4 +53,3 @@ Feature: Agent View
And the user hovers on 'Modified' in the dropdown menu
And the user clicks on 'Ascending' in the dropdown menu
Then the two Agents are displayed sorted by ascending modified date

15 changes: 15 additions & 0 deletions staff_features/agents/step_definitions/agent_shared.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

Given 'an Agent has been created' do
visit "#{STAFF_URL}/agents/agent_person/new"

fill_in 'Primary Part of Name', with: @uuid

click_on 'Save'

expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created'

url_parts = current_url.split('agents/agent_person').pop.split('/')
url_parts.pop
@agent_id = url_parts.pop
end
146 changes: 146 additions & 0 deletions staff_features/agents/step_definitions/agent_view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# frozen_string_literal: true

Given 'two Agents have been created with a common keyword in their name' do
@shared_agent_uuid = SecureRandom.uuid
@agent_a_uuid = SecureRandom.uuid
@agent_b_uuid = SecureRandom.uuid

visit "#{STAFF_URL}/agents/agent_person/new"
fill_in 'Primary Part of Name', with: "A #{@agent_a_uuid} #{@shared_agent_uuid}"
fill_in 'Authority ID', with: "A #{@agent_a_uuid} #{@shared_agent_uuid}"
select 'Local sources', from: 'Source'
select 'Anglo-American Cataloging Rules', from: 'Rules'
click_on 'Save'
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created'
url_parts = current_url.split('agents/agent_person').pop.split('/')
url_parts.pop
@agent_a_id = url_parts.pop

visit "#{STAFF_URL}/agents/agent_person/new"
fill_in 'Primary Part of Name', with: "B #{@agent_b_uuid} #{@shared_agent_uuid}"
fill_in 'Authority ID', with: "B #{@agent_b_uuid} #{@shared_agent_uuid}"
select 'NAD / ARK II Name Authority Database', from: 'Source'
select 'Describing Archives: A Content Standard', from: 'Rules'
click_on 'Save'
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created'
url_parts = current_url.split('agents/agent_person').pop.split('/')
url_parts.pop
@agent_b_id = url_parts.pop
end

Given 'the two Agents are displayed sorted by ascending name' do
visit "#{STAFF_URL}/agents"

fill_in 'filter-text', with: @shared_agent_uuid

within '.search-filter' do
find('button').click
end

search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by descending name' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[1]).to have_text @agent_a_uuid
expect(search_result_rows[0]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending type' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending level' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[1]).to have_text @agent_a_uuid
expect(search_result_rows[0]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending Authority ID' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending source' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending rule' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending created date' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'Sort Agents by modified date' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

Then 'the two Agents are displayed sorted by ascending modified date' do
search_result_rows = all('#tabledSearchResults tbody tr')

expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @agent_a_uuid
expect(search_result_rows[1]).to have_text @agent_b_uuid
end

When 'the user filters by text with the Agent name' do
fill_in 'Filter by text', with: @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

Then 'the Agent is in the search results' do
expect(page).to have_css('tr', text: @uuid)
end

Then 'the Agent view page is displayed' do
expect(find('h2').text).to eq "#{@uuid} Agent"
end
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
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')

Expand Down
4 changes: 4 additions & 0 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,7 @@
select '', from: label
end
end

Then 'the button has text {string}' do |text|
expect(page).to have_text text
end

0 comments on commit c0ff8ad

Please sign in to comment.