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

VACMS-10356 Add content validator for Preview URL links (#10356) #16040

Conversation

JunTaoLuo
Copy link
Contributor

@JunTaoLuo JunTaoLuo commented Nov 7, 2023

Description

Closes #10356.

Testing done

  • Added unit tests for validator
  • Tested functionality locally

Screenshots

QA steps

What needs to be checked to prove this works?
What needs to be checked to prove it didn't break any related things?
What variations of circumstances (users, actions, values) need to be checked?

As user with ability to edit content:

  1. Edit any node/page with rich text field, e.g. the VAMC system service description of a System Health Service.

  2. Insert a link to a preview URL, e.g. <a href="https://preview-staging.vfs.va.gov/example/path">Example Link!</a>

  3. Try to save the document and be blocked by errors and validate that:

    • An error appears at the top of the page:
    image
    • The field title is highlighted red to indicate error:
    image
    • An error appears at the bottom of the field:
    image
  4. Edit any node/item with plain text field, e.g. description of a media image.

  5. Add a link to a preview URL, e.g. https://preview-staging.vfs.va.gov/example/path

  6. Try to save the document and be blocked by errors and validate that:

    • An error appears at the top of the page:
    image
    • The field title is highlighted red to indicate error:
    image
    • An error appears at the bottom of the field:
    image
  7. Then validate Acceptance Criteria from issue

    • A link created to the preview server url will fail form validation and prevent save.
    • Validator is covered by unit tests.

Definition of Done

  • Documentation has been updated, if applicable.
  • Tests have been added if necessary.
  • Automated tests have passed.
  • Code Quality Tests have passed.
  • Acceptance Criteria in related issue are met.
  • Manual Code Review Approved.
  • If there are field changes, front end output has been thoroughly checked.

Select Team for PR review

  • CMS Team
  • Public websites
  • Facilities
  • User support
  • Accelerated Publishing

@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 7, 2023 21:01 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 8, 2023 19:23 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 8, 2023 20:02 Destroyed
@JunTaoLuo JunTaoLuo force-pushed the VACMS-10356-Prevent-preview-links branch from d7b8eaa to ab7e4e6 Compare November 9, 2023 15:46
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 9, 2023 15:46 Destroyed
@JunTaoLuo JunTaoLuo marked this pull request as ready for review November 9, 2023 17:23
@JunTaoLuo JunTaoLuo changed the title [WIP] VACMS-10356 Add content validator for Preview URL links (#10356) VACMS-10356 Add content validator for Preview URL links (#10356) Nov 9, 2023
@JunTaoLuo JunTaoLuo force-pushed the VACMS-10356-Prevent-preview-links branch from ab7e4e6 to 1262fe4 Compare November 9, 2023 17:25
@va-cms-bot va-cms-bot temporarily deployed to Tugboat November 9, 2023 17:25 Destroyed
Copy link
Contributor

@ndouglas ndouglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good to me -- just two things:

  • Pls open the PR from a branch on the repository so that tests run correctly.
  • Consider adjusting the name to fit how broadly it works.

Comment on lines +7 to +20
/**
* Checks that the text does not use any preview URLs as paths.
*
* In other words, we want to avoid things like this:
*
* `<a href="/https://www.va.gov/">VA.gov</a>`
*
* @Constraint(
* id = "PreventPreviewUrlsAsPathsInLinks",
* label = @Translation("Prevent Preview URLs as Paths in Links", context = "Validation"),
* type = { "string_long", "text_long" }
* )
*/
class PreventPreviewUrlsAsPathsInLinks extends Constraint {
Copy link
Contributor

@ndouglas ndouglas Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to me to be somewhat misnamed -- it's not just blocking Preview URLs as paths, but as any href. Which is good, but it'd be better if the name matched 🙂

Request: Please rename this.

@ndouglas
Copy link
Contributor

ndouglas commented Nov 9, 2023

Thanks also for the good QA steps 🙂

/**
* Data provider.
*/
public function validateDataProvider() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise: Good test cases 👍🏻

@github-actions github-actions bot added the CMS Team CMS Product team that manages both editor exp and devops label Nov 9, 2023
@JunTaoLuo
Copy link
Contributor Author

Closing in favor of #16086

@JunTaoLuo JunTaoLuo closed this Nov 9, 2023
@JunTaoLuo JunTaoLuo deleted the VACMS-10356-Prevent-preview-links branch November 9, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMS Team CMS Product team that manages both editor exp and devops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add form validation to prevent links to preview.
3 participants