Skip to content

test(e2e): Add global image transformations spec - #1343

Open
utkarshcloudinary wants to merge 1 commit into
developfrom
test/global-transformations-e2e
Open

utkarshcloudinary wants to merge 1 commit into
developfrom
test/global-transformations-e2e

Conversation

@utkarshcloudinary

Copy link
Copy Markdown
Collaborator

Adds an e2e spec that checks the global image format and quality settings reach the delivery URL of a newly synced image.

Approach

  • New tests/e2e/cloudinary-global-transformations.spec.js (@serial, real credentials needed for wp cloudinary sync). Each test uploads and syncs a fresh attachment after the settings are saved, so the image is synced with those settings.
  • Lazy load and breakpoints are off and image_freeform is empty, so the server writes the final delivery URL into src. All changed settings are restored in afterAll.
  • The test reads the f_ and q_ params from the transformation segments of the URL, not from a plain substring match.
  • Non-default (webp, 60): the URL has f_webp and q_60.
  • Revert to default: the default is auto, and Media::default_image_transformations() still writes it into the URL. So the revert test checks that the explicit values are replaced by f_auto / q_auto.
  • Not set (none) is the only value that removes the params. A third test checks that the URL then has no f_ or q_.

QA notes

  • npm run test:e2e:serial -- cloudinary-global-transformations

Check that the global image format and quality settings reach the
delivery URL of a newly synced image:

- non-default values (webp, 60) give f_webp and q_60
- reverting to the defaults gives f_auto and q_auto
- "Not set" removes the f_ and q_ parameters

@gabrielcld2 gabrielcld2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@utkarshcloudinary this is looking good! Just a few suggestions

requestUtils,
} ) => {
// Set the non-default values first, so this test proves the
// revert and does not only read the defaults.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: The revert test doesn't prove a revert. It saves webp/60, immediately saves auto/auto, then uploads a new image. Nothing is rendered while webp is set, so the first save has no visible effect. The test passes even when the plugin ignores the settings entirely.

*
* Each call gets a fresh attachment, so the image is synced with the
* settings that are active at that time. The timestamp in the filename
* gives a fresh public ID, so no CDN cache from an earlier run applies.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion (non-blocking): The per-test upload and sync is probably unnecessary. The JSDoc says each test needs a fresh attachment "so the image is synced with those settings". But f_/q_ are applied when the page is rendered, not when the image is synced.

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.

3 participants