Skip to content

fix: mock oEmbed proxy in embed E2E test to prevent CI flakes#354

Merged
dcalhoun merged 2 commits intotrunkfrom
fix/mock-oembed-proxy-in-embed-test
Mar 6, 2026
Merged

fix: mock oEmbed proxy in embed E2E test to prevent CI flakes#354
dcalhoun merged 2 commits intotrunkfrom
fix/mock-oembed-proxy-in-embed-test

Conversation

@dcalhoun
Copy link
Copy Markdown
Member

@dcalhoun dcalhoun commented Mar 6, 2026

What?

Mocks the WordPress oEmbed proxy endpoint in the embed content E2E test using Playwright's page.route().

Why?

The embed test (embed-content.spec.js) hits YouTube's oEmbed endpoint via the WordPress proxy during CI. If YouTube rate-limits or is unreachable, the test flakes. This was flagged in #329 (comment).

How?

  • Adds a mockOembedProxy() helper that intercepts requests to the /oembed/1.0/proxy REST API endpoint using Playwright's route interception.
  • YouTube URLs receive a canned successful oEmbed JSON response.
  • Non-embeddable URLs receive a 404, matching WordPress's real behavior.
  • Both tests call mockOembedProxy(page) before editor.setup(), so no external network calls are made.

Testing Instructions

  1. Run make wp-env-start to start the local WordPress environment.
  2. Run npx playwright test e2e/embed-content.spec.js.
  3. Verify both tests pass without any network calls to YouTube.

Accessibility Testing Instructions

N/A — no UI changes.

Screenshots or screencast

N/A — test infrastructure only.

The embed content test was hitting YouTube's oEmbed endpoint via the
WordPress proxy, which can flake in CI due to rate-limiting or network
issues. Use Playwright's page.route() to intercept the oEmbed proxy
REST API request and return canned responses instead.
@dcalhoun dcalhoun added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Mar 6, 2026
Parse the embed URL and match the hostname with a regex instead of
using a substring check, which could match unintended URLs containing
"youtube.com" in other positions.
@dcalhoun dcalhoun marked this pull request as ready for review March 6, 2026 01:28
@dcalhoun dcalhoun requested a review from kean March 6, 2026 01:28
@dcalhoun dcalhoun enabled auto-merge (squash) March 6, 2026 01:29
Copy link
Copy Markdown
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

Nice, thanks for addressing it.

@dcalhoun dcalhoun merged commit 768bdfa into trunk Mar 6, 2026
14 checks passed
@dcalhoun dcalhoun deleted the fix/mock-oembed-proxy-in-embed-test branch March 6, 2026 13:58
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