Skip to content

Commit

Permalink
Add specs for wizard and system specs for altered views
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-daly committed Jan 31, 2025
1 parent e5f1d36 commit 7eca88e
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 40 deletions.
2 changes: 1 addition & 1 deletion config/locales/en/claims/support/claims/samplings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ en:
success_heading: Claim updated
upload_data:
update:
heading: Sampling data uploaded
heading: Auditing data uploaded
body: It may take a moment for the uploaded claims to update
confirm_provider_rejected:
page_title: Are you sure you want to confirm the provider has rejected the claim? - Auditing - Claim %{reference}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
claim_reference,sample_reason
11111111,Valid paid claim
22222222,Invalid claim
88888888,Valid reason
11111111,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
claim_refrence,sampl_reason
11111111,Random audit
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,16 @@
when_i_click_on_upload_claims_to_be_sampled
then_i_see_the_upload_csv_page

# when_i_upload_a_csv_containing_invalid_headers
# and_i_click_on_upload_csv_file
# then_i_see_validation_errors_regarding_invalid_headers

# when_i_click_on_upload_again
# and_i_upload_a_csv_containing_invalid_sampling_data
# and_i_click_on_upload_csv_file
# then_i_see_validation_errors_regarding_invalid_data
when_i_upload_a_csv_containing_invalid_sampling_data
and_i_click_on_upload_csv_file
then_i_see_validation_errors_regarding_invalid_data
end

private

def given_claims_exist
@current_academic_year = AcademicYear.for_date(Time.current) || create(:academic_year, :current)

current_claim_window = create(:claim_window, academic_year: @current_academic_year,
starts_on: @current_academic_year.starts_on,
ends_on: @current_academic_year.starts_on + 2.days)
@current_claim = create(:claim,
:submitted,
claim_window: current_claim_window,
reference: 11_111_111)
@another_paid_claim = create(:claim,
:submitted,
status: :paid,
claim_window: current_claim_window)
@paid_claim_1 = create(:claim, :submitted, status: :paid, reference: 11_111_111)
@paid_claim_2 = create(:claim, :submitted, status: :paid, reference: 22_222_222)
end

def and_i_am_signed_in
Expand Down Expand Up @@ -74,20 +58,25 @@ def when_i_click_on_upload_claims_to_be_sampled
end

def when_i_upload_a_csv_containing_invalid_sampling_data
attach_file "Upload CSV file", "spec/fixtures/claims/sampling/invalid_example_sampling_upload.csv"
attach_file "Upload CSV file",
"spec/fixtures/claims/sampling/invalid_example_sampling_upload.csv"
end

def and_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("The selected CSV file contains invalid data")
end

def then_i_see_the_upload_csv_page
expect(page).to have_h1("Upload claims to be audited")
have_element(:span, text: "Auditing", class: "govuk-caption-l")
expect(page).to have_element(:label, text: "Upload CSV file")
end

def then_i_see_validation_errors_regarding_invalid_data
expect(page).to have_h1("Upload claims to be audited")
expect(page).to have_element(:div, text: "You need to fix 2 errors related to specific rows", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Not a valid claim reference", class: "govuk-table__cell")
expect(page).to have_element(:td, text: "Reason needed", class: "govuk-table__cell")
expect(page).to have_element(:p, text: "Only showing rows with errors", class: "govuk-!-text-align-centre")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require "rails_helper"

RSpec.describe "Support user uploads a CSV file with the wrong headers",
service: :claims,
type: :system do
scenario do
given_claims_exist
and_i_am_signed_in

when_i_navigate_to_the_sampling_claims_index_page
then_i_see_the_sampling_claims_index_page

when_i_click_on_upload_claims_to_be_audited
then_i_see_the_upload_csv_page

when_i_upload_a_csv_file_not_containing_invalid_headers
and_i_click_on_upload_csv_file
then_i_see_validation_error_regarding_invalid_headers
end

private

def given_claims_exist
@paid_claim_1 = create(:claim, :submitted, status: :paid, reference: 11_111_111)
end

def and_i_am_signed_in
sign_in_claims_support_user
end

def when_i_navigate_to_the_sampling_claims_index_page
within primary_navigation do
click_on "Claims"
end

within secondary_navigation do
click_on "Auditing"
end
end

def then_i_see_the_sampling_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("Auditing")
expect(page).to have_current_path(claims_support_claims_samplings_path, ignore_query: true)
end

def then_i_see_the_upload_csv_page
expect(page).to have_h1("Upload claims to be audited")
have_element(:span, text: "Auditing", class: "govuk-caption-l")
expect(page).to have_element(:label, text: "Upload CSV file")
end

def when_i_click_on_upload_claims_to_be_audited
click_on "Upload claims to be audited"
end

def and_i_click_on_upload_csv_file
click_on "Upload CSV file"
end

def when_i_upload_a_csv_file_not_containing_invalid_headers
attach_file "Upload CSV file",
"spec/fixtures/claims/sampling/invalid_headers_sampling_upload.csv"
end

def then_i_see_validation_error_regarding_invalid_headers
expect(page).to have_css(".govuk-error-summary__list", text: "Your file needs a column called ‘claim_reference’ and ‘sample_reason’")
expect(page).to have_css(".govuk-error-summary__list", text: "Right now it has columns called ‘claim_refrence’ and ‘sampl_reason’.")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ def and_i_click_on_upload_csv_file
end

def then_i_see_the_confirmation_page_for_uploading_the_sampling_data
expect(page).to have_h1("Are you sure you want to upload the auditing data?")
expect(page).to have_h1("Confirm you want to upload claims to be sampled")
have_element(:span, text: "Auditing", class: "govuk-caption-l")
expect(page).to have_element(:p, text: "There is 1 claim included in this upload.", class: "govuk-body")
expect(page).to have_element(
:strong,
text: "WarningEach accredited provider will receive an email instructing them to assure their partner schools' claim.",
class: "govuk-warning-text__text",
expect(page).to have_table_row(
"1" => "2",
"claim_reference" => "11111111",
"sample_reason" => "Some Reason",
)
end

Expand All @@ -137,7 +136,7 @@ def then_i_see_the_upload_csv_page
end

def when_i_click_upload_data
click_on "Upload data"
click_on "Confirm upload"
end

def then_i_see_the_upload_has_been_successful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def then_i_see_the_errors_page

def and_i_see_the_csv_contained_claims_not_with_the_status_sampling_in_progress
expect(page).to have_h1("Upload provider 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(:div, text: "You need to fix 1 error related to a specific row", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Not a valid mentor name Jane Doe", class: "govuk-table__cell")
expect(page).to have_element(:p, text: "Only showing rows with errors", class: "govuk-!-text-align-centre")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def then_i_see_the_errors_page

def and_i_see_the_csv_contained_claims_not_with_the_status_sampling_in_progress
expect(page).to have_h1("Upload provider 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(:div, text: "You need to fix 1 error related to a specific row", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Not a valid claim reference 22222222", class: "govuk-table__cell")
expect(page).to have_element(:p, text: "Only showing rows with errors", class: "govuk-!-text-align-centre")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def then_i_see_the_errors_page

def and_i_see_the_csv_contained_claims_without_a_rejection_reason
expect(page).to have_h1("Upload provider 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(:div, text: "You need to fix 1 error related to a specific row", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Reason needed", class: "govuk-table__cell")
expect(page).to have_element(:p, text: "Only showing rows with errors", class: "govuk-!-text-align-centre")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def then_i_see_the_errors_page

def and_i_see_the_csv_contained_claims_without_a_claim_accepted_input_for_each_mentor
expect(page).to have_h1("Upload provider 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(:div, text: "You need to fix 1 error related to a specific row", class: "govuk-error-summary")
expect(page).to have_element(:td, text: "Not a valid input", class: "govuk-table__cell")
expect(page).to have_element(:p, text: "Only showing rows with errors", class: "govuk-!-text-align-centre")
end
Expand Down

0 comments on commit 7eca88e

Please sign in to comment.