test(stock): cover propagated reservation expiration
This commit is contained in:
@@ -227,7 +227,7 @@ class CartControllerTest extends TestCase
|
||||
$this->assertDatabaseHas('carrito_items', ['id' => $cartItemId]);
|
||||
$this->assertDatabaseHas('carritos', [
|
||||
'id' => $cartId,
|
||||
'status' => 'active',
|
||||
'status' => Cart::STATUS_EXPIRED,
|
||||
'current_stock_reservation_id' => $reservationId,
|
||||
'deleted_at' => null,
|
||||
]);
|
||||
@@ -241,6 +241,11 @@ class CartControllerTest extends TestCase
|
||||
'quantity' => 2,
|
||||
]);
|
||||
|
||||
$this->getJson('/api/tenants/acme/cart')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.id', $cartId)
|
||||
->assertJsonPath('data.status', Cart::STATUS_EXPIRED);
|
||||
|
||||
$this->postJson('/api/tenants/acme/cart/items', [
|
||||
'catalog_item_id' => $item->id,
|
||||
'cantidad' => 1,
|
||||
@@ -262,12 +267,12 @@ class CartControllerTest extends TestCase
|
||||
$this->assertNotSame($cartId, $newCartId);
|
||||
$this->assertDatabaseHas('carritos', [
|
||||
'id' => $cartId,
|
||||
'status' => 'abandoned',
|
||||
'status' => Cart::STATUS_ABANDONED,
|
||||
'current_stock_reservation_id' => $reservationId,
|
||||
]);
|
||||
$this->assertDatabaseHas('carritos', [
|
||||
'id' => $newCartId,
|
||||
'status' => 'active',
|
||||
'status' => Cart::STATUS_ACTIVE,
|
||||
'current_stock_reservation_id' => null,
|
||||
]);
|
||||
|
||||
|
||||
@@ -702,6 +702,16 @@ class StorePurchaseTest extends TestCase
|
||||
$this->assertPurchaseReservation($purchase->id, $variant->inventory_id, 3, 'expired');
|
||||
$this->assertSame(1, $activeCart->items()->count());
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->postJson('/api/tenants/sonder/compras/start-checkout', [
|
||||
'cart_id' => $activeCart->id,
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertExactJson([
|
||||
'code' => 'stock_reservation.expired',
|
||||
'message' => __('api.cart.reservation_expired'),
|
||||
]);
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->postJson("/api/tenants/sonder/compras/{$purchase->id}/cancel")
|
||||
->assertUnprocessable()
|
||||
|
||||
Reference in New Issue
Block a user