EAR-2439 mutually exclusive logic not applied when mutually exclusive answer has only one option #219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the context of this PR?
Mutually exclusive logic is not applied when a mutually exclusive answer has only one option.
JIRA ticket: https://jira.ons.gov.uk/browse/EAR-2439
Credit to @Farhanam76 for helping me understand the Author product, giving me the context of the Author product, and the codebase, coming up with the initial logic to solve this issue and letting me work on this ticket with her.
Bug
Reproduce for reviews
Match OneOf
and select the exclusive answer (OR answer) option.When you do this currently, there is a bug where if you enter something in the textarea, it will go to the end of the current section page as it should. If you tick the checkbox, it should go to the page configured in the routing logic rule but currently, it doesn't and goes to the end of the current section page (the bug).
This is not an issue if there are multiple answer options for the exclusive answer (OR answer) as it'll become radio buttons instead of a checkbox (happens when you only have one answer option for the exclusive answer field).
What to do after everything is green
Fix
src/eq_schema/builders/routing2/newRoutingDestination/index.js
if (condition === "OneOf")
to check if the answer object containstype:"MutuallyExclusive"
and if the options length === 1routingConditionConversion
instead of OneOf to fix this bug.utils/functions/answerGetters.js
and it has a reusable function calledgetAnswerById
to retrieve the answer object by using the answer ID.