Skip to content

Tests: Mock Openverse in the image drag-and-drop e2e test - #83798

Closed
adamsilverstein wants to merge 2 commits into
trunkfrom
fix/e2e-mock-openverse-image-drag
Closed

adamsilverstein wants to merge 2 commits into
trunkfrom
fix/e2e-mock-openverse-image-drag

Conversation

@adamsilverstein

Copy link
Copy Markdown
Member

Every E2E run since about 18:00 UTC today, trunk included, fails on the Openverse image drag-and-drop test. This mocks Openverse so the test stops depending on it.

Claude traced the failure through the CI trace and wrote up the fix:

What?

Mocks the Openverse search request and the image it returns in the can be replaced by dragging-and-dropping images from the inserter test in test/e2e/specs/editor/blocks/image.spec.js.

Why?

The test fails on all three attempts on trunk (https://github.com/WordPress/gutenberg/actions/runs/36612771519) and on every PR since.

The live Openverse API now returns NASA images hosted on live.staticflickr.com first. The inserter's excluded_source=flickr filter checks the source, which is nasa here, so these images aren't filtered out. In CI the image fetch fails with a CORS error:

Access to fetch at 'https://live.staticflickr.com/5727/21680130205_a83fd34928_b.jpg' from origin 'http://localhost:8889' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

The sideload never starts, so the image block keeps its placeholder and the assertion times out.

The same approach is already open for the release branches in #83621, #83687 and #83714.

How?

page.route() fulfills https://api.openverse.org/v1/images/** with two mock results, and fulfills the mock image URL with the existing 10x10_e2e_test_image_z9T8jK.png asset, both with Access-Control-Allow-Origin: *. The rest of the test is unchanged, so it still covers the drag, the sideload and the switch to a local media URL.

Testing Instructions

  1. Check that the Playwright job running specs/editor/blocks/image.spec.js passes on this PR.
  2. Locally: npm run test:e2e -- test/e2e/specs/editor/blocks/image.spec.js -g "dragging-and-dropping images from the inserter"

The Openverse filter letting Flickr-hosted images through may deserve its own issue. That's out of scope here.

AI Use

Claude Code wrote the code and the description. I will review and test.

🤖 Generated with Claude Code

https://claude.ai/code/session_016UV8km5az5vUNvgieaWiND

The live Openverse API now returns Flickr-hosted NASA images first.
The excluded_source filter doesn't drop them, and their host doesn't
send CORS headers to CI, so the sideload fetch fails and the test
fails on every branch. Mock the search and image responses so the
test no longer depends on an external service.

Claude-Session: https://claude.ai/code/session_016UV8km5az5vUNvgieaWiND
@adamsilverstein adamsilverstein added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: 0 B

Total Size: 8.24 MB

c606901 Run

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka

mirka commented Sep 30, 2026

Copy link
Copy Markdown
Member

Closing as fixed in #83842

@mirka mirka closed this Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants