Skip to content

test(e2e): verify Cloudinary video delivery (WP player + Cloudinary player)#1178

Open
utkarshcloudinary wants to merge 9 commits into
feature/e2e-cloudinary-imagesfrom
feature/e2e-cloudinary-videos
Open

test(e2e): verify Cloudinary video delivery (WP player + Cloudinary player)#1178
utkarshcloudinary wants to merge 9 commits into
feature/e2e-cloudinary-imagesfrom
feature/e2e-cloudinary-videos

Conversation

@utkarshcloudinary
Copy link
Copy Markdown
Collaborator

Approach

Adds e2e coverage for video delivery on top of the image-delivery PR. The new spec exercises both video render paths the plugin supports:

  • Default WordPress player (video_player=wp) — verifies the plugin's server-side str_replace rewrites the <video>/<source> src to a res.cloudinary.com/<cloud_name>/... URL.
  • Cloudinary player (video_player=cld) — verifies the plugin emits a player.cloudinary.com iframe whose query string carries the configured cloud_name and a non-empty public_id.

New files

  • tests/e2e/cloudinary-video-delivery.spec.js — the spec, structured as two nested describes (one per player) under a shared lifecycle.
  • tests/e2e/fixtures/test-video.mp4 — small (~2KB) silent fixture generated via ffmpeg.

Shared lifecycle
beforeAll connects the plugin via WP-CLI (reuses utils/connection.js). beforeEach uploads the fixture via the WP REST media endpoint, creates a published post containing a single core/video block, then runs wp cloudinary sync so the asset is pushed to Cloudinary deterministically. afterEach deletes both the post and the attachment via WP-CLI.

Cloudinary-player scoping
The cld test toggles cloudinary_media_display.video_player to cld in its own beforeAll via wp option patch update and reverts to wp in afterAll. Other specs (and the wp-player test) are unaffected.

Decisions worth flagging

  • WP-CLI cleanup instead of REST, matching the image spec — the wp-env test site does not use pretty permalinks, which makes ?force=true appended to ?rest_route=-style REST URLs fragile.
  • Setting toggle uses wp option patch update so we don't fetch-modify-write the whole 33-key cloudinary_media_display blob.
  • No assertions on transformation strings, player UI, or iframe load — the intent is to catch a regression where the plugin stops rewriting URLs / stops emitting the player iframe.

QA notes

Requires CLOUDINARY_E2E_URL to be set (already wired via the e2e workflow secret and via .env locally).

npm run test:e2e -- tests/e2e/cloudinary-video-delivery.spec.js

Expected: 2 passed (~30s). Full suite (npm run test:e2e) should report 10 passed.

To inspect a run:

npm run test:e2e:debug -- tests/e2e/cloudinary-video-delivery.spec.js

After running, confirm the setting was reverted:

docker exec $(docker ps --format '{{.Names}}' | grep -E '\-tests-cli-1$') \
  wp option get cloudinary_media_display --format=json --allow-root | \
  python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('video_player'))"

Expected: wp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants