Skip to content

Allow routing to work with multiple conditions#2069

Merged
lfdebrux merged 2 commits into
mainfrom
ldeb-step-next-step-slug-after-routing-multiple-conditions
Apr 28, 2026
Merged

Allow routing to work with multiple conditions#2069
lfdebrux merged 2 commits into
mainfrom
ldeb-step-next-step-slug-after-routing-multiple-conditions

Conversation

@lfdebrux
Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/Ndp9ZPrn/3062-update-forms-runner-to-work-with-more-than-one-routing-condition-per-question

Update the logic in Step#next_step_slug_after_routing so that it will match a routing condition even if it isn't the first condition. This should allow forms-runner to support forms with multiple branches.

Note that this still won't match a "default" condition (answer_value of nil) that isn't the first in the list of routing conditions; our plans for routing don't currently have a use case for a default condition on a selection question, so there shouldn't be a situation where there are multiple conditions and one of them is a default condition.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

Change `id` and the `next_step_id` for the step being tested so that
they're different from the step IDs for steps we're routing to; this
makes it harder to write tests that pass with a false positive (for
instance, if you expect `second_step_id`, before that could have been
because the routing was returning the default route, instead of routing
to the second step).
Update the logic in Step#next_step_slug_after_routing so that it will
match a routing condition even if it isn't the first condition. This
should allow forms-runner to support forms with multiple branches.

Note that this still won't match a "default" condition (answer_value of
`nil`) that isn't the first in the list of routing conditions; our plans
for routing don't currently have a use case for a default condition on a
selection question, so there shouldn't be a situation where there are
multiple conditions and one of them is a default condition.
@github-actions
Copy link
Copy Markdown
Contributor

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2069.submit.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

Copy link
Copy Markdown
Contributor

@thomasiles thomasiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks really nice and clear 🏅

@lfdebrux lfdebrux added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit efd6dc0 Apr 28, 2026
7 of 9 checks passed
@lfdebrux lfdebrux deleted the ldeb-step-next-step-slug-after-routing-multiple-conditions branch April 28, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants