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

Replace hard-coded strings in Playwright tests #4804

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Aug 23, 2024

Fixes

Fixes #619 by @sarayourfriend

Description

This PR audits the Playwright tests to not use hard-coded strings, replacing them with i18n translations

It also replaces some page.locator with page.getByRole selectors, and uses better selectors for checkboxes.

Testing Instructions

The CI should pass, and the changes should make sense. The Playwright tests should not have hard-coded strings left.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat requested a review from a team as a code owner August 23, 2024 08:58
@openverse-bot openverse-bot added 🧱 stack: frontend Related to the Nuxt frontend 🟩 priority: low Low priority and doesn't need to be rushed 🧰 goal: internal improvement Improvement that benefits maintainers, not users 💻 aspect: code Concerns the software code in the repository labels Aug 23, 2024
Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM. Just one small requested change to expand on the comment about Playwright's behaviour. It's a blocker because of the potential for error or confusion with it, but otherwise this is great. Love all the changes to getByRole (and similar)!

Comment on lines 36 to 37
// `.select()` doesn't work for radio buttons because Playwright
// incorrectly states that the element is covered by the icon SVG.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there is a bug report or something to link to to explain why Playwright incorrectly reports this is the case, it would be helpful to document it here. Otherwise, it seems to easy to write Playwright's error off as "incorrect" when there may actually be an underlying issue we can solve. IIRC there is a bug report about something related to SVGs and click events.

I vaguely remember something like this being the case when working on #4088, and it ended up being a bug in our pointer-events configuration for the checkboxes, leading to this change: https://github.com/WordPress/openverse/pull/4088/files#diff-9cab0d134035b3db0d42b453e18b3fff640f27e4155601385449cbe17b7788f8R50

When I was working on that, I remember coming across a Playwright bug report that seemed to indicate there was a general problem with Playwright's "click" and SVGs and that the issue seemed to imply it was just broken, rather than there being a real fix for it (in this case, passing through pointer events). In the end there was a fix in our code that did actually resolve a real (potential) problem. Apparently click events "happened" to work, but didn't technically always appear like they would work (which could affect accessibility tools maybe?).

If either is the case here, if it is a Playwright bug that we cannot do anything to fix, or if there is something we can change about the radio buttons to fix it, like there was for the checkboxes, then we should include that here explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought there was a bug because I was adding pointer-events-none to the VIcon.vue component, and it was still getting the click event. Only to realize that the element in the report component is VSvg! 🤦

Added pointer-events-none to VRadiomark and removed the comment 4cf211e

@obulat obulat force-pushed the fix/remove-hardcoded-strings-from-tests branch from f45e682 to 4cf211e Compare August 26, 2024 10:24
Copy link
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Nice! 🚀

@obulat obulat merged commit d8eca37 into main Aug 27, 2024
47 checks passed
@obulat obulat deleted the fix/remove-hardcoded-strings-from-tests branch August 27, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Update e2e tests to not rely on specific text copy, instead use translation tokens
3 participants