Checkout — Story Report

5 scenarios · 2 passed · 1 failed · 1 skipped · 1 pending

Started
29/05/2024, 17:26:40
Duration
2.40 s
Version
1.4.0
Commit
a1b2c3d

Checkout

src/checkout/checkout.story.test.ts

Checkout caps the loyalty discount at 30%

1.24 sPassed
  1. Givena cart with 3 items totaling "$120.00"120 ms

    Seeded from the standard fixture cart.

  2. Whena loyalty discount of 45% is applied80 ms
    Requested discount
    0.45
    Pricing call
    const total = applyDiscount(cart, { loyalty: 0.45 });
  3. Thenthe discount is capped at 30%40 ms
    Discount tiers
    RequestedAppliedSaving
    20%20%$24.00
    45%30%$36.00

Why this rule exists

Loyalty stacking used to let a few accounts reach negative totals. The cap keeps margins safe — see the pricing policy.

  • regression-guard
  • finance-approved
Pricing policy
Discount pipeline
flowchart LR
  Cart --> Loyalty --> Cap[Cap at 30%] --> Total
cart.png
cart.png
Trace (3 spans, 1.24 s)
  • POST /checkout1.24 s
  • db.cart.load95 ms
  • pricing.applyDiscount80 ms

Checkout is blocked when the card is declined

610 msFailed
  1. Givena customer whose card will be declined90 ms
  2. Whenthey submit the order200 ms
  3. Thenno order is created60 ms
    Gateway response
    {"code":"declined","retriable":false}
Trace (2 spans, 610 ms)
  • POST /checkout610 ms
  • payments.charge410 ms

Gift wrapping is offered above the free-wrap threshold

Skipped
  • checkout
  • wip
  1. Givena cart above the threshold

Skipped until the gift-wrap service ships (SHOP-400).