Skip to content

Read observable pages and the session cart JSON - #4318

Draft
Ji-One1 wants to merge 1 commit into
jb/storefront-e2e-v2-10-browser-lifecyclefrom
jb/storefront-e2e-v2-11-page-cart-readiness
Draft

Ji-One1 wants to merge 1 commit into
jb/storefront-e2e-v2-10-browser-lifecyclefrom
jb/storefront-e2e-v2-11-page-cart-readiness

Conversation

@Ji-One1

@Ji-One1 Ji-One1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

The buyer needs an observable page, and the assertion needs the active cart from that same browser session. These helpers provide both without using page text as cart proof.

What this changes

  • Add a shared Playwright/Stagehand readiness predicate: DOMContentLoaded has started, and the body is visible with child elements. Page acquisition and polling share a 15-second deadline and support abort.
  • Read one GET <root>cart.js in the page with the session's own cookies. Hydrogen rewrites this AJAX endpoint to upstream cart.json.
  • Use the same-origin window.Shopify.routes.root, or the supplied storefront base path. Refuse unsupported roots and redirects; request no cache and bound the fetch, including the body, to five seconds.
  • Copy only variant IDs, line quantities, and item count out of the page. Normalize variant IDs to ProductVariant GIDs and report failures through the five CartReadError codes defined earlier.

Developer impact

Internal tooling only; no published Hydrogen changes or changeset. No cookie is read, parsed, or set by the reader. No cart ID or Storefront API cart query is needed.

Risk

Readiness does not prove network idle, stable UI, or iframe registration. A custom storefront might serve a cart different from its UI cart at this endpoint; the helper cannot detect that. Buyer integration and CLI wiring are separate.

Stack: 10/15. Previous: #4317. Next: #4319.

@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from d5219d3 to 5e226d3 Compare November 5, 2026 16:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from e0a3546 to 551f4af Compare November 5, 2026 16:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 5e226d3 to 98de12f Compare November 5, 2026 18:42
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch 2 times, most recently from 332bfb8 to 74e1f21 Compare November 6, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 98de12f to 576904c Compare November 6, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 74e1f21 to 8f61b9c Compare November 6, 2026 01:36
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch 2 times, most recently from 734359c to 900b21b Compare November 6, 2026 01:45
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 8f61b9c to 2caa429 Compare November 6, 2026 01:45
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 900b21b to 5e3daad Compare November 6, 2026 14:27
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 2caa429 to 5fe5a5f Compare November 6, 2026 14:27
@Ji-One1 Ji-One1 changed the title Read observable pages and current-cart references Read observable pages and the session cart JSON Nov 6, 2026
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 5e3daad to 9d1ffc1 Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 5fe5a5f to 4303447 Compare November 6, 2026 15:08
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 4303447 to 6fe9f2b Compare November 6, 2026 16:20
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch 2 times, most recently from 5f3c634 to 731ec61 Compare November 6, 2026 19:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch 2 times, most recently from 66f4b1d to ecf1fa3 Compare November 6, 2026 20:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 731ec61 to 5bb49ea Compare November 6, 2026 20:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from ecf1fa3 to e1081d6 Compare November 6, 2026 20:32
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch 2 times, most recently from 77a741f to 9e8c131 Compare November 6, 2026 20:59
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from e1081d6 to 835920f Compare November 6, 2026 20:59
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 9e8c131 to d75930e Compare November 9, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 835920f to 88cc2ae Compare November 9, 2026 00:01
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from d75930e to b5f4e39 Compare November 9, 2026 00:37
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 88cc2ae to c05ee80 Compare November 9, 2026 00:37
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from b5f4e39 to 6ecdbef Compare November 9, 2026 04:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from c05ee80 to 27b327d Compare November 9, 2026 04:23
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-10-browser-lifecycle branch from 6ecdbef to d2b9663 Compare November 9, 2026 06:55
@Ji-One1
Ji-One1 force-pushed the jb/storefront-e2e-v2-11-page-cart-readiness branch from 27b327d to bb59481 Compare November 9, 2026 06:55

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.

1 participant