Skip to content

Commit 4fdd4cf

Browse files
authored
Merge pull request #2836 from govuk-forms/update-labels-and-option-text-on-new-routes-page
Update labels and option text on new routes page
2 parents 8179e10 + 62af1fa commit 4fdd4cf

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

app/services/routes/build_service.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def options_for_goto_page(page, selected = nil)
4545
if drop
4646
if value == next_page_id
4747
drop = false
48-
["Go to question #{page.position.next}", Forms::RouteInput::DEFAULT_VALUE]
48+
["#{page.position.next}. #{next_page.question_text}", Forms::RouteInput::DEFAULT_VALUE]
4949
elsif selected && value == selected
5050
option
5151
end
@@ -76,7 +76,7 @@ def build_routes_for_selection_page(page, conditions_by_key)
7676
answer_value:,
7777
goto: goto_value_for(condition),
7878
goto_options: options_for_goto_page(page, condition&.goto_page_id),
79-
label: { text: "Option #{index}: #{answer_value_label}" },
79+
label: { text: "If option #{index} (#{answer_value_label}), go to:" },
8080
)
8181
end
8282
end
@@ -92,7 +92,7 @@ def build_route_for_generic_page(page, conditions_by_key)
9292
page:,
9393
goto: goto_value_for(condition),
9494
goto_options: options_for_goto_page(page, condition&.goto_page_id),
95-
label: { text: "Go to", hidden: true },
95+
label: { text: "After question #{page.position}, go to:" },
9696
),
9797
]
9898
end

spec/services/routes/build_service_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
it "sets the label correctly for a generic page" do
4040
route_for_page1 = service.build_routes.first
41-
expect(route_for_page1.label).to eq({ text: "Go to", hidden: true })
41+
expect(route_for_page1.label).to eq({ text: "After question #{pages.first.position}, go to:" })
4242
end
4343

4444
context "when a condition exists for the generic page" do
@@ -117,10 +117,10 @@
117117
route_for_no = routes_for_page1.find { |r| r.answer_value == "No" }
118118

119119
expect(route_for_yes.goto).to eq(Forms::RouteInput::DEFAULT_VALUE)
120-
expect(route_for_yes.label).to eq({ text: "Option 1: Yes" })
120+
expect(route_for_yes.label).to eq({ text: "If option 1 (Yes), go to:" })
121121

122122
expect(route_for_no.goto).to eq(Forms::RouteInput::DEFAULT_VALUE)
123-
expect(route_for_no.label).to eq({ text: "Option 2: No" })
123+
expect(route_for_no.label).to eq({ text: "If option 2 (No), go to:" })
124124
end
125125

126126
context "when the selection page has more than 10 options" do
@@ -154,7 +154,7 @@
154154

155155
none_of_the_above_route = routes_for_page1.find { |r| r.answer_value == "none_of_the_above" }
156156
expect(none_of_the_above_route).not_to be_nil
157-
expect(none_of_the_above_route.label[:text]).to eq("Option 3: None of the above")
157+
expect(none_of_the_above_route.label[:text]).to eq("If option 3 (None of the above), go to:")
158158
end
159159
end
160160

@@ -207,7 +207,7 @@
207207
expect(route_for_page1).to be_a(Forms::RouteInput)
208208
expect(route_for_page1.page_id).to eq(pages.first.id)
209209
expect(route_for_page1.answer_value).to be_nil
210-
expect(route_for_page1.label).to eq({ text: "Go to", hidden: true })
210+
expect(route_for_page1.label).to eq({ text: "After question #{pages.first.position}, go to:" })
211211
end
212212
end
213213
end
@@ -242,7 +242,7 @@
242242
options = service.options_for_goto_page(pages.first)
243243
default_option = options.find { |opt| opt[1] == Forms::RouteInput::DEFAULT_VALUE }
244244

245-
expect(default_option).to eq(["Go to question 2", Forms::RouteInput::DEFAULT_VALUE])
245+
expect(default_option).to eq(["2. #{pages.second.question_text}", Forms::RouteInput::DEFAULT_VALUE])
246246
end
247247

248248
it "does not include the current page in the options" do
@@ -256,7 +256,7 @@
256256
options = service.options_for_goto_page(pages.second)
257257

258258
expect(options).to eq [
259-
["Go to question 3", Forms::RouteInput::DEFAULT_VALUE],
259+
["3. #{pages.third.question_text}", Forms::RouteInput::DEFAULT_VALUE],
260260
["End of the form", "end_of_form"],
261261
]
262262
end
@@ -267,7 +267,7 @@
267267

268268
expect(options).to eq [
269269
["1. #{pages.first.question_text}", pages.first.id],
270-
["Go to question 3", Forms::RouteInput::DEFAULT_VALUE],
270+
["3. #{pages.third.question_text}", Forms::RouteInput::DEFAULT_VALUE],
271271
["End of the form", "end_of_form"],
272272
]
273273
end

spec/views/routes/show.html.erb_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def select_options(select_field)
8181

8282
expect(rendered).to have_selector('.govuk-select[name="forms_routes_input[routes_attributes][0][goto]"]') do |field|
8383
expect(select_options(field)).to eq [
84-
["default", "Go to question 2"],
84+
["default", "2. #{pages.second.question_text}"],
8585
["103", "3. #{pages.third.question_text}"],
8686
["end_of_form", "End of the form"],
8787
]
8888
end
8989

9090
expect(rendered).to have_selector('.govuk-select[name="forms_routes_input[routes_attributes][1][goto]"]') do |field|
9191
expect(select_options(field)).to eq [
92-
["default", "Go to question 3"],
92+
["default", "3. #{pages.third.question_text}"],
9393
["end_of_form", "End of the form"],
9494
]
9595
end

0 commit comments

Comments
 (0)