From ba45ff262d21edb062100f7c183d96e301734d82 Mon Sep 17 00:00:00 2001 From: Ben Abraham <16797406+Kizr@users.noreply.github.com> Date: Thu, 30 Jan 2025 11:11:49 +0000 Subject: [PATCH] Add specs for clawback activity --- .../_payment_and_clawback_activities.html.erb | 4 +- spec/factories/clawbacks.rb | 4 +- spec/fixtures/files/example-clawbacks.csv | 3 + ...lawback_request_delivered_activity_spec.rb | 103 ++++++++++++++++++ ..._views_clawback_requested_activity_spec.rb | 79 ++++++++++++++ ...lawback_response_uploaded_activity_spec.rb | 102 +++++++++++++++++ ...payment_request_delivered_activity_spec.rb | 103 ++++++++++++++++++ ...payment_response_uploaded_activity_spec.rb | 80 ++++++++++++++ ...iews_rejected_by_provider_activity_spec.rb | 79 ++++++++++++++ ..._views_rejected_by_school_activity_spec.rb | 79 ++++++++++++++ ...ampling_approved_manually_activity_spec.rb | 79 ++++++++++++++ ...r_views_sampling_response_activity_spec.rb | 92 ++++++++++++++++ ...r_views_sampling_uploaded_activity_spec.rb | 0 13 files changed, 805 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/files/example-clawbacks.csv create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_clawback_request_delivered_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_clawback_requested_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_clawback_response_uploaded_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_payment_request_delivered_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_payment_response_uploaded_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_provider_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_school_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_sampling_approved_manually_activity_spec.rb create mode 100644 spec/system/claims/support/claims/activity_logs/support_user_views_sampling_response_activity_spec.rb rename spec/system/claims/support/claims/{acitivity_logs => activity_logs}/support_user_views_sampling_uploaded_activity_spec.rb (100%) diff --git a/app/views/claims/support/claims/claim_activities/_payment_and_clawback_activities.html.erb b/app/views/claims/support/claims/claim_activities/_payment_and_clawback_activities.html.erb index 05c2d5b99..b20477e0a 100644 --- a/app/views/claims/support/claims/claim_activities/_payment_and_clawback_activities.html.erb +++ b/app/views/claims/support/claims/claim_activities/_payment_and_clawback_activities.html.erb @@ -2,7 +2,9 @@
<%= govuk_button_link_to t(".download_csv"), claim_activity.record.csv_file, secondary: true %> - <%= govuk_button_link_to t(".resend_email_to_payer"), claim_activity.record.csv_file, secondary: true %> + <% unless claim_activity.action == "clawback_response_uploaded" %> + <%= govuk_button_link_to t(".resend_email_to_payer"), resend_email_claims_support_claims_claim_activity_path(claim_activity), secondary: true %> + <% end %>

<%= t(".providers") %>

diff --git a/spec/factories/clawbacks.rb b/spec/factories/clawbacks.rb index 49fcd574c..d3c37e542 100644 --- a/spec/factories/clawbacks.rb +++ b/spec/factories/clawbacks.rb @@ -8,6 +8,8 @@ # updated_at :datetime not null # FactoryBot.define do - factory :clawback do + factory :clawback, class: Claims::Clawback do + claims { build_list(:claim, 3, :clawback_in_progress) } + csv_file { file_fixture("example-clawbacks.csv") } end end diff --git a/spec/fixtures/files/example-clawbacks.csv b/spec/fixtures/files/example-clawbacks.csv new file mode 100644 index 000000000..afa6939b4 --- /dev/null +++ b/spec/fixtures/files/example-clawbacks.csv @@ -0,0 +1,3 @@ +claim_reference,school_urn,school_name,claim_status +12345678,1234567,Example School,clawback_requested +23456789,2345678,Example School 2,clawback_requested diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_request_delivered_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_request_delivered_activity_spec.rb new file mode 100644 index 000000000..bb91b9a98 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_request_delivered_activity_spec.rb @@ -0,0 +1,103 @@ +require "rails_helper" + +RSpec.describe "Support user views clawback request delivered activity spec", service: :claims, type: :system do + scenario do + given_clawback_request_delivered_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + + when_i_click_on_download_csv + then_i_receive_a_csv_file + end + + def given_clawback_request_delivered_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @niot = build(:claims_provider, name: "National Institute of Technology") + @niot_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "87654321", provider: @niot) + + @clawback = build(:clawback, claims: [@best_practice_network_claim, @niot_claim]) + @activity_log = create(:claim_activity, :clawback_request_delivered, user: @colin, record: @clawback) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (2) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (2)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Claims sent to payer for clawback") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Claims sent to payer for clawback - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims sent to payer for clawback") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_link("Resend email to payer", href: resend_email_claims_support_claims_claim_activity_path(@activity_log)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + + expect(page).to have_h3("National Institute of Technology") + expect(page).to have_table_row({ + "Claim reference" => "87654321", + "Number of mentors" => "0", + "Claim amount" => "£#{@niot_claim.amount}", + }) + end + + def when_i_click_on_download_csv + click_on "Download CSV" + end + + def then_i_receive_a_csv_file + expect(page.response_headers["Content-Type"]).to eq("text/csv") + expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"example-clawbacks.csv\"; filename*=UTF-8''example-clawbacks.csv") + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_requested_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_requested_activity_spec.rb new file mode 100644 index 000000000..a39c37286 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_requested_activity_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe "Support user views clawback requested activity spec", service: :claims, type: :system do + scenario do + given_clawback_requested_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + end + + def given_clawback_requested_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @activity_log = create(:claim_activity, :clawback_requested, user: @colin, record: @best_practice_network_claim) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (1) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (1)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Clawback requested") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Clawback requested - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Clawback requested") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_response_uploaded_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_response_uploaded_activity_spec.rb new file mode 100644 index 000000000..e2e196527 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_clawback_response_uploaded_activity_spec.rb @@ -0,0 +1,102 @@ +require "rails_helper" + +RSpec.describe "Support user views clawback response uploaded activity spec", service: :claims, type: :system do + scenario do + given_clawback_response_uploaded_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + + when_i_click_on_download_csv + then_i_receive_a_csv_file + end + + def given_clawback_response_uploaded_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @niot = build(:claims_provider, name: "National Institute of Technology") + @niot_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "87654321", provider: @niot) + + @clawback = build(:clawback, claims: [@best_practice_network_claim, @niot_claim]) + @activity_log = create(:claim_activity, :clawback_response_uploaded, user: @colin, record: @clawback) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (2) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (2)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Payer clawback response uploaded") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Payer clawback response uploaded - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Payer clawback response uploaded") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + + expect(page).to have_h3("National Institute of Technology") + expect(page).to have_table_row({ + "Claim reference" => "87654321", + "Number of mentors" => "0", + "Claim amount" => "£#{@niot_claim.amount}", + }) + end + + def when_i_click_on_download_csv + click_on "Download CSV" + end + + def then_i_receive_a_csv_file + expect(page.response_headers["Content-Type"]).to eq("text/csv") + expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"example-clawbacks.csv\"; filename*=UTF-8''example-clawbacks.csv") + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_payment_request_delivered_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_payment_request_delivered_activity_spec.rb new file mode 100644 index 000000000..efe097a7f --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_payment_request_delivered_activity_spec.rb @@ -0,0 +1,103 @@ +require "rails_helper" + +RSpec.describe "Support user views payment request delivered activity spec", service: :claims, type: :system do + scenario do + given_payment_request_delivered_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + + when_i_click_on_download_csv + then_i_receive_a_csv_file + end + + def given_payment_request_delivered_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @niot = build(:claims_provider, name: "National Institute of Technology") + @niot_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "87654321", provider: @niot) + + @payment = build(:claims_payment, claims: [@best_practice_network_claim, @niot_claim]) + @activity_log = create(:claim_activity, :payment_request_delivered, user: @colin, record: @payment) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (2) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (2)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Claims sent to payer for payment") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Claims sent to payer for payment - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims sent to payer for payment") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_link("Resend email to payer", href: resend_email_claims_support_claims_claim_activity_path(@activity_log)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + + expect(page).to have_h3("National Institute of Technology") + expect(page).to have_table_row({ + "Claim reference" => "87654321", + "Number of mentors" => "0", + "Claim amount" => "£#{@niot_claim.amount}", + }) + end + + def when_i_click_on_download_csv + click_on "Download CSV" + end + + def then_i_receive_a_csv_file + expect(page.response_headers["Content-Type"]).to eq("text/csv") + expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"example-payments.csv\"; filename*=UTF-8''example-payments.csv") + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_payment_response_uploaded_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_payment_response_uploaded_activity_spec.rb new file mode 100644 index 000000000..8f798ab4a --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_payment_response_uploaded_activity_spec.rb @@ -0,0 +1,80 @@ +require "rails_helper" + +RSpec.describe "Support user views payment response uploaded activity spec", service: :claims, type: :system do + scenario do + given_payment_response_uploaded_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + + when_i_click_on_download_csv + then_i_receive_a_csv_file + end + + def given_payment_response_uploaded_activity_exists + @colin = build(:claims_support_user, :colin) + @payment_response = build(:claims_payment_response) + @activity_log = create(:claim_activity, :payment_response_uploaded, user: @colin, record: @payment_response) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (0) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (0)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Payer payment response uploaded") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Payer payment response uploaded - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Payer payment response uploaded") + end + + def when_i_click_on_download_csv + click_on "Download CSV" + end + + def then_i_receive_a_csv_file + expect(page.response_headers["Content-Type"]).to eq("text/csv") + expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"example-payments-response.csv\"; filename*=UTF-8''example-payments-response.csv") + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_provider_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_provider_activity_spec.rb new file mode 100644 index 000000000..5135db3ae --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_provider_activity_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe "Support user views rejected by provider activity spec", service: :claims, type: :system do + scenario do + given_rejected_by_provider_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + end + + def given_rejected_by_provider_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @activity_log = create(:claim_activity, :rejected_by_provider, user: @colin, record: @best_practice_network_claim) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (1) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (1)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Rejected by provider") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Rejected by provider - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Rejected by provider") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_school_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_school_activity_spec.rb new file mode 100644 index 000000000..6f7610509 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_rejected_by_school_activity_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe "Support user views rejected by school activity spec", service: :claims, type: :system do + scenario do + given_rejected_by_school_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + end + + def given_rejected_by_school_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @activity_log = create(:claim_activity, :rejected_by_school, user: @colin, record: @best_practice_network_claim) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (1) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (1)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Rejected by school") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Rejected by school - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Rejected by school") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_approved_manually_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_approved_manually_activity_spec.rb new file mode 100644 index 000000000..217a18b37 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_approved_manually_activity_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe "Support user views sampling approved manually activity spec", service: :claims, type: :system do + scenario do + given_sampling_approved_manually_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + end + + def given_sampling_approved_manually_activity_exists + @colin = build(:claims_support_user, :colin) + + @best_practice_network = build(:claims_provider, name: "Best Practice Network") + @best_practice_network_claim = build(:claim, :payment_in_progress, submitted_at: 1.day.ago, reference: "12345678", provider: @best_practice_network) + + @activity_log = create(:claim_activity, :sampling_approved_manually, user: @colin, record: @best_practice_network_claim) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (1) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (1)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Sampling approved manually") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Sampling approved manually - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Sampling approved manually") + expect(page).to have_link("12345678", href: claims_support_claim_path(@best_practice_network_claim)) + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@best_practice_network_claim.amount}", + }) + end +end diff --git a/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_response_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_response_activity_spec.rb new file mode 100644 index 000000000..7d372a875 --- /dev/null +++ b/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_response_activity_spec.rb @@ -0,0 +1,92 @@ +require "rails_helper" + +RSpec.describe "Support user views sampling response uploaded activity spec", service: :claims, type: :system do + scenario do + given_sampling_response_uploaded_activity_exists + and_i_am_signed_in + then_i_see_the_organisations_page + + when_i_click_on_claims + then_i_see_the_claims_page + + when_i_click_on_activity_log + then_i_see_the_activity_log_page + + when_i_click_on_view_details + then_i_see_the_activity_details + + when_i_click_on_download_csv + then_i_receive_a_csv_file + end + + def given_sampling_response_uploaded_activity_exists + @colin = build(:claims_support_user, :colin) + @provider = build(:claims_provider, name: "Best Practice Network") + @claim = build(:claim, :audit_requested, submitted_at: 1.day.ago, reference: "12345678", provider: @provider) + @provider_sampling = build(:provider_sampling, provider: @provider, claims: [@claim]) + @sampling = build(:claims_sampling, provider_samplings: [@provider_sampling]) + @activity_log = create(:claim_activity, :sampling_response_uploaded, user: @colin, record: @sampling) + end + + def and_i_am_signed_in + sign_in_claims_support_user + end + + def then_i_see_the_organisations_page + expect(page).to have_title("Organisations (1) - Claim funding for mentor training - GOV.UK") + expect(page).to have_h1("Organisations (1)") + end + + def when_i_click_on_claims + click_on("Claims") + end + + def then_i_see_the_claims_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("All claims") + end + + def when_i_click_on_activity_log + click_on("Activity log") + end + + def then_i_see_the_activity_log_page + expect(page).to have_title("Claims - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Claims") + expect(secondary_navigation).to have_current_item("Activity log") + expect(page).to have_h2("Activity log") + expect(page).to have_element("h3", class: "app-timeline__title", text: "Provider audit response uploaded") + expect(page).to have_link("View details", href: claims_support_claims_claim_activity_path(@activity_log)) + end + + def when_i_click_on_view_details + click_on("View details") + end + + def then_i_see_the_activity_details + expect(page).to have_title("Provider audit response uploaded - Claim funding for mentor training - GOV.UK") + expect(primary_navigation).to have_current_item("Claims") + expect(page).to have_h1("Provider audit response uploaded") + expect(page).to have_h2("Providers") + expect(page).to have_h3("Best Practice Network") + expect(page).to have_table_row({ + "Claim reference" => "12345678", + "Number of mentors" => "0", + "Claim amount" => "£#{@claim.amount}", + }) + expect(page).to have_link("12345678", href: claims_support_claim_path(@claim)) + expect(page).to have_link("Resend email to provider", href: resend_email_claims_support_claims_claim_activity_path(@activity_log, provider_id: @provider.id)) + end + + def when_i_click_on_download_csv + click_on "Download CSV" + end + + def then_i_receive_a_csv_file + expect(page.response_headers["Content-Type"]).to eq("text/csv") + expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"example-sampling-response.csv\"; filename*=UTF-8''example-sampling-response.csv") + end +end diff --git a/spec/system/claims/support/claims/acitivity_logs/support_user_views_sampling_uploaded_activity_spec.rb b/spec/system/claims/support/claims/activity_logs/support_user_views_sampling_uploaded_activity_spec.rb similarity index 100% rename from spec/system/claims/support/claims/acitivity_logs/support_user_views_sampling_uploaded_activity_spec.rb rename to spec/system/claims/support/claims/activity_logs/support_user_views_sampling_uploaded_activity_spec.rb