E-Commerce QA

E-Commerce Edge Case Testing: Catching Cart and Checkout Bugs Automatically

Cross-tab desync, promo code stacking, race conditions during checkout. E-commerce applications have a unique class of edge cases that only surface under real-world conditions. Here is how to find them before your customers do.

0

Generates standard Playwright files you can inspect, modify, and run in any CI pipeline.

Assrt SDK

1. The E-Commerce Edge Case Taxonomy

E-commerce applications are uniquely vulnerable to edge cases because they combine state management, real-time inventory, payment processing, and user sessions into a single flow. A standard CRUD application might have dozens of edge cases. An e-commerce checkout flow has hundreds, and each one can cost real money when it fails.

The edge cases fall into several categories. State synchronization issues occur when the cart, inventory, or pricing data becomes inconsistent across tabs, devices, or server requests. Business logic edge cases involve promo codes, discounts, tax calculations, and shipping rules interacting in unexpected ways. Timing issues include race conditions during checkout, inventory reservation conflicts, and payment timeout handling.

What makes these particularly dangerous is that they rarely appear in standard test plans. A typical QA team tests the happy path (add item, go to cart, checkout, pay) and maybe a few error scenarios (invalid card, out of stock). The edge cases that cause the most revenue loss are the ones nobody thought to test because they require specific combinations of actions that seem unlikely but happen daily at scale.

2. Cross-Tab and Cross-Device Cart Desync

One of the most common e-commerce bugs occurs when a user has your site open in multiple tabs or on multiple devices. They add an item in one tab, then open the cart in another tab. Depending on your cart implementation (client-side state, session storage, server-side cart, or a hybrid), the second tab may show a stale cart, a merged cart, or an empty cart.

Testing this manually is tedious. You need to open two browser tabs, perform actions in a specific sequence, and verify the state in both tabs after each action. With Playwright, this becomes straightforward because you can create multiple browser contexts or pages within a single test and orchestrate actions across them. The challenge is knowing which sequences to test.

The dangerous sequences are: add to cart in Tab A then refresh Tab B; start checkout in Tab A then modify cart in Tab B; complete payment in Tab A while Tab B still shows the old cart; and log out in Tab A while Tab B is mid-checkout. Each of these should result in a defined, safe behavior. In practice, many e-commerce sites handle some of these correctly and others not at all.

Try Assrt for free

Open-source AI testing framework. No signup required.

Get Started

3. Promo Codes, Coupons, and Discount Stacking

Promotional pricing is a rich source of edge cases because discounts interact with each other in combinatorial ways. A simple system with a percentage discount, a flat discount, a free shipping threshold, and a buy-one-get-one offer already has dozens of possible combinations. Add loyalty points, referral credits, and employee discounts, and the combinations become unmanageable without automated testing.

Common bugs include: applying a promo code, removing the qualifying item, and keeping the discount; stacking multiple percentage discounts to achieve negative totals; applying a free shipping code after a shipping-inclusive promo, resulting in a double discount; and using a promo code on a pre-sale or clearance item that should be excluded. Each of these has caused real financial losses at real companies.

The testing strategy for promo codes should be combinatorial. Generate a matrix of discount types, application orders, and cart compositions, then verify that the total is correct for each combination. Playwright tests can automate this by programmatically applying and removing promo codes, modifying cart contents, and asserting on the displayed total. This is the kind of systematic testing that humans find mind-numbing but automation handles effortlessly.

4. Race Conditions in Checkout and Inventory

Race conditions in e-commerce checkout are the bugs that keep engineering managers awake at night. The classic scenario: two users add the last item to their carts simultaneously. Both see it as available. Both click "buy." One of them needs to get an error, but the timing of inventory checks, payment processing, and order creation determines which one. If the system is not designed carefully, both orders succeed and you have oversold.

Testing race conditions requires running multiple browser sessions in parallel, which Playwright supports natively. You can create two browser contexts, navigate both to the same product page, and trigger the checkout flow simultaneously. The test asserts that exactly one checkout succeeds and the other receives an appropriate error message.

Other timing-related edge cases include: clicking the payment button twice before the first request completes (double charge), navigating away during payment processing (orphaned transaction), and the session expiring mid-checkout (lost cart). Each of these needs an explicit test because the default behavior of most frameworks is undefined for these scenarios.

5. Automating Edge Case Discovery with Crawl-Based Tools

The fundamental challenge with e-commerce edge cases is that you cannot test what you have not imagined. Manual test plans are limited by the creativity and experience of the person writing them. Crawl-based test discovery tools address this by systematically exploring your application and identifying all interactive paths, including ones the team never considered.

Tools like Assrt crawl your e-commerce site, discovering product pages, cart interactions, filter combinations, and checkout steps. They generate Playwright tests for each discovered flow. While these auto-generated tests cover the happy path by default, they provide a foundation that you can extend with edge case scenarios. Having a test for every discovered flow means you know when any change breaks something, even flows you did not know existed.

For the specific edge cases discussed above, combine crawl-based discovery with targeted test augmentation. Use the discovered tests as a starting point, then add multi-tab scenarios, promo code combinations, and concurrent checkout tests on top of them. This hybrid approach gives you broad coverage from automation and deep coverage from human expertise, which is exactly what e-commerce applications need.

The cost of not testing e-commerce edge cases is measured in lost revenue, customer trust, and support tickets. Automated test discovery makes it practical to maintain coverage across the hundreds of paths that a modern e-commerce application contains, turning edge case testing from an occasional manual effort into a continuous automated process.

Ready to automate your testing?

Assrt discovers test scenarios, writes Playwright tests from plain English, and self-heals when your UI changes.

$npm install @assrt/sdk