feat(purchase): implement purchase limit enforcement and custom exception handling

This commit is contained in:
2026-08-19 16:43:59 -03:00
parent 8537d2ed0a
commit 5c0b3503b7
15 changed files with 124 additions and 41 deletions

View File

@@ -241,7 +241,15 @@ class CartControllerTest extends TestCase
'cantidad' => 2,
])
->assertUnprocessable()
->assertJsonValidationErrors('cantidad');
->assertJsonValidationErrors('cantidad')
->assertJsonPath('code', 'purchase.limit_exceeded')
->assertJsonPath('catalog_item_id', $item->id)
->assertJsonPath('catalog_item_name', $item->nombre)
->assertJsonPath('maximum_addable_quantity', 1)
->assertJsonPath(
'message',
"Podés agregar hasta 1 unidad más de “{$item->nombre}”.",
);
$this->assertDatabaseHas('carrito_items', [
'catalog_item_id' => $item->id,