From f72683a9858c389e26697285358d32516d602987 Mon Sep 17 00:00:00 2001 From: Konstantina Dimopoulou <13031341+kdimopulu@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:27:32 +0200 Subject: [PATCH] Agent delete (#90) --- staff_features/agents/agent_delete.feature | 25 ++++++++++ .../agents/step_definitions/agent_delete.rb | 49 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 staff_features/agents/agent_delete.feature create mode 100644 staff_features/agents/step_definitions/agent_delete.rb diff --git a/staff_features/agents/agent_delete.feature b/staff_features/agents/agent_delete.feature new file mode 100644 index 00000000..82b49ab8 --- /dev/null +++ b/staff_features/agents/agent_delete.feature @@ -0,0 +1,25 @@ +Feature: Agent Delete + Background: + Given an administrator user is logged in + And an Agent has been created + Scenario: Agent is deleted from the search results + When the user clicks on 'Browse' + And the user clicks on 'Agents' + And the user filters by text with the Agent name + And the user checks the checkbox of the Agent + And the user clicks on 'Delete' + And the user clicks on 'Delete Records' + Then the 'Agents' deleted message is displayed + And the Agent is deleted + Scenario: Agent is deleted from the view page + Given the user is on the Agent view page + When the user clicks on 'Delete' + And the user clicks on 'Delete' in the modal + Then the Agents page is displayed + And the 'Agent' deleted message is displayed + And the Agent is deleted + Scenario: Cancel Agent delete from the view page + Given the user is on the Agent view page + When the user clicks on 'Delete' + And the user clicks on 'Cancel' + Then the user is still on the Agent view page diff --git a/staff_features/agents/step_definitions/agent_delete.rb b/staff_features/agents/step_definitions/agent_delete.rb new file mode 100644 index 00000000..35abc659 --- /dev/null +++ b/staff_features/agents/step_definitions/agent_delete.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +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 + +When 'the user checks the checkbox of the Agent' do + find('#multiselect-item').check +end + +Then 'the Agent is deleted' do + expect(@agent_id).to_not eq nil + + visit "#{STAFF_URL}/agents/agent_person/#{@agent_id}/edit" + + expect(find('h2').text).to eq 'Record Not Found' + + expected_text = "The record you've tried to access may no longer exist or you may not have permission to view it." + expect(page).to have_text expected_text +end + +Given 'the user is on the Agent view page' do + visit "#{STAFF_URL}/agents/agent_person/#{@agent_id}" +end + +Then 'the Agents page is displayed' do + expect(find('h2').text).to have_text 'Agents' +end + +Then 'the user is still on the Agent view page' do + expect(current_url).to include "agents/agent_person/#{@agent_id}" +end