describe('Order Flow', () => {
test('successful order creation', async () => {
const cart = await createCart(locationId);
await addItemToCart(locationId, cart.id, testProduct, 1);
const validatedCart = await validateCart(locationId, cart.id, testCustomer);
expect(validatedCart.isValid).toBe(true);
const paymentIntent = await createPaymentIntent(locationId, cart.id);
expect(paymentIntent.client_secret).toBeDefined();
// Simulate successful payment
const order = await simulateSuccessfulPayment(paymentIntent.id);
expect(order.status).toBe('pending');
});
test('cart validation failure', async () => {
const cart = await createCart(locationId);
// Add out of stock item
await expect(validateCart(locationId, cart.id, testCustomer))
.rejects.toThrow('Item is out of stock');
});
});