---
title: "Verify cart quantity controls enforce the available-stock cap"
description: "Attempt to exceed a controlled product stock limit and verify visible feedback, persisted quantity, totals, and the behavior after stock becomes available."
canonical_url: "https://vostride.com/agent-library/shopping-cart/stock-cap-quantity.md"
md_url: "https://vostride.com/agent-library/shopping-cart/stock-cap-quantity.md"
content_kind: "recipe"
topic: "shopping-cart"
---

# Verify cart quantity controls enforce the available-stock cap

Attempt to exceed a controlled product stock limit and verify visible feedback, persisted quantity, totals, and the behavior after stock becomes available.

## Risk

Quantity inputs may enforce limits differently from increment buttons. A valid cart must not silently retain an impossible quantity when backordering is disabled, and recovery should become possible when the underlying stock fixture changes.

## Fixtures

- A sandbox product with exactly three available units and backordering disabled.
- A test-owned cart containing two units and a documented stock-reservation policy.
- Hooks for available stock, cart quantity, and reservations plus independent totals for accepted quantities.

## Steps

1. Open the cart and verify quantity two, available-stock messaging if shown, and the expected subtotal.
2. Increase to three and verify the allowed quantity and recalculated total persist.
3. Attempt quantity four using the visible quantity entry or increment control and verify the documented limit message or capped input.
4. Reload and inspect the cart hook; verify stored quantity and reservations do not exceed the allowed stock under the stated policy.
5. Increase fixture stock to five, refresh the cart, and verify quantity four can now be accepted with the correct new total.

## Expected results

- The application rejects or caps quantities above available stock when backorders are disabled.
- Stored cart quantity and totals agree with the accepted visible quantity.
- A genuine stock increase allows the formerly blocked quantity.

## False-pass traps

- A disabled increment button can coexist with a text field accepting an excessive quantity.
- Available stock and reserved stock are different values; the fixture must follow the application reservation contract.

## Cleanup

- Clear the cart, release reservations, and restore the original fixture stock.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa hooks](/docs/agent-qa/guides/hooks.md)
- [agent-qa auth state](/docs/agent-qa/guides/auth-state.md)

- [Shopping cart QA recipes](/agent-library/shopping-cart.md)
- [Software factory QA library](/agent-library.md)
