From 7709ca98ceebe53789e0babedc8ebb1d063f2d3d Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Sat, 1 Feb 2025 14:13:52 +0200 Subject: [PATCH] Agent create --- staff_features/agents/agent_create.feature | 95 +++++++++---------- .../agents/step_definitions/agent_create.rb | 17 ++++ staff_features/shared/step_definitions.rb | 20 +++- 3 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 staff_features/agents/step_definitions/agent_create.rb diff --git a/staff_features/agents/agent_create.feature b/staff_features/agents/agent_create.feature index 041d956..39ea610 100644 --- a/staff_features/agents/agent_create.feature +++ b/staff_features/agents/agent_create.feature @@ -1,50 +1,49 @@ Feature: Agent Create Background: - Given an administrator user is logged in - And the user is on Agents page - And the user clicks on 'Create Agent' - Scenario: Agent type Person is created - When the user clicks on 'Person' in the dropdown menu - And the user fills in 'Primary Part of Name' with 'Person Agent' in the 'Name Forms' form - And the user clicks on 'Save' - Then the 'Agent' created message is displayed - And the user is on the agent_person edit page - Scenario: Agent type Person is not created because required fields are missing - When the user clicks on 'Person' in the dropdown menu - And the user clicks on 'Save' - Then the following error messages are displayed - | Primary Part of Name - Property is required but was missing | - Scenario: Agent type Family is created - When the user clicks on 'Family' in the dropdown menu - And the user fills in 'Family Name' with 'Family Agent' in the 'Name Forms' form - And the user clicks on 'Save' - Then the 'Agent' created message is displayed - And the user is on the agent_family edit page - Scenario: Agent type Family is not created because required fields are missing - When the user clicks on 'Family' in the dropdown menu - And the user clicks on 'Save' - Then the following error messages are displayed - | Family Name - Property is required but was missing | - Scenario: Agent type Corporate Entity is created - When the user clicks on 'Corporate Entity' in the dropdown menu - And the user fills in 'Primary Part of Name' with 'Corporate Agent' in the 'Name Forms' form - And the user clicks on 'Save' - Then the 'Agent' created message is displayed - And the user is on the agent_corporate_entity edit page - Scenario: Agent type Corporate Entity is not created because required fields are missing - When the user clicks on 'Corporate Entity' in the dropdown menu - And the user clicks on 'Save' - Then the following error messages are displayed - | Primary Part of Name - Property is required but was missing | - Scenario: Agent type Software is created - When the user clicks on 'Software' in the dropdown menu - And the user fills in 'Software Name' with 'Software Agent' in the 'Name Forms' form - And the user clicks on 'Save' - Then the 'Agent' created message is displayed - And the user is on the agent_software edit page - Scenario: Agent type Software is not created because required fields are missing - When the user clicks on 'Software' in the dropdown menu - And the user clicks on 'Save' - Then the following error messages are displayed - | Software Name - Property is required but was missing | - \ No newline at end of file + Given an administrator user is logged in + And the user clicks on 'Create' + And the user hovers on 'Agent' in the dropdown menu + Scenario: Agent Person is created + When the user clicks on 'Person' + And the user fills in 'Primary Part of Name' in the 'Name Forms' form + And the user clicks on 'Save' + Then the 'Agent' created message is displayed + And the 'Primary Part of Name' has a unique value + Scenario: Agent Person is not created because required fields are missing + When the user clicks on 'Person' + And the user clicks on 'Save' + Then the following error messages are displayed + | Primary Part of Name - Property is required but was missing | + Scenario: Agent Family is created + When the user clicks on 'Family' + And the user fills in 'Family Name' in the 'Name Forms' form + And the user clicks on 'Save' + Then the 'Agent' created message is displayed + And the 'Family Name' has a unique value + Scenario: Agent Family is not created because required fields are missing + When the user clicks on 'Family' + And the user clicks on 'Save' + Then the following error messages are displayed + | Family Name - Property is required but was missing | + Scenario: Agent Corporate Entity is created + When the user clicks on 'Corporate Entity' + And the user fills in 'Primary Part of Name' in the 'Name Forms' form + And the user clicks on 'Save' + Then the 'Agent' created message is displayed + And the 'Primary Part of Name' has a unique value + Scenario: Agent Corporate Entity is not created because required fields are missing + When the user clicks on 'Corporate Entity' + And the user clicks on 'Save' + Then the following error messages are displayed + | Primary Part of Name - Property is required but was missing | + Scenario: Agent Software is created + When the user clicks on 'Software' + And the user fills in 'Software Name' in the 'Name Forms' form + And the user clicks on 'Save' + Then the 'Agent' created message is displayed + And the 'Software Name' has a unique value + Scenario: Agent Software is not created because required fields are missing + When the user clicks on 'Software' + And the user clicks on 'Save' + Then the following error messages are displayed + | Software Name - Property is required but was missing | diff --git a/staff_features/agents/step_definitions/agent_create.rb b/staff_features/agents/step_definitions/agent_create.rb new file mode 100644 index 0000000..a721ce0 --- /dev/null +++ b/staff_features/agents/step_definitions/agent_create.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +Then 'the Agent form has the following values' do |form_values_table| + form_values = form_values_table.hashes + + form_values.each do |row| + section_title = find('h3', text: row['form_section']) + section = section_title.ancestor('section', match: :first) + expect(section[:id]).to_not eq nil + + within section do + field = find_field(row['form_field']) + + expect(field.value.downcase).to eq row['form_value'].downcase + end + end +end diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index 87cf803..76d3023 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -61,6 +61,14 @@ end end +When 'the user hovers on {string} in the dropdown menu' do |string| + within '.dropdown-menu' do + element = find(:xpath, "//button[contains(text(), '#{string}')] | //a[contains(text(), '#{string}')]") + + element.hover + end +end + When 'the user clicks on {string} in the transfer form' do |string| dropdown_menu = find('.transfer-form') @@ -161,7 +169,7 @@ When 'the user fills in {string} with {string} in the {string} form' do |label, value, form_title| section_title = find('h3', text: form_title) - section = section_title.ancestor('section') + section = section_title.ancestor('section', match: :first) expect(section[:id]).to_not eq nil within section do @@ -169,6 +177,16 @@ end end +When 'the user fills in {string} in the {string} form' do |label, form_title| + section_title = find('h3', text: form_title) + section = section_title.ancestor('section', match: :first) + expect(section[:id]).to_not eq nil + + within section do + fill_in label, with: @uuid + end +end + When 'the user fills in {string} with {string} and selects {string} in the {string} form' do |label, value, selected_value, form_title| section_title = find('h3', text: form_title) section = section_title.ancestor('section')