WordPress / openverse

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
https://openverse.org
MIT License
254 stars 203 forks source link

Change text to secondary on content-heavy pages #5148

Open dhruvkb opened 2 weeks ago

dhruvkb commented 2 weeks ago

Fixes

Fixes #5119 by @obulat Fixes #5151 by @fcoveram

Description

This PR changes the content pages to use text-secondary for the body text, while retaining text-default for the headings.

Testing Instructions

Visit the content pages and see that the text should be a little lighter and less contrasted with the background.

I'll update the snapshots once @fcoveram approves the new designs.

Checklist

[best_practices]: https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines

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. ```
github-actions[bot] commented 2 weeks ago

Latest k6 run output[^update]

     ✓ status was 200

     checks.........................: 100.00% ✓ 6400      ✗ 0   
     data_received..................: 1.5 GB  8.6 MB/s
     data_sent......................: 837 kB  4.8 kB/s
     http_req_blocked...............: avg=10.59µs  min=1.95µs  med=4.27µs   max=4.34ms   p(90)=5.69µs   p(95)=6.15µs  
     http_req_connecting............: avg=5.99µs   min=0s      med=0s       max=4.28ms   p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=605.42ms min=41.26ms med=524.43ms max=2.36s    p(90)=1.1s     p(95)=1.2s    
       { expected_response:true }...: avg=605.42ms min=41.26ms med=524.43ms max=2.36s    p(90)=1.1s     p(95)=1.2s    
   ✓ http_req_failed................: 0.00%   ✓ 0         ✗ 6400
     http_req_receiving.............: avg=148.33µs min=41.22µs med=119.3µs  max=21.06ms  p(90)=186.11µs p(95)=223.51µs
     http_req_sending...............: avg=20.75µs  min=6.76µs  med=20.11µs  max=427.63µs p(90)=25.62µs  p(95)=27.57µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=605.25ms min=41.08ms med=524.3ms  max=2.36s    p(90)=1.1s     p(95)=1.2s    
     http_reqs......................: 6400    36.710781/s
     iteration_duration.............: avg=3.23s    min=1.13s   med=2.62s    max=9.72s    p(90)=6.28s    p(95)=6.59s   
     iterations.....................: 1200    6.883272/s
     vus............................: 6       min=6       max=30
     vus_max........................: 30      min=30      max=30

[^update]: This comment will automatically update with new output each time k6 runs for this PR

dhruvkb commented 2 weeks ago

Thanks @fcoveram! I'll update the visual regression testing snapshots then.

fcoveram commented 2 weeks ago

I created this ticket requesting the update of text-secondary.

dhruvkb commented 2 weeks ago

@fcoveram changing the text-secondary color to gray-12 impacts the whole application, not just the text-heavy pages. Can you check out this branch and see if it looks good to you?

For example on this page the search query, artist name, duration, genre/category and license icons have all gotten darker.

Screenshot 2024-11-08 at 3 20 25 PM
fcoveram commented 1 week ago

Just for the record, during yesterday's community meeting, I agreed with @dhruvkb's idea to limit the use of a darker shade as text-secondary in text-heavy pages. So let's continue with that 👍

obulat commented 3 days ago

@dhruvkb, I think I've found the reason for visual regression tests not failing. All pixels in the snapshots are the same, only their color is different. And the difference in color is not a reason for failing tests due to threshold[https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-2-option-threshold] set to 0.2 by default.

An acceptable perceived color difference in the YIQ color space between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with TestConfig.expect. Defaults to 0.2

Setting it to 0.18 makes the tests fail. I think we could set it to 0.1 by default:

Subject: [PATCH] Fix unit test warnings
---
Index: frontend/test/playwright/visual-regression/pages/pages.spec.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/frontend/test/playwright/visual-regression/pages/pages.spec.ts b/frontend/test/playwright/visual-regression/pages/pages.spec.ts
--- a/frontend/test/playwright/visual-regression/pages/pages.spec.ts    (revision abac8a12fdcd210e7eeb935685ababdf2813feeb)
+++ b/frontend/test/playwright/visual-regression/pages/pages.spec.ts    (date 1731940873192)
@@ -44,7 +44,6 @@
           await expectSnapshot(page, contentPage, page, {
             dir,
             screenshotOptions: { fullPage: true },
-            snapshotOptions: { maxDiffPixelRatio: 0.0 },
           })
         })
       })
Index: frontend/test/playwright/playwright.config.ts
<+>UTF-8
===================================================================
diff --git a/frontend/test/playwright/playwright.config.ts b/frontend/test/playwright/playwright.config.ts
--- a/frontend/test/playwright/playwright.config.ts (revision abac8a12fdcd210e7eeb935685ababdf2813feeb)
+++ b/frontend/test/playwright/playwright.config.ts (date 1731945641913)
@@ -66,6 +66,11 @@
    * to avoid the test also becoming a load test.
    */
   workers: UPDATE_TAPES === "true" || baseURL !== localBaseURL ? 1 : undefined,
+  expect: {
+    toMatchSnapshot: {
+      threshold: 0.1,
+    }
+  }
 }

 export default config
dhruvkb commented 3 days ago

Thanks for discovering this @obulat.

github-actions[bot] commented 3 days ago

Playwright failure test results: https://github.com/WordPress/openverse/actions/runs/11899883311

It looks like some of the Playwright tests failed. If you made changes to the frontend UI without updating snapshots, this might be the cause. You can download zipped patches containing the updated snapshots alongside a general trace of the tests under the "Artifacts" section in the above page. They're named in the form *_snapshot_diff and *_test_results respectively.

You can read more on how to use these artifacts in the docs.

If the test is flaky, follow the flaky test triage procedure.