---
title: "Verify signing in merges guest and account carts according to policy"
description: "Prepare distinct guest and account carts, sign in through the shopping flow, and verify item preservation, duplicate handling, quantities, and final ownership."
canonical_url: "https://vostride.com/agent-library/shopping-cart/guest-login-cart-merge.md"
md_url: "https://vostride.com/agent-library/shopping-cart/guest-login-cart-merge.md"
content_kind: "recipe"
topic: "shopping-cart"
---

# Verify signing in merges guest and account carts according to policy

Prepare distinct guest and account carts, sign in through the shopping flow, and verify item preservation, duplicate handling, quantities, and final ownership.

## Risk

Cart merging can lose guest items or multiply a SKU present in both carts. The application merge policy must specify whether quantities combine, replace, or require a choice; the test records that decision before inspecting the final cart.

## Fixtures

- A test account with a saved cart containing product Amber and one shared SKU.
- A guest cart containing product Blue and the same shared SKU at a different quantity.
- A documented cart merge rule and hooks reading premerge and final account cart identities and lines.

## Steps

1. As a guest, open the cart and verify Blue and the shared SKU with their known quantities.
2. Sign in through the cart-supported flow using the fixture account and verify the correct account identity.
3. If the application asks how to merge carts, choose the documented fixture option and verify the visible explanation.
4. Inspect the resulting cart and verify Amber, Blue, and the shared SKU quantities match the predetermined merge expectation.
5. Reload and inspect cart state through the hook; verify one account-owned active cart, the expected lines and total, and the documented handling of the former guest cart.

## Expected results

- The merge preserves or replaces items exactly according to the declared policy.
- The shared SKU quantity is deterministic and independently checked.
- The final active cart belongs to the signed-in account and persists after reload.

## False-pass traps

- Counting cart rows alone can miss incorrect quantities on a merged duplicate SKU.
- Starting with an empty account cart avoids the conflict that makes this scenario valuable.

## Cleanup

- Clear both fixture cart identities and revoke the test account session.

## 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)
