-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Symfony expects true/false for CheckboxType #9931
Conversation
Codecov Report
@@ Coverage Diff @@
## features #9931 +/- ##
===========================================
Coverage 39.91% 39.91%
Complexity 34336 34336
===========================================
Files 2038 2038
Lines 108606 108604 -2
===========================================
Hits 43350 43350
+ Misses 65256 65254 -2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Load up this PR ✅
- Browse the UI and toggle the Yes/No buttons in various forms (typically used for published/enabled states). Changing the state, saving, and editing should repopulate the correct state. ✅
- API functional tests should pass (the 5 tests that failed always fail on my local) ❓ Seemingly unable to get this up and running locally as all my tests are failing having cloned the API Library and set up with ddev / run
ddev exec composer test
- Test the Configuration can be saved and manipulated ✅
- Create a batch of messages via the API ✅
- Try to PATCH ✅
- Try to PUT ✅
- Try using 0/1 rather than yes/no ✅
So this is a +1 from me but we need someone to check the tests in step 3 as I was unable to get that part to work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm this fixes the message_channels
bug in the API library tests: https://github.com/mautic/api-library/pull/249/checks?check_run_id=2495446071
Code also LGTM, thanks @alanhartless 🚀
This will have to be reverted: #10716 |
Description:
One of the API tests started to fail with the Symfony Forms version bump to 4.4.21, specifically with the addition of this code symfony/form@v4.4.20...v4.4.21#diff-bb5d9d94844af7f842e5b6aa429a8a0141316e527f0c4bd31d3a140adfc7c581R145.
It seems that prior to 4.4.21, our YesNoButtonGroupType returning integers for values worked but now fails because of the above change leading to isEnabled being set as null. YesNoButtonGroupType is getting proxied as RadioType when resolved by Symfony forms which inherits CheckboxType and according to Symfony docs, should have boolean values. Switching the values of YesNoButtonGroupType from integers to booleans caused the API test to pass. Yes/No toggles in the UI also continue to work.
Steps to test this PR:
4. Test the Configuration can be saved and manipulated 4. Create a batch of messages via the API: `POST /api/messages/batch/new` (change channelId to be the ID of an Email and SMS that exists in your Mautic) ``` [ { "name": "API message", "description": "Marketing message created via API unit test", "channels": { "email": { "channel": "email", "channelId": 27, "isEnabled": false }, "sms": { "channel": "sms", "channelId": 17, "isEnabled": true } } }, { "name": "API message", "description": "Marketing message created via API unit test", "channels": { "email": { "channel": "email", "channelId": 27, "isEnabled": false }, "sms": { "channel": "sms", "channelId": 17, "isEnabled": true } } }, { "name": "API message", "description": "Marketing message created via API unit test", "channels": { "email": { "channel": "email", "channelId": 27, "isEnabled": false }, "sms": { "channel": "sms", "channelId": 17, "isEnabled": true } } } ] ```
Then try to PATCH by switching the isEnabled of each channel and adding the message ID:
PATCH /api/messages/batch/edit
Then try PUT as well
PUT /api/messages/batch/edit
Finally, try using 0/1 instead of true/false.
BC Breaks:
This changes causes Symfony to render the value of the No button as empty. This shouldn't cause any issues for most. But if they happen to be using a NotBlank constraints on the YesNoButtonGroupType, as found in this PR, it will fail because the submission will have an empty value (it shouldn't be required to start with because the buttons default to No). It also means that some functional tests that may have previously submitted 0 as the value will value as an invalid value.