test(stock): cover propagated reservation expiration
This commit is contained in:
@@ -668,7 +668,7 @@ class StorePurchaseTest extends TestCase
|
||||
$this->assertSame(3, $remaining);
|
||||
}
|
||||
|
||||
public function test_it_expires_the_purchase_without_mutating_the_active_cart(): void
|
||||
public function test_it_expires_the_purchase_and_preserves_the_expired_cart_items(): void
|
||||
{
|
||||
$this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
|
||||
$user = User::factory()->create();
|
||||
@@ -694,13 +694,24 @@ class StorePurchaseTest extends TestCase
|
||||
$this->assertDatabaseHas('carritos', [
|
||||
'id' => $activeCart->id,
|
||||
'user_id' => $user->id,
|
||||
'status' => 'active',
|
||||
'status' => Cart::STATUS_EXPIRED,
|
||||
'current_purchase_id' => null,
|
||||
'current_stock_reservation_id' => $purchase->stock_reservation_id,
|
||||
'deleted_at' => null,
|
||||
]);
|
||||
$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()
|
||||
@@ -1024,7 +1035,7 @@ class StorePurchaseTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_it_expires_an_abandoned_purchase_without_mutating_its_active_cart(): void
|
||||
public function test_it_expires_a_purchase_and_its_associated_cart(): void
|
||||
{
|
||||
$this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
|
||||
$user = User::factory()->create();
|
||||
@@ -1066,7 +1077,9 @@ class StorePurchaseTest extends TestCase
|
||||
$this->assertDatabaseHas('carritos', [
|
||||
'id' => $activeCart->id,
|
||||
'user_id' => $user->id,
|
||||
'status' => 'active',
|
||||
'status' => Cart::STATUS_EXPIRED,
|
||||
'current_purchase_id' => null,
|
||||
'current_stock_reservation_id' => $purchase->stock_reservation_id,
|
||||
'deleted_at' => null,
|
||||
]);
|
||||
$this->assertSame(1, $activeCart->items()->count());
|
||||
|
||||
Reference in New Issue
Block a user