Skip to content

Commit

Permalink
Fix the labels on addresses
Browse files Browse the repository at this point in the history
Labels on addresses were `for` `claim_some_address` but the radio button
had the `id` `some_address`. Update the radio buttons to use
govuk_radio_button helper and let that generate the label tag. Also
updates the specs to click the labels rather than find the radio buttons
by id.
  • Loading branch information
rjlynch committed Sep 9, 2024
1 parent b1571e5 commit 050df70
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions app/views/claims/select_home_address.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="govuk-grid-column-two-thirds">
<%= render("shared/error_summary", instance: @form, errored_field_id_overrides: { "address": "#{@address_data.first[:address].gsub(",", "").gsub(" ", "_").downcase}"}) if @form.errors.any? %>

<%= form_for @form, url: claim_path(current_journey_routing_name) do |form| %>
<%= form_for @form, url: claim_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
<div class="govuk-!-margin-bottom-5">
<h1 class="govuk-heading-xl"><%= t("questions.address.home.title") %></h1>
<h2 class="govuk-heading-l govuk-!-margin-bottom-1">Postcode</h2>
Expand All @@ -27,10 +27,12 @@
<% address = option[:address].gsub(",", "").gsub(" ", "_").downcase %>
<% checked = params.dig(:claim, :address_line_1) == option[:address_line_1] %>

<div class="govuk-radios__item">
<%= form.radio_button :address, [option[:address], option[:address_line_1], option[:address_line_2], option[:address_line_3], option[:postcode]].join(":"), { checked:, class: "govuk-radios__input", id: address } %>
<%= form.label address, "#{option[:address]}", class: "govuk-label govuk-radios__label", id: address %>
</div>
<%= form.govuk_radio_button(
:address,
[option[:address], option[:address_line_1], option[:address_line_2], option[:address_line_3], option[:postcode]].join(":"),
label: { text: option[:address] },
checked: checked
) %>
<% end %>
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
# - Select your home address
expect(page).to have_text(I18n.t("questions.address.home.title"))

choose "flat_11_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 11, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"
click_on "Continue"

journey_session.reload
Expand Down Expand Up @@ -445,7 +445,7 @@
expect(page).to have_text("6, Wearside Road, London, SE13 7UN")
expect(page).to have_link(href: claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME, "address"))

choose "5_wearside_road_london_se13_7un"
choose "5, Wearside Road, London, SE13 7UN"
click_on "Continue"

journey_session.reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def navigate_to_check_email_page(school:)
# - Select your home address
expect(page).to have_text(I18n.t("questions.address.home.title"))

choose "flat_11_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 11, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"
click_on "Continue"
end
end
2 changes: 1 addition & 1 deletion spec/features/early_career_payments_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@
# - Select your home address
expect(page).to have_text(I18n.t("questions.address.home.title"))

choose "flat_11_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 11, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"
click_on "Continue"

# - What is your address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def navigate_to_check_email_page(school:)
# - Select your home address
expect(page).to have_text(I18n.t("questions.address.home.title"))

choose "flat_11_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 11, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"
click_on "Continue"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def navigate_to_teacher_reference_number_page(school:)
# - Select your home address
expect(page).to have_text(I18n.t("questions.address.home.title"))

choose "flat_11_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 11, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"
click_on "Continue"

# - select-email page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def and_i_complete_the_postcode_step
click_on "Search"

expect(page).to have_text("Select an address")
choose "flat_1_millbrook_tower_windermere_avenue_southampton_so16_9fx"
choose "Flat 1, Millbrook Tower, Windermere Avenue, Southampton, SO16 9FX"

click_on "Continue"
end
Expand Down

0 comments on commit 050df70

Please sign in to comment.