From 9d0ec6fcc6623406080db4be872d0502024792b1 Mon Sep 17 00:00:00 2001 From: Joel Sugarman Date: Tue, 14 Jan 2025 11:55:43 +0000 Subject: [PATCH] AP-4439: Add feature test to excecise bank transaction removal --- .../with_bank_transactions.feature | 57 +++++++++++++++++++ features/step_definitions/generic_steps.rb | 6 ++ features/support/steps_helper.rb | 4 ++ 3 files changed, 67 insertions(+) diff --git a/features/providers/non_passported_journey/with_bank_transactions.feature b/features/providers/non_passported_journey/with_bank_transactions.feature index 90be1249c2..e8c5671067 100644 --- a/features/providers/non_passported_journey/with_bank_transactions.feature +++ b/features/providers/non_passported_journey/with_bank_transactions.feature @@ -217,3 +217,60 @@ Feature: non_passported_journey with bank transactions | h3 | Payments the partner makes in cash | | h3 | Housing Benefit | | h2 | Dependants | + + @javascript + Scenario: Selects and then removes income and outgoings bank transactions + Given I start the means application with bank transactions with no transaction type category + Then I should be on the 'client_completed_means' page showing 'Your client has shared their financial information' + Then I click 'Continue' + + Then I should be on the 'identify_types_of_income' page showing "Which of these payments does your client get?" + And I select 'Benefits' + And I click 'Save and continue' + + Then I should be on a page with title "Select payments your client receives in cash" + When I select 'My client receives none of these payments in cash' + And I click 'Save and continue' + + Then I should be on a page showing "Does your client get student finance?" + When I choose "No" + And I click 'Save and continue' + + Then I should be on the 'identify_types_of_outgoing' page showing "Which of these payments does your client pay?" + Then I select 'Housing' + And I click 'Save and continue' + + Then I should be on a page with title "Select payments your client pays in cash" + And I should see 'Housing' + When I select 'None of the above' + And I click 'Save and continue' + + Then I should be on the 'income_summary' page showing "Sort your client's income into categories" + And the following sections should exist: + | tag | section | + | h2 | 1. Benefits, charitable or government payments | + + Then I click the first link 'View statements and add transactions' + Then I select the first checkbox + + When I click 'Save and continue' + Then I should be on the 'income_summary' page showing "Sort your client's income into categories" + + When I click the first link or button 'Remove' + Then I should see govuk-notification-banner "You removed transaction \d{1,2} [A-Z]\w{2} \d{4} .* from the list" + + When I click the first link 'View statements and add transactions' + Then I select the first checkbox + And I click 'Save and continue' + + Then I should be on the 'income_summary' page showing "Sort your client's income into categories" + And I click 'Save and continue' + + When I click 'Save and continue' + Then I should be on the 'outgoings_summary' page showing "Sort your client's regular payments into categories" + Then I click the first link 'View statements and add transactions' + Then I select the first checkbox + And I click 'Save and continue' + + When I click the first link or button 'Remove' + Then I should see govuk-notification-banner "You removed transaction \d{1,2} [A-Z]\w{2} \d{4} .* from the list" diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index 8b549e825a..7cacf22665 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -24,6 +24,12 @@ expect(page).to have_css(".govuk-tag", text:) end +Then("I should see govuk-notification-banner {string}") do |text| + expect(page) + .to have_css(".govuk-notification-banner", text: /#{text}/), + "expected to find govuk-notification-banner with text matching: \"#{text}\"" +end + And(/^I should (see|not see) a ['|"](.*?)['|"] button$/) do |visibility, text| if visibility == "see" expect(page).to have_button(text:) diff --git a/features/support/steps_helper.rb b/features/support/steps_helper.rb index 7cafdd6a97..26bc2fd212 100644 --- a/features/support/steps_helper.rb +++ b/features/support/steps_helper.rb @@ -60,6 +60,10 @@ first(:link, link_name).click end +Then("I click the first link or button {string}") do |name| + click_on(name, match: :first) +end + Then("I click the {string} link {string}") do |nth, link_name| all(:link, link_name)[nth.to_i - 1].click end