Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent edit #84

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions staff_features/agents/agent_edit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Agent Edit
Background:
Given an administrator user is logged in
And an Agent has been created
Scenario: Agent is opened in the edit mode from the browse menu
Given the Agent appears in the search results list
When the user clicks on 'Edit'
Then the Agent is opened in the edit mode
Scenario: Agent is opened in the edit mode from the view mode
Given the Agent is opened in the view mode
When the user clicks on 'Edit'
Then the Agent is opened in the edit mode
Scenario Outline: Agent is successfully updated
Given the Agent is opened in edit mode
When the user changes the '<Field>' field to '<NewValue>'
And the user clicks on 'Save'
Then the 'Agent' saved message is displayed
And the field '<Field>' has value '<NewValue>'
Examples:
| Field | NewValue |
| Prefix | Test |
Scenario: Agent is not updated after changes are reverted
Given the Agent is opened in edit mode
When the user fills in 'Primary Part of Name' with 'New Agent Name'
And the user clicks on 'Revert Changes'
Then the Primary Part of Name has the original value
51 changes: 51 additions & 0 deletions staff_features/agents/step_definitions/agent_edit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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: "Agent #{@uuid}"
select 'Local sources', from: 'Source'
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

Given 'the Agent appears in the search results list' do
visit "#{STAFF_URL}/agents"

fill_in 'filter-text', with: "Agent #{@uuid}"

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

search_result_rows = all('#tabledSearchResults tbody tr')
expect(search_result_rows.length).to eq 1
end

Then 'the Agent is opened in the edit mode' do
uri = current_url.split('/')

action = uri.pop
agent_id = uri.pop

expect(action).to eq 'edit'
expect(agent_id).to eq @agent_id
end

Given 'the Agent is opened in edit mode' do
visit "#{STAFF_URL}/agents/agent_person/#{@agent_id}/edit"
end

Given 'the Agent is opened in the view mode' do
visit "#{STAFF_URL}/agents/agent_person/#{@agent_id}"
end

Then 'the Primary Part of Name has the original value' do
visit "#{STAFF_URL}/agents/agent_person/#{@agent_id}/edit"

expect(page).to have_field('Primary Part of Name', with: "Agent #{@uuid}")
end
Loading