From c0a16bfd5be7191d869164c1c45685f718ed05d2 Mon Sep 17 00:00:00 2001 From: Dave G Date: Mon, 2 Dec 2024 15:25:47 +0000 Subject: [PATCH] [1996] - Create interstitial start page for withdrawals (#4850) --- app/components/record_actions/view.rb | 2 +- .../trainees/withdrawal/starts_controller.rb | 11 +++++++ .../trainees/withdrawal/starts/show.html.erb | 29 +++++++++++++++++++ config/locales/en.yml | 9 ++++++ config/routes.rb | 1 + .../trainee_actions/withdraw_trainee_spec.rb | 17 ++++++++--- spec/support/features/page_helpers.rb | 4 +++ .../page_objects/trainees/withdrawal/start.rb | 16 ++++++++++ 8 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 app/controllers/trainees/withdrawal/starts_controller.rb create mode 100644 app/views/trainees/withdrawal/starts/show.html.erb create mode 100644 spec/support/page_objects/trainees/withdrawal/start.rb diff --git a/app/components/record_actions/view.rb b/app/components/record_actions/view.rb index b08581bd4f..e72a6e0353 100644 --- a/app/components/record_actions/view.rb +++ b/app/components/record_actions/view.rb @@ -126,7 +126,7 @@ def course_started_but_no_specified_start_date? def relevant_redirect_path if trainee.trainee_start_date.present? - edit_trainee_withdrawal_date_path(trainee) + trainee_withdrawal_start_path(trainee) else trainee_start_date_verification_path(trainee, context: :withdraw) end diff --git a/app/controllers/trainees/withdrawal/starts_controller.rb b/app/controllers/trainees/withdrawal/starts_controller.rb new file mode 100644 index 0000000000..b1a210ef49 --- /dev/null +++ b/app/controllers/trainees/withdrawal/starts_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Trainees + module Withdrawal + class StartsController < Base + def show + # No additional logic needed for now + end + end + end +end diff --git a/app/views/trainees/withdrawal/starts/show.html.erb b/app/views/trainees/withdrawal/starts/show.html.erb new file mode 100644 index 0000000000..f8e65ed4ca --- /dev/null +++ b/app/views/trainees/withdrawal/starts/show.html.erb @@ -0,0 +1,29 @@ +<%= render PageTitle::View.new(text: t("trainees.withdrawals.start.show.heading")) %> + +<%= content_for(:breadcrumbs) do %> + <%= render GovukComponent::BackLinkComponent.new( + text: t("back"), + href: trainee_path(trainee), + ) %> +<% end %> + +
+
+ <%= trainee.full_name %> +

<%= t("trainees.withdrawals.start.show.heading") %>

+ +

<%= t("trainees.withdrawals.start.show.before_you_start.header") %>

+

+ <%= t("trainees.withdrawals.start.show.before_you_start.body") %> +

+ +

<%= t("trainees.withdrawals.start.show.how_your_answers_will_help.header") %>

+

+ <%= t("trainees.withdrawals.start.show.how_your_answers_will_help.body") %> +

+ + <%= govuk_link_to t("views.forms.common.continue"), edit_trainee_withdrawal_date_path(trainee), class: "govuk-button" %> +
+
+ +<%= govuk_link_to t("views.forms.common.cancel_and_return_to_record"), trainee_path(trainee), class: "govuk-link app-button--link govuk-body", role: "link" %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index e070bb424f..15becd08a3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1266,6 +1266,15 @@ en: label: Which country or territory is the trainee studying in? hint: If the trainee is studying in more than one country or territory, choose the one where they’ll spend the most time. withdrawals: + start: + show: + heading: "Withdraw the trainee" + before_you_start: + header: "Before you start" + body: "Make sure you have all the background information to why this trainee has withdrawn." + how_your_answers_will_help: + header: "How your answers will help us" + body: "Your answers will help us better understand withdrawal reasons and inform policy with the aim to increase trainee retention." dates: edit: heading: When did the trainee withdraw? diff --git a/config/routes.rb b/config/routes.rb index 91dfa1c2cc..bef1dd46dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,6 +168,7 @@ resource :award_recommendations, only: %i[create] namespace :withdrawal do + resource :start, only: :show resource :date, only: %i[edit update] resource :reason, only: %i[edit update] resource :extra_information, only: %i[edit update], path: "extra-information" diff --git a/spec/features/trainee_actions/withdraw_trainee_spec.rb b/spec/features/trainee_actions/withdraw_trainee_spec.rb index 97d615cb36..6d18dbf697 100644 --- a/spec/features/trainee_actions/withdraw_trainee_spec.rb +++ b/spec/features/trainee_actions/withdraw_trainee_spec.rb @@ -139,7 +139,7 @@ given_i_am_authenticated given_a_trainee_exists_to_be_withdrawn_with_no_start_date and_i_am_on_the_trainee_record_page - and_i_click_on_withdraw + and_i_click_on_withdraw_and_continue and_i_choose_they_have_not_started then_i_am_taken_to_the_forbidden_withdrawal_page end @@ -169,7 +169,7 @@ given_i_am_authenticated given_a_deferred_trainee_exists and_i_am_on_the_trainee_record_page - and_i_click_on_withdraw + and_i_click_on_withdraw_and_continue then_the_deferral_text_should_be_shown when_i_check_a_reason(withdrawal_reason.name) and_i_continue(:reason) @@ -185,7 +185,7 @@ given_a_trainee_exists_to_be_withdrawn and_the_trainee_has_a_duplicate and_i_am_on_the_trainee_record_page - and_i_click_on_withdraw + and_i_click_on_withdraw_and_continue then_the_duplicate_record_text_should_be_shown end @@ -226,7 +226,7 @@ def when_i_am_on_the_withdrawal_page given_i_am_authenticated given_a_trainee_exists_to_be_withdrawn and_i_am_on_the_trainee_record_page - and_i_click_on_withdraw + and_i_click_on_withdraw_and_continue end def when_i_am_on_the_date_page @@ -283,10 +283,19 @@ def and_i_continue(page) public_send("withdrawal_#{page}_page").continue.click end + def and_i_click_on_withdraw_and_continue + and_i_click_on_withdraw + and_i_start_withdrawal + end + def and_i_click_on_withdraw record_page.withdraw.click end + def and_i_start_withdrawal + and_i_continue(:start) + end + def when_i_withdraw withdrawal_confirmation_page.withdraw.click end diff --git a/spec/support/features/page_helpers.rb b/spec/support/features/page_helpers.rb index 59b8140b86..f55af6f240 100644 --- a/spec/support/features/page_helpers.rb +++ b/spec/support/features/page_helpers.rb @@ -262,6 +262,10 @@ def trainee_admin_page @trainee_admin_page ||= PageObjects::Trainees::Admin.new end + def withdrawal_start_page + @withdrawal_start_page ||= PageObjects::Trainees::Withdrawal::Start.new + end + def withdrawal_date_page @withdrawal_date_page ||= PageObjects::Trainees::Withdrawal::Date.new end diff --git a/spec/support/page_objects/trainees/withdrawal/start.rb b/spec/support/page_objects/trainees/withdrawal/start.rb new file mode 100644 index 0000000000..8f8e49253e --- /dev/null +++ b/spec/support/page_objects/trainees/withdrawal/start.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module PageObjects + module Trainees + module Withdrawal + class Start < PageObjects::Base + include PageObjects::Helpers + + set_url "/trainees/{id}/withdrawal/start" + + element :continue, ".govuk-button", text: "Continue" + element :cancel, "a", text: "Cancel and return to record" + end + end + end +end