From 1a52ff79ae29f83a6f64be000c3b5b2f5d177199 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Wed, 16 Sep 2026 15:42:13 +0300 Subject: [PATCH] Add support for adding routes using multiple branches feature When the multiple branches feature is released generally in forms-admin, the way to add or edit routes for a form will change. This commit updates the code for creating a test form in the end to end specs to work with either the new "Edit question routes" page to add routes or the old journey when the multiple branches feature is not enabled, depending on what buttons are present on the "Add and edit your questions" page. --- spec/end_to_end/end_to_end_spec.rb | 11 +++++++++-- spec/support/feature_helpers.rb | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/spec/end_to_end/end_to_end_spec.rb b/spec/end_to_end/end_to_end_spec.rb index 19d8317..0361b71 100644 --- a/spec/end_to_end/end_to_end_spec.rb +++ b/spec/end_to_end/end_to_end_spec.rb @@ -59,8 +59,15 @@ click_link "your questions", match: :first - add_a_route selection_question, if_the_answer_selected_is: "Yes", skip_the_person_to: alternate_question_text - add_a_secondary_skip last_question_before_skip: question_text, question_to_skip_to: "End of the form" + if page.has_selector?(:link, "Add a question route") + add_a_route selection_question, if_the_answer_selected_is: "Yes", skip_the_person_to: alternate_question_text + add_a_secondary_skip last_question_before_skip: question_text, question_to_skip_to: "End of the form" + else + add_routes do + select_route selection_question, if_option: "Yes", go_to: alternate_question_text + select_route question_text, go_to: "End of the form" + end + end finish_form_creation diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 085f9e5..3d94883 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -242,6 +242,27 @@ def add_a_route(question_to_add_a_route_from, if_the_answer_selected_is:, skip_t click_button "Save and continue" end + def add_routes + expect(page).to have_css("h1", text: "Add and edit your questions") + click_on "Add routes" + + expect(page).to have_css "h1", text: "Edit question routes" + + yield + + click_button "Save and continue" + expect(page).to have_css ".govuk-notification-banner", text: "Your routes have been saved" + end + + def select_route(question, go_to:, if_option: nil) + question = find(:xpath, ".//p[contains(., '#{question}')]/..") + + question.select( + go_to, + from: if_option ? "(#{if_option}), go to:" : "After question", + ) + end + def add_a_secondary_skip(last_question_before_skip:, question_to_skip_to:) click_on "Set questions to skip"