QA
Mid~15 minAPI testingSession cookiesMoney assertionsError handling

API: cart maths, coupons and stock rules

App: SwagShop, a practice e-commerce demo store (Saucedemo-style). Login: standard_user, locked_out_user, problem_user, performance_glitch_user / secret_sauce. REST API: tests call it as /api/... through the request fixture or page.request; GET /api lists every endpoint ↗.

Next scenario →

Interview scenario

"The cart service owns the money maths, so test it at the API: add two products with quantities, check the subtotal and 8% tax, apply SAVE10 and check the discount, prove an out-of-stock product is refused, then change a quantity and remove a line."

Acceptance criteria

  1. Log in through the API, then POST /api/cart/items for productId 4 with qty 2 and productId 0 (qty 1). Assert count 3 and subtotal 45.97.
  2. Apply coupon SAVE10 (POST /api/cart/coupon) and assert discount 4.6 and total 44.68 (tax is 8% after the discount).
  3. Adding productId 10 (out of stock) returns 409.
  4. PATCH /api/cart/items/4 with qty 1 and DELETE /api/cart/items/0, then assert the cart count is 1.

🔒 This lab is part of Pro

Pro unlocks the live editor, the scenario checks and the reference solutions in Playwright and Selenium Java for all 37 labs, plus every interview answer. One payment of ₹1,299, lifetime access. Already on a lower tier? Upgrade for the difference.