-
Notifications
You must be signed in to change notification settings - Fork 69
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
VACMS 6172: Adds validator and constraint to fail Drupal URLs. #6199
VACMS 6172: Adds validator and constraint to fail Drupal URLs. #6199
Conversation
it me! |
946b053
to
1545421
Compare
(I was planning on adding unit tests, I just wanted to get this PR opened before the end of the day, and it's getting close for me) |
.../custom/va_gov_backend/src/Plugin/Validation/Constraint/PreventAbsoluteCmsLinksValidator.php
Outdated
Show resolved
Hide resolved
The other issue, which increases the risk but I don't think enough to not do it is right now the links are correctly flagged as bad if they have a *// but do not hit if there is no // I think the risk of We also want to double check with Jane and Rachel that this is not going to interfere with any linking to knowledge base content where they may want to intentionally be sending people to prod.cms.va.gov |
Last comment I promise :) It would be good to pull in @rachel-kauff to get the error message to be more in line with plainlanguage feedback |
Thanks, Steve!
Yeah, I think I'm setting the constraint in a weird way or something -- I haven't figured that out. The nonworking link is referring to the same thing as a working link does (e.g. if the field were empty) but minus a
EDIT: Ugh, just accidentally closed this and sent the comment prematurely. Awesome. #friday Sure, I could take the
You're absolutely right, of course. @xiongjaneg , @rachel-kauff, do you see any issues with angrily rejecting |
…tor-and-constraint-to-fail-Drupal-URLs
…tor-and-constraint-to-fail-Drupal-URLs
I wrote a revalidation script and revalidated all however-many-thousand nodes, and this was the output. According to this, four nodes have an absolute CMS URL:
It's likely worth going through to see what the other validation issues are. From a casual glance, they seem to be of a very small variety. |
…tor-and-constraint-to-fail-Drupal-URLs
…tor-and-constraint-to-fail-Drupal-URLs
…tor-and-constraint-to-fail-Drupal-URLs
…tor-and-constraint-to-fail-Drupal-URLs
Followup for refining text in #6233. |
…tor-and-constraint-to-fail-Drupal-URLs
…tor-and-constraint-to-fail-Drupal-URLs
va/tests/status-error: +--------------------------------+----------+----------------------------------+ |
…tor-and-constraint-to-fail-Drupal-URLs
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.
awesome tests!
Description
Relates to #6172. Wrote two tests: one for rich text fields and one for plain text fields. I don't think we need tests to prove it doesn't trigger falsely -- the normal functional tests should prove that. Assuming I didn't mess something up.
To Do
I think this could be related to this Paragraphs issue, but it'll take some work to confirm that and it might just be a red herring.EDIT: It was a red herring. The TextareaWidget doesn't consult the violation path, and there is no other way to target thevalue
specifically. This was probably overlooked because TextareaWithSummaryWidget does consult the violation path.<node path alias>#<subform, etc>-field-wysiwyg-0
, whereas it should point to<node path alias>#<subform, etc>-field-wysiwyg-0-value
. I played quite a bit yesterday with ConstraintViolationBuilder::atPath(), setting it to(string) $delta . '.value'
, etc, but I couldn't get it to retain the full path. I'm gonna have to do some deep diving to figure out where the path is getting mangled.::validate()
::validateHtml()
::validateText()
Possibly shift to validating the entire entity and looping through the fields and validating each one rather than validating each field separately. I don't know if that would cause or avert performance issues.Improve functional tests to confirm that:This was a core issue, not a failing in my code AFAICT.the error links work (moving the user to the appropriate field)the error message is only displayed a single time.Update screenshots after ^^will address in followupTesting done
Added two Behat tests. Was gonna add PHPUnit tests to test mechanically, and still might depending on my mood and dictatorial disposition of my reviewer.
Screenshots
QA steps
As user uid with user_role
Definition of Done
Select Team for PR review
Core Application Team
Product Support Team
Is this PR blocked by another PR?
DO NOT MERGE
Does this PR need review from a Product Owner
Needs PO review
CMS user-facing annoucement
Is an announcement needed to let editors know of this change?