Unit tests
Test the caller-owned session adapter independently:- versioned
sessionStoragekeys include the canonical API environment, merchant, and location; - the cart capability and customer JWT never enter URLs, analytics, or
localStorage; - ETag revisions are retained;
- claim, delete, expiry, and terminal checkout handling clear persisted capability state;
- malformed or old-version records fail closed.
fetch when testing the SDK:
If-Match, and an idempotency key. For CART_CONFLICT, assert the mutation is not replayed automatically and the current cart revision is refreshed.
Checkout tests
Cover every authoritative result:PROCESSINGcontinues bounded polling;CUSTOMER_ACTION_REQUIREDrenders only the returned Stripe action;PAIDrenders the stable order identity and clears persisted cart state after terminal handling;ACCEPTEDrenders the audited pay-at-store order without claiming online settlement;ACTION_REQUIREDrenders the exact recovery action and never falls back to success;- authorization, timeout, and stale-revision errors remain visible.
Receipt tests
Start with a URL containing#receiptToken=.... Assert the app calls history.replaceState immediately, stores the token only for that API environment, merchant, and receipt ID in sessionStorage, and sends it in the receipt header—not in the request URL.
End-to-end sandbox flow
- Fetch published merchant, location, menu, product, distance, order-time, and gratuity data anonymously and verify no customer JWT is attached.
- Create a cart and verify the capability is returned only once for a new cart.
- Mutate the cart and verify revision changes.
- Submit the canonical order and handle its Stripe customer action or activation-lock error.
- Observe nonterminal polling followed by exactly one terminal result.
- Verify rating and receipt access.
- Confirm no secret or capability appears in browser URLs, logs, analytics, or static assets.
Outbound webhook tests
Create an endpoint in the sandbox Business Manager and use Send test. Test events have"test": true in the exact body and Crave-Webhook-Test: true; they are never real orders.
Your receiver test suite should prove that it:
- verifies the timestamped
Crave-Webhook-Signatureagainst raw bytes before parsing JSON; - rejects tampered bodies and timestamps outside the 300-second replay window;
- accepts either valid signature during bounded secret rotation;
- commits each
Crave-Webhook-Idonly once and returns2xxfor duplicates; - returns quickly, then processes asynchronously;
- looks up current Crave state after an ambiguous timeout instead of blindly resubmitting;
- keeps secrets, signatures, customer data, and full response bodies out of logs.
