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

Fix Playwright VR test failures #5135

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Fix Playwright VR test failures #5135

merged 2 commits into from
Nov 4, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Nov 1, 2024

Fixes

Fixes #5134 by @obulat
Note: the added lines are lines from thumbnail request tapes for rendering the search results page in Playwright

Description

The problem in #5134 was that the dark theme content switcher modal would sometimes display a "loading" state, even though the loading was finished before the light snapshot was taken.

In the Playwright visual regression tests, we have expectSnapshot function that takes the light snapshot, and then switches the theme to dark and takes the dark snapshot. The theme switching should not cause any network requests such as re-loading the search results, but in these tests for some reason that was happening.

Originally, this PR added a wait for networkidle event before taking a snapshot of the filters modal. I also tried various options of using the UI state to detect that all of the images were loaded (so that there are no changes in the snapshot backgrounds) but nothing works reliably.
Even with this check, the app was re-fetching data when the theme was changed from light to dark in expect-snapshot. I couldn't understand why that was, and couldn't reproduce it in the real app. It was only happening in Playwright trace.

So, instead of tweaking the wait for the content settings modal being rendered, I made the test load the filter on SSR (so, instead of searching without filters, and then selecting a filter and snapshotting the filters grid, we now go to the page with license_type=commercial query and load the filtered search results on the SSR).

Other changes

  • Instead of taking the picture of the whole page with the content settings modal, we take a picture of only the content settings modal.
  • The border above the tab panel in the content settings modal in the dark theme wasn't being set correctly: it was using border-default instead of border-overlay, and one of the "dark" theme CSS variable lists didn't have a value for border-overlay color.
  • initialize the theme switcher icon based on the store theme, if it's available (rather than undefined) to make it render faster
  • unset aria-hidden instead of using aria-hidden=false for "Show results" button in the modal
  • save search result thumb tapes because if the thumb doesn't exist, the page tries to load the image from the provider, making network requests.

Testing Instructions

The CI should pass even if re-ran several times

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 November 1, 2024 15:17
@obulat obulat requested review from krysal and dhruvkb November 1, 2024 15:17
@openverse-bot openverse-bot added 🧱 stack: documentation Related to Sphinx documentation 🧱 stack: frontend Related to the Nuxt frontend 🟥 priority: critical Must be addressed ASAP 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository labels Nov 1, 2024
Copy link

github-actions bot commented Nov 1, 2024

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 6400      ✗ 0   
     data_received..................: 1.5 GB  8.8 MB/s
     data_sent......................: 837 kB  4.9 kB/s
     http_req_blocked...............: avg=26.13µs  min=1.98µs  med=3.81µs   max=10.48ms p(90)=5.43µs   p(95)=5.83µs  
     http_req_connecting............: avg=21.21µs  min=0s      med=0s       max=10.42ms p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=587.37ms min=67.44ms med=511.21ms max=2.34s   p(90)=1.06s    p(95)=1.17s   
       { expected_response:true }...: avg=587.37ms min=67.44ms med=511.21ms max=2.34s   p(90)=1.06s    p(95)=1.17s   
   ✓ http_req_failed................: 0.00%   ✓ 0         ✗ 6400
     http_req_receiving.............: avg=142.05µs min=38.59µs med=115.11µs max=18.73ms p(90)=183.23µs p(95)=219.32µs
     http_req_sending...............: avg=21.71µs  min=6.96µs  med=19.24µs  max=5.1ms   p(90)=25.21µs  p(95)=27.11µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s      p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=587.2ms  min=67.3ms  med=511.04ms max=2.34s   p(90)=1.06s    p(95)=1.17s   
     http_reqs......................: 6400    37.795415/s
     iteration_duration.............: avg=3.13s    min=1.06s   med=2.56s    max=9.23s   p(90)=6.13s    p(95)=6.49s   
     iterations.....................: 1200    7.08664/s
     vus............................: 8       min=8       max=30
     vus_max........................: 30      min=30      max=30

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

Copy link

github-actions bot commented Nov 1, 2024

Full-stack documentation: https://docs.openverse.org/_preview/5135

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@obulat obulat force-pushed the fix/playwright-problem branch from 260fd12 to 0861fbe Compare November 1, 2024 15:34
@@ -96,7 +137,7 @@ export const expectSnapshot: ExpectSnapshot = async (
await turnOnDarkMode(page, dir ?? "ltr")

// Wait for the theme to change.
await sleep(200)
await sleep(100)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the original value. I thought we needed to increase it to fix the modal rendering, but turns out that switching the theme was done incorrectly before. When the modal is open, the theme switcher is covered by it. We need to close the modal, switch the theme, and then re-open the modal before taking the snapshot.

@obulat obulat force-pushed the fix/playwright-problem branch 6 times, most recently from a68b6f6 to 479eeef Compare November 2, 2024 12:12
@obulat obulat force-pushed the fix/playwright-problem branch from 479eeef to 0b1bdaf Compare November 4, 2024 03:42
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

The changes to the tests and the updated snapshots look good and make sense. I'm approving because it's critical but I do have one question:

Can you explain why there are new tapes as part of this PR? Additionally, if there are new tapes added are some old tapes no longer useful and can be removed?

@obulat
Copy link
Contributor Author

obulat commented Nov 4, 2024

Thank you!

Can you explain why there are new tapes as part of this PR? Additionally, if there are new tapes added are some old tapes no longer useful and can be removed?

When the search results page loads, if the thumbnail is not available (in one of the tapes), then the component makes a request for the image's direct URL in on image load error handler, so the rendering is further delayed. If we have all tapes for all of the results on the page, then we don't make any requests to the providers.

As for removing tapes, maybe we should remove one of the search terms we use in the Playwright tests. We currently use "cat", "birds" and "galah", which is not necessary. If we decide that this is a good idea, we can update the test files to only have one search terms, and remove unused tapes.

@obulat obulat merged commit 4568bba into main Nov 4, 2024
48 checks passed
@obulat obulat deleted the fix/playwright-problem branch November 4, 2024 14:26
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: fix Bug fix 🟥 priority: critical Must be addressed ASAP 🧱 stack: documentation Related to Sphinx documentation 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
3 participants