diff --git a/tests/Feature/Cart/CartControllerTest.php b/tests/Feature/Cart/CartControllerTest.php index 89c14ef..ba17157 100644 --- a/tests/Feature/Cart/CartControllerTest.php +++ b/tests/Feature/Cart/CartControllerTest.php @@ -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, ]); diff --git a/tests/Feature/Purchase/StorePurchaseTest.php b/tests/Feature/Purchase/StorePurchaseTest.php index 019cf9d..054221d 100644 --- a/tests/Feature/Purchase/StorePurchaseTest.php +++ b/tests/Feature/Purchase/StorePurchaseTest.php @@ -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()