Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions spec/end_to_end/end_to_end_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions spec/support/feature_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down