Skip to content

test(e2e): Add per-asset overlay and crop spec - #1316

Open
utkarshcloudinary wants to merge 2 commits into
developfrom
test/asset-edit-transformations-e2e
Open

utkarshcloudinary wants to merge 2 commits into
developfrom
test/asset-edit-transformations-e2e

Conversation

@utkarshcloudinary

Copy link
Copy Markdown
Collaborator

Adds a Playwright spec that edits one asset through the real Edit Asset UI. It checks that a text overlay and a crop change the front-end image URL, and that removing them reverts the URL to the default.

Approach

  • tests/e2e/cloudinary-asset-edit.spec.js (@serial, needs CLOUDINARY_E2E_URL):
    • beforeAll uploads one image, publishes a post with an inline image block, and runs wp cloudinary sync. The two tests share this asset, so the file runs in serial mode.
    • Text overlay: the test opens admin.php?page=cloudinary&section=edit-asset&asset=<ID>, types the overlay text, and clicks Save Changes. On the front end, src and data-transformations contain l_text:Arial_20:<text> and fl_layer_apply. The test then clicks Reset All and saves again. src and data-transformations are then the same as before the edit.
    • Crop: the test enters c_crop,h_120,w_160 in Asset transformations and saves. The crop is then in src and data-transformations. The test then clears the field and saves. The values are then the same as before the edit.
    • Each save waits for the save_asset response and checks that it has no note, which the plugin returns for a transformation that is not valid.
    • Each front-end check waits for the lazy-loader to put the res.cloudinary.com/<cloud_name>/ URL into src. It does not use fixed timeouts.
  • Reset All only clears the form. The overlay stays on the front end until the user clicks Save Changes, so the test does both steps.

QA notes

  • cp .env.example .env and set CLOUDINARY_E2E_URL to a test account.
  • npm run env:start, or npx wp-env start --config .wp-env.ci.json for the plain HTTP setup that CI uses.
  • npm run test:e2e:serial -- cloudinary-asset-edit, or with the CI config: WP_BASE_URL=http://localhost:8889 ./.wp-env/scripts/run-e2e.sh cloudinary-asset-edit --workers=1.
  • Expect 2 passing tests.

Drive the real Edit Asset UI to save a text overlay and a crop,
then assert the front-end image delivery URL picks them up and
reverts to the default once they are removed.
When the theme emits a srcset, the lazy-loader restores it and keeps
the SVG placeholder in src, so the src check failed in CI. Assert on
currentSrc, which is the URL the browser loads in both cases.

This branch has not been deployed

No deployments
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