Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAR-2439 mutually exclusive logic not applied when mutually exclusive answer has only one option #219

Merged
merged 12 commits into from
Aug 6, 2024

Conversation

sanjeevz3009
Copy link
Contributor

@sanjeevz3009 sanjeevz3009 commented Jul 22, 2024

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

  • Design a question, have a textarea answer, then have a mutually exclusive answer (OR answer field in Author) and have only one answer option for the mutually exclusive.
  • Add the routing logic rule of Match OneOf and select the exclusive answer (OR answer) option.
  • Then select a page to go to if the exclusive answer checkbox is ticked.
  • Else go to the end of the current section.

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

    • Bring this branch up-to-date with Origin/Master
    • If there are a lot of commits or some are not helpful to read, squash them down
    • Click the Merge button on this pull request
    • Does this change mean the Capability examples questionnaire should be updated?
    • Move the Jira ticket for this task into the next stage of the process

Fix

  • File changed: src/eq_schema/builders/routing2/newRoutingDestination/index.js
  • Nested if statement added under if (condition === "OneOf") to check if the answer object contains type:"MutuallyExclusive" and if the options length === 1
    • If the above conditions are met AllOf passed into routingConditionConversion instead of OneOf to fix this bug.
  • Created a new file called utils/functions/answerGetters.js and it has a reusable function called getAnswerById to retrieve the answer object by using the answer ID.

@sanjeevz3009 sanjeevz3009 marked this pull request as ready for review July 26, 2024 16:12
@Farhanam76 Farhanam76 merged commit 14fc1de into master Aug 6, 2024
2 checks passed
@Farhanam76 Farhanam76 deleted the EAR-2439-Mutually-Exclusive-Logic-Not-Applied branch August 6, 2024 12:38
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.

4 participants