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"