Bug hunt · Intermediate

Find the 8 bugs in this shopping cart

Most cart bugs hide in the numbers. Check every total against the rules with a calculator, try the boundaries, then compare your list with the answer key. No real payment happens here.

Business rules

  1. Prices in the cart match the product list.
  2. Quantity is 1 to 10 per item.
  3. Line total = price × quantity.
  4. Coupon SAVE10 takes 10% off the subtotal, once per order.
  5. HST of 13% is charged on the subtotal after the discount.
  6. Shipping is $5.99, and free when the subtotal after the discount is $50.00 or more.
  7. The cart badge shows the total number of items.
  8. An empty cart cannot be checked out.

Products

🛒 0
  • Wireless mouse$25.00
  • USB-C cable$12.50
  • Notebook$10.00
  • Desk lamp$40.00

Your cart

ProductPriceQtyTotalRemove

Your cart is empty.

Subtotal
$0.00
Discount
−$0.00
HST (13%)
$0.00
Shipping
$5.99
Total
$5.99

Answer key

Tip: write the expected totals in a spreadsheet first, then compare them with the screen.

Show the 8 planted bugs
  1. USB-C cable price changes in the cart. It is listed at $12.50 but charged at $12.05.
  2. Quantity accepts 0 and negative numbers. A quantity of -2 gives a negative line total and lowers the order total.
  3. Quantity accepts more than 10. Up to 99 is allowed, although the limit is 10 per item.
  4. Coupon can be applied again and again. Each click on Apply adds another 10% off.
  5. Tax is charged before the discount. HST is 13% of the subtotal, not of the subtotal after the discount.
  6. Free shipping misses exactly $50.00. Two mice ($50.00) still pay $5.99 shipping. The code checks "more than 50", not "50 or more".
  7. Cart badge counts products, not items. Three notebooks show a badge of 1 instead of 3.
  8. An empty cart can be checked out. Checkout with nothing in the cart places an order for the $5.99 shipping fee.

Want to automate these checks? Every element has a data-testid. Then try theautomation playground.