refactor(cart): own checkout item editing
This commit is contained in:
@@ -568,14 +568,12 @@ class StorePurchaseTest extends TestCase
|
||||
$itemId = $purchase->cart->items->firstOrFail()->id;
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->patchJson("/api/tenants/sonder/compras/{$purchase->id}/items/{$itemId}", [
|
||||
'quantity' => 4,
|
||||
->patchJson("/api/tenants/sonder/checkout-carts/{$purchase->cart_id}/items/{$itemId}", [
|
||||
'cantidad' => 4,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.items.0.quantity', 4)
|
||||
->assertJsonPath('data.items.0.line_total', '200.00')
|
||||
->assertJsonPath('data.subtotal', '200.00')
|
||||
->assertJsonPath('data.total', '200.00');
|
||||
->assertJsonPath('data.items.0.cantidad', 4)
|
||||
->assertJsonPath('data.subtotal', '200.00');
|
||||
|
||||
$this->assertDatabaseHas('inventories', [
|
||||
'id' => $variant->inventory_id,
|
||||
@@ -589,12 +587,17 @@ class StorePurchaseTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->patchJson("/api/tenants/sonder/compras/{$purchase->id}/items/{$itemId}", [
|
||||
'quantity' => 1,
|
||||
->patchJson("/api/tenants/sonder/checkout-carts/{$purchase->cart_id}/items/{$itemId}", [
|
||||
'cantidad' => 1,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.items.0.quantity', 1)
|
||||
->assertJsonPath('data.total', '50.00');
|
||||
->assertJsonPath('data.items.0.cantidad', 1)
|
||||
->assertJsonPath('data.subtotal', '50.00');
|
||||
|
||||
$this->assertDatabaseHas('compras', [
|
||||
'id' => $purchase->id,
|
||||
'total' => '50.00',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('inventories', [
|
||||
'id' => $variant->inventory_id,
|
||||
@@ -612,11 +615,11 @@ class StorePurchaseTest extends TestCase
|
||||
$itemId = $purchase->cart->items->firstOrFail()->id;
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->patchJson("/api/tenants/sonder/compras/{$purchase->id}/items/{$itemId}", [
|
||||
'quantity' => 4,
|
||||
->patchJson("/api/tenants/sonder/checkout-carts/{$purchase->cart_id}/items/{$itemId}", [
|
||||
'cantidad' => 4,
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors('quantity');
|
||||
->assertJsonValidationErrors('cantidad');
|
||||
|
||||
$this->assertDatabaseHas('carrito_items', [
|
||||
'id' => $itemId,
|
||||
@@ -644,10 +647,9 @@ class StorePurchaseTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->postJson("/api/tenants/sonder/compras/{$purchase->id}/edit-items")
|
||||
->postJson("/api/tenants/sonder/checkout-carts/{$purchase->cart_id}/edit")
|
||||
->assertOk()
|
||||
->assertJsonPath('data.status', Purchase::STATUS_CREATED)
|
||||
->assertJsonPath('data.payment_method', null);
|
||||
->assertJsonPath('data.status', 'checkout');
|
||||
|
||||
$this->assertDatabaseHas('compras', [
|
||||
'id' => $purchase->id,
|
||||
|
||||
Reference in New Issue
Block a user