From 61e74aeb20bf8813e8341a3fcd883a250158d99e Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 17 Jun 2024 15:55:16 +0100 Subject: [PATCH] use GOVUK formbuilder for mobile number form --- app/views/claims/mobile_number.html.erb | 42 +++++++------------ spec/features/changing_answers_spec.rb | 2 +- .../claim_with_mobile_sms_otp_spec.rb | 2 +- ...urney_with_teacher_id_check_mobile_spec.rb | 2 +- ...urney_with_teacher_id_check_mobile_spec.rb | 2 +- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/app/views/claims/mobile_number.html.erb b/app/views/claims/mobile_number.html.erb index f5ee0ef5d7..72fd5e821d 100644 --- a/app/views/claims/mobile_number.html.erb +++ b/app/views/claims/mobile_number.html.erb @@ -9,35 +9,25 @@
- <%= render("shared/error_summary", instance: @form) if @form.errors.any? %> + <%= form_for @form, url: claim_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_error_summary %> - <%= form_for @form, url: claim_path(current_journey_routing_name) do |f| %> - <%= t("questions.personal_details") %> - <%= form_group_tag f.object do %> -

- <%= f.label( - :mobile_number, - t("questions.mobile_number"), - class: "govuk-label #{label_css_class_for_journey(f.object.journey)}" - ) %> -

+ <%= f.govuk_phone_field :mobile_number, + spellcheck: "false", + caption: { + text: t("questions.personal_details"), + size: "xl" + }, + label: { + text: t("questions.mobile_number"), + tag: "h1", + size: "xl", + }, + hint: { text: "To verify your mobile number we will send you a text message with a 6-digit passcode. You can enter the passcode on the next screen." } %> -
- To verify your mobile number we will send you a text message with a 6-digit passcode. You can enter the passcode on the next screen. -
- - <%= errors_tag f.object, :mobile_number %> - - <%= f.text_field( - :mobile_number, - spellcheck: "false", - class: css_classes_for_input(f.object, :mobile_number), - "aria-describedby" => "mobile-number-hint" - ) %> - - <% end %> <%= render "help_with_access_codes", communication_type: "Mobile" %> - <%= f.submit "Continue", class: "govuk-button" %> + + <%= f.govuk_submit "Continue" %> <% end %>
diff --git a/spec/features/changing_answers_spec.rb b/spec/features/changing_answers_spec.rb index 3a8bd108e4..c5785e25d8 100644 --- a/spec/features/changing_answers_spec.rb +++ b/spec/features/changing_answers_spec.rb @@ -417,7 +417,7 @@ expect(page).not_to have_content("Check your answers before sending your application") expect(page).to have_text(I18n.t("questions.mobile_number")) - fill_in "claim_mobile_number", with: new_mobile + fill_in "Mobile number", with: new_mobile click_on "Continue" expect(session.reload.answers.mobile_number).to eql new_mobile diff --git a/spec/features/claim_with_mobile_sms_otp_spec.rb b/spec/features/claim_with_mobile_sms_otp_spec.rb index 0d6d6159bf..4832cb52f5 100644 --- a/spec/features/claim_with_mobile_sms_otp_spec.rb +++ b/spec/features/claim_with_mobile_sms_otp_spec.rb @@ -42,7 +42,7 @@ # - Mobile number expect(page).to have_text(I18n.t("questions.mobile_number")) - fill_in "claim_mobile_number", with: scenario[:mobile_number] + fill_in "Mobile number", with: scenario[:mobile_number] click_on "Continue" expect(session.reload.answers.mobile_number).to eql(scenario[:mobile_number]) diff --git a/spec/features/combined_teacher_claim_journey_with_teacher_id_check_mobile_spec.rb b/spec/features/combined_teacher_claim_journey_with_teacher_id_check_mobile_spec.rb index 48bc60c807..3e6ba15069 100644 --- a/spec/features/combined_teacher_claim_journey_with_teacher_id_check_mobile_spec.rb +++ b/spec/features/combined_teacher_claim_journey_with_teacher_id_check_mobile_spec.rb @@ -208,7 +208,7 @@ def provide_alternative_number find("#claim_mobile_check_alternative").click click_on "Continue" - fill_in "claim_mobile_number", with: alt_phone_number + fill_in "Mobile number", with: alt_phone_number click_on "Continue" fill_in "claim_one_time_password", with: otp_code diff --git a/spec/features/tslr_claim_journey_with_teacher_id_check_mobile_spec.rb b/spec/features/tslr_claim_journey_with_teacher_id_check_mobile_spec.rb index de9f554503..4186a00496 100644 --- a/spec/features/tslr_claim_journey_with_teacher_id_check_mobile_spec.rb +++ b/spec/features/tslr_claim_journey_with_teacher_id_check_mobile_spec.rb @@ -197,7 +197,7 @@ def provide_alternative_number find("#claim_mobile_check_alternative").click click_on "Continue" - fill_in "claim_mobile_number", with: alt_phone_number + fill_in "Mobile number", with: alt_phone_number click_on "Continue" fill_in "claim_one_time_password", with: otp_code