Skip to content

test(e2e): Add breakpoints and lazy load spec - #1342

Open
utkarshcloudinary wants to merge 2 commits into
developfrom
test/responsive-breakpoints-lazy-load-e2e
Open

utkarshcloudinary wants to merge 2 commits into
developfrom
test/responsive-breakpoints-lazy-load-e2e

Conversation

@utkarshcloudinary

Copy link
Copy Markdown
Collaborator

Adds an e2e spec for the responsive breakpoints and lazy load delivery settings on a synced image. It also fixes the shared srcsetUrls() helper, which split Cloudinary URLs apart at the commas inside their transformation segment (w_800,h_600,c_scale).

Approach

  • New tests/e2e/cloudinary-breakpoints-lazy-load.spec.js (@serial, real credentials needed for wp cloudinary sync). It uploads the 1200x900 fixture, embeds it in a post, and syncs once in beforeAll.
  • Settings are written through the plugin settings API. They are pinned in each test and restored in afterAll.
  • Server markup is read in a context with JavaScript off, because the lazy load script rewrites src/srcset after load.
  • Breakpoints: max_width=1100, min_width=500, pixel_step=300 must give srcset widths 1200w, 1100w, 800w, 500w. Each breakpoint URL is on Cloudinary and has the matching w_ transformation. Core never makes these widths for this image, so they can only come from the plugin.
  • Breakpoints are only written to srcset on the server when lazy load is off (Responsive_Breakpoints::add_features()), so the srcset test turns lazy load off.
  • Lazy load: checks the SVG placeholder src, data-cloudinary="lazy", data-size, the CLDBind onload, data-public-id, data-delivery, and the CLDLB config with the blur placeholder (e_blur:2000). With JS on, src changes to a Cloudinary URL.
  • Disabled: with breakpoints off, data-responsive and the breakpoint widths are gone. With lazy load off, the placeholder attributes and CLDLB are gone and src is the Cloudinary URL from the server.
  • utils/delivery.js: new parseSrcset() returns { url, descriptor } pairs. srcsetUrls() now uses it.

QA notes

  • npm run test:e2e:serial -- cloudinary-breakpoints-lazy-load
  • npm run test:e2e:serial -- cloudinary-gallery-delivery (uses the changed helper)

Cloudinary transformation segments such as w_800,h_600 contain commas,
so splitting srcset on every comma broke each candidate into pieces.
Parse candidates by their trailing descriptor instead and expose the
descriptor through parseSrcset().
Cover the responsive breakpoints and lazy load delivery settings on a
synced image:

- min/max/step produce the matching srcset width entries
- lazy load renders the SVG placeholder, data attributes and the
  CLDLB loader config with the blur placeholder
- turning either setting off removes its markup

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