Skip to content

Commit

Permalink
System tests for Payments payer response
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie committed Feb 3, 2025
1 parent 7a45903 commit b97b2d1
Show file tree
Hide file tree
Showing 15 changed files with 860 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def validate_claim_status(row, row_number)
end

def validate_claim_unpaid_reason(row, row_number)
return unless row["claim_status"].downcase == "unpaid" &&
return unless row["claim_status"].to_s.downcase == "unpaid" &&
row["claim_unpaid_reason"].blank?

invalid_claim_unpaid_reason_rows << row_number
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
claim_reference,claim_status,claim_unpaid_reason
11111111,paid,
22222222,clawback_complete,Some reason
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
claim_reference,claim_status,claim_unpaid_reason
11111111,paid,
22222222,unpaid,
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
when_i_click_on_upload_esfa_response
then_i_see_the_upload_csv_page

when_i_upload_a_file_not_containing_an_assured_status_for_each_mentor
when_i_upload_a_file_not_containing_an_invalid_claim_status
and_i_click_on_upload_csv_file
then_i_see_the_errors_page
and_i_see_the_csv_contained_claims_without_an_assured_status_for_each_mentor
and_i_see_the_csv_contained_claims_with_a_invalid_claim_status
end

private
Expand Down Expand Up @@ -111,7 +111,7 @@ def and_i_click_on_upload_csv_file
click_on "Upload CSV file"
end

def when_i_upload_a_file_not_containing_an_assured_status_for_each_mentor
def when_i_upload_a_file_not_containing_an_invalid_claim_status
attach_file "Upload CSV file",
"spec/fixtures/claims/clawback/esfa_responses/invalid_esfa_clawback_response_upload_with_invalid_claim_status.csv"
end
Expand All @@ -123,7 +123,7 @@ def then_i_see_the_errors_page
expect(page).to have_h1("Upload payer response")
end

def and_i_see_the_csv_contained_claims_without_an_assured_status_for_each_mentor
def and_i_see_the_csv_contained_claims_with_a_invalid_claim_status
expect(page).to have_h1("Upload payer response")
expect(page).to have_element(:div, text: "You need to fix 1 error related to specific rows", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Not a valid claim status paid", class: "govuk-table__cell", count: 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
when_i_click_on_upload_esfa_response
then_i_see_the_upload_csv_page

when_i_upload_a_file_not_containing_an_assured_status_for_each_mentor
when_i_upload_a_file_containing_a_reference_not_associated_with_an_existing_claim
and_i_click_on_upload_csv_file
then_i_see_the_errors_page
and_i_see_the_csv_contained_claims_with_an_invalid_reference
Expand Down Expand Up @@ -111,7 +111,7 @@ def and_i_click_on_upload_csv_file
click_on "Upload CSV file"
end

def when_i_upload_a_file_not_containing_an_assured_status_for_each_mentor
def when_i_upload_a_file_containing_a_reference_not_associated_with_an_existing_claim
attach_file "Upload CSV file",
"spec/fixtures/claims/clawback/esfa_responses/example_esfa_clawback_response_upload.csv"
end
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require "rails_helper"

RSpec.describe "Support user can not upload payer responses when there are no claims with the status 'payment_in_progress'",
service: :claims,
type: :system do
scenario do
given_i_am_signed_in

when_i_navigate_to_the_payments_claims_index_page
then_i_see_the_payments_claims_index_page
and_i_see_no_payment_claims_have_been_uploaded

when_i_click_on_upload_payer_response
then_i_see_there_are_no_claims_waiting_for_a_response
end

private

def given_i_am_signed_in
sign_in_claims_support_user
end

def when_i_navigate_to_the_payments_claims_index_page
within primary_navigation do
click_on "Claims"
end

within secondary_navigation do
click_on "Payments"
end
end

def then_i_see_the_payments_claims_index_page
expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK")
expect(page).to have_h1("Claims")
expect(primary_navigation).to have_current_item("Claims")
expect(secondary_navigation).to have_current_item("Payments")
expect(page).to have_current_path(claims_support_claims_payments_path, ignore_query: true)
end

def and_i_see_no_payment_claims_have_been_uploaded
expect(page).to have_h2("Payments")
expect(page).to have_element(:p, text: "There are no claims waiting to be processed.")
end

def when_i_click_on_upload_payer_response
click_on "Upload payer response"
end

def then_i_see_there_are_no_claims_waiting_for_a_response
expect(page).to have_title("You cannot upload a payer response - Payments - Claims - Claim funding for mentor training - GOV.UK")
expect(page).to have_h1("You cannot upload a payer response")
expect(page).to have_element(:span, text: "Payment")
expect(page).to have_element(
:p,
text: "You cannot upload a payer response as there are no claims waiting for a response.",
class: "govuk-body",
)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require "rails_helper"

RSpec.describe "Support user does not upload a file",
service: :claims,
type: :system do
scenario do
given_claims_exist
and_i_am_signed_in

when_i_navigate_to_the_payments_claims_index_page
then_i_see_the_payments_claims_index_page
and_i_see_no_payment_claims_have_been_uploaded

when_i_click_on_upload_payer_response
then_i_see_the_upload_csv_page

when_i_click_on_upload_csv_file
then_i_see_validation_error_regarding_invalid_data
end

private

def given_claims_exist
@claim = create(:claim,
:payment_in_progress,
reference: 11_111_111)
end

def and_i_am_signed_in
sign_in_claims_support_user
end

def when_i_navigate_to_the_payments_claims_index_page
within primary_navigation do
click_on "Claims"
end

within secondary_navigation do
click_on "Payments"
end
end

def then_i_see_the_payments_claims_index_page
expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK")
expect(page).to have_h1("Claims")
expect(primary_navigation).to have_current_item("Claims")
expect(secondary_navigation).to have_current_item("Payments")
expect(page).to have_current_path(claims_support_claims_payments_path, ignore_query: true)
end

def then_i_see_the_upload_csv_page
expect(page).to have_h1("Upload payer response")
have_element(:span, text: "Payments", class: "govuk-caption-l")
expect(page).to have_element(:label, text: "Upload CSV file")
end

def and_i_see_no_payment_claims_have_been_uploaded
expect(page).to have_h2("Payments")
expect(page).to have_element(:p, text: "There are no claims waiting to be processed.")
end

def when_i_click_on_upload_payer_response
click_on "Upload payer response"
end

def when_i_click_on_upload_csv_file
click_on "Upload CSV file"
end

def then_i_see_validation_error_regarding_invalid_data
expect(page).to have_validation_error("Select a CSV file to upload")
end
end
Loading

0 comments on commit b97b2d1

Please sign in to comment.