Repository navigation
test(e2e): Add SVG upload and delivery spec - #1317
Merged
Merged
Conversation
Cover the SVG Support feature end to end against a real Cloudinary account: - A valid SVG uploads, syncs, gets a Cloudinary attachment URL, and the front end serves it as image/svg+xml with its content intact. - An SVG with an inline <script> and an onload handler still syncs, but the delivered asset has both stripped (fl_sanitize). The spec turns svg_support on for its run and restores the previous value afterwards. It is tagged @serial because it needs real credentials for `wp cloudinary sync`.
The analytics specs flip image_format to webp and image_quality to 80 and leave them changed. With a fixed global format, the first render after sync delivers an SVG as f_webp without fl_sanitize, because Media::get_cloudinary_id() replaces the extension with the global format. CI ran the analytics specs first, so both SVG tests got image/webp. Pin both settings to auto for the spec and restore the previous values afterwards.
utkarshcloudinary
marked this pull request as ready for review
October 13, 2026 10:19
gabrielcld2
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Playwright spec for SVG Support. It checks that a valid SVG uploads, syncs and is delivered from Cloudinary as an SVG, and that an SVG with unsafe content has that content stripped.
Approach
tests/e2e/cloudinary-svg-delivery.spec.js(@serial, needsCLOUDINARY_E2E_URL):beforeAllsetssvg_support=on,image_format=autoandimage_quality=autothrough the settings API.afterAllrestores the previous values. SVG Support is off by default, and WordPress rejects SVG uploads without it. The format and quality are pinned because the analytics specs change them and do not change them back (see the note below).wp cloudinary sync.image/svg+xml, and the attachment has a public ID and a sync log. The RESTsource_urlis ares.cloudinary.com/<cloud_name>/…/*.svgURL. The front-end<img>URL returnsimage/svg+xml, and the body is the original SVG.<script>and anonloadhandler. It still uploads and syncs. The front-end URL (f_svg,…/fl_sanitize) returnsimage/svg+xmlwith no<script>and noon*=attributes.tests/e2e/fixtures/svg-valid.svg,tests/e2e/fixtures/svg-unsafe.svg.sanitizeflag inSVG::add_features(), the unsafe-SVG test failed with "the <script> element should be stripped".Notes
_fields. Without this,missing_image_sizesreads width/height from the metadata, which an SVG does not have before sync. WithWP_DEBUGon, the PHP warning breaks the JSON response.has_public_id()+been_synced(), notis_synced(). Afterwp cloudinary sync,is_synced()returns false for every asset type, JPEG included, because therelationsignature changes on the next request. This is a separate issue and is not specific to SVG.source_urlfor an SVG usesf_auto,q_auto, so Cloudinary serves PNG/WebP at that URL. Only the front-end URL serves SVG. For this reason, the spec checks the delivered content type on the front-end URL only. If the attachment URL must also return SVG, that is a plugin bug.image_formatis a fixed format such aswebp, the first front-end render after sync delivers an SVG asf_webp,q_80withoutfl_sanitize.Media::get_cloudinary_id()replaces the.svgextension with the global format, soSVG::add_features()seesformat=webpand does nothing. The second render is correct. The spec pinsimage_format=autoto test the default path. This bug needs its own fix.QA notes
cp .env.example .envand setCLOUDINARY_E2E_URLto a test account.npm run env:start, ornpx wp-env start --config .wp-env.ci.jsonfor the plain HTTP setup that CI uses.npm run test:e2e:serial -- cloudinary-svg-delivery, or with the CI config:WP_BASE_URL=http://localhost:8889 ./.wp-env/scripts/run-e2e.sh cloudinary-svg-delivery --workers=1.svg_supporton the tests site has the same value after the run as before.