-
Notifications
You must be signed in to change notification settings - Fork 641
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
Fix Broken Conditionals When Cloning Survey Question Groups #6064
Fix Broken Conditionals When Cloning Survey Question Groups #6064
Conversation
Nice! I think it would be good to extend the survey_admin_spec so that it includes this behavior (in a way that would break the test if we undid the controller changes). I think both of the additional concerns you identify are valid, although I don't think they've caused any problems in practice. |
Great! I will write the test code for it too.😄
Okay. |
…ces and adding validations
ce6e3f8
to
6eca30c
Compare
…ion groups - Added robust tests to ensure conditional questions have valid conditional parameters after cloning a question group. - Fixed an issue in `SurveyAdmin.js` where CSRF token access was not using optional chaining `(?.)`, which could cause test failures due to unhandled `undefined` values.
6eca30c
to
7724cec
Compare
I’ve extended the test for While writing the test, I noticed three "FIXME" tests that were commented out because they were failing. Interestingly, the test I was working on for the current PR was also failing for the same reason as at least one of those "FIXME" tests. The issue was due to not using optional chaining ( The error would occur when the token wasn’t immediately available during test execution, leading to failures. The problematic code is in
The failure occurred because optional chaining ( Screen recording (For test case):2024-12-19-14-43-13_QTFQkBHD.mp4Capybara Screenshots (Just adding for reference in case required): |
closes #2418
What this PR does
Fixes an issue where conditionals in cloned question groups pointed to non-existent questions from the original group by updating them to reference corresponding cloned questions and adding validations to ensure conditionals are valid.
Cause of the Bug:
The root cause of the issue lies in the cloning process. When a question group is cloned:
initConditionals() in SurveyAdmin.js
the line of code which lead to the error is mentioned below.Changes Implemented
1. Conditional Mapping During Cloning:
2. Validation for Conditionals:
3. Fallback Handling:
Test Description
This test verifies that conditional question groups are correctly cloned, including their conditional logic.
Setup:
Clone Operation:
Assertions:
This ensures that the cloning functionality preserves all related conditional configurations.
Screenshots
Before:
Before.mp4
After:
After.mp4
Open questions and concerns
a.1.mp4
b.1.mp4