Repository navigation
test(e2e): Add global image transformations spec - #1343
Conversation
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
left a comment
There was a problem hiding this comment.
@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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good catch, fixed in 2a331a6. The test now renders with webp/60 and checks f_webp/q_60 first, then reverts to auto/auto and checks f_auto/q_auto on the same image. If the plugin ignored the settings, the first check fails.
| * | ||
| * 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agreed, done in 2a331a6. The spec now uploads and syncs one image in beforeAll, and each test only changes the settings and reloads the page. CI confirms it: all 3 tests pass on the same synced image, so f_/q_ are applied at render time.
The revert test saved webp/60 and then auto/auto before any render, so it passed even if the plugin ignored the settings. Render and check webp/60 first, then revert and check f_auto/q_auto on the same image. f_ and q_ are added at render time, not at sync time, so upload and sync one image in beforeAll instead of one per test. Record each ID as soon as it exists so a partial setup is still cleaned up.
Adds an e2e spec that checks the global image format and quality settings reach the delivery URL of a newly synced image.
Approach
tests/e2e/cloudinary-global-transformations.spec.js(@serial, real credentials needed forwp cloudinary sync). Each test uploads and syncs a fresh attachment after the settings are saved, so the image is synced with those settings.image_freeformis empty, so the server writes the final delivery URL intosrc. All changed settings are restored inafterAll.f_andq_params from the transformation segments of the URL, not from a plain substring match.webp,60): the URL hasf_webpandq_60.auto, andMedia::default_image_transformations()still writes it into the URL. So the revert test checks that the explicit values are replaced byf_auto/q_auto.Not set(none) is the only value that removes the params. A third test checks that the URL then has nof_orq_.QA notes
npm run test:e2e:serial -- cloudinary-global-transformations