feat: Remove 'in_review' status from purchase workflow; implement logging for status changes and update related tests

This commit is contained in:
2026-08-03 17:04:39 -03:00
parent c4b317d5fc
commit 96f26e2e9d
8 changed files with 92 additions and 27 deletions

View File

@@ -472,9 +472,18 @@ class StorePurchaseTest extends TestCase
'status' => Purchase::STATUS_PENDING_PAYMENT,
'payment_method' => 'transfer',
]);
$this->assertDatabaseHas('value_changes', [
'trackable_type' => (new Purchase)->getMorphClass(),
'trackable_id' => $purchaseId,
'attribute' => 'status',
'old_value' => Purchase::STATUS_CREATED,
'new_value' => Purchase::STATUS_PENDING_PAYMENT,
'actor_type' => 'user',
'user_id' => $user->id,
]);
}
public function test_it_submits_a_pending_purchase_for_review_idempotently(): void
public function test_it_keeps_a_submitted_purchase_pending_payment_idempotently(): void
{
$this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
$user = User::factory()->create();
@@ -492,24 +501,24 @@ class StorePurchaseTest extends TestCase
$this->actingAs($user, 'sanctum')
->postJson($url)
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_IN_REVIEW)
->assertJsonPath('data.status', Purchase::STATUS_PENDING_PAYMENT)
->assertJsonPath('data.expires_at', null);
$this->assertDatabaseHas('compras', [
'id' => $purchase->id,
'status' => Purchase::STATUS_IN_REVIEW,
'status' => Purchase::STATUS_PENDING_PAYMENT,
'expires_at' => null,
]);
$this->actingAs($user, 'sanctum')
->postJson($url)
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_IN_REVIEW);
->assertJsonPath('data.status', Purchase::STATUS_PENDING_PAYMENT);
$this->actingAs($user, 'sanctum')
->postJson("/api/tenants/sonder/compras/{$purchase->id}/complete")
->assertOk()
->assertJsonPath('data.status', Purchase::STATUS_IN_REVIEW);
->assertJsonPath('data.status', Purchase::STATUS_PENDING_PAYMENT);
}
public function test_it_rejects_review_for_a_purchase_that_is_not_awaiting_payment(): void