23 lines
959 B
PHP
23 lines
959 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use Livewire\Livewire;
|
||
|
|
use Modules\Payment\Filament\Widgets\PaymentFailureRateWidget;
|
||
|
|
use Modules\Payment\Models\Payment;
|
||
|
|
|
||
|
|
test('it computes the failure rate among resolved payments in the last 30 days', function () {
|
||
|
|
$this->actingAs(User::factory()->create());
|
||
|
|
|
||
|
|
Payment::factory()->completed()->create(['initiated_at' => today()]);
|
||
|
|
Payment::factory()->completed()->create(['initiated_at' => today()]);
|
||
|
|
Payment::factory()->completed()->create(['initiated_at' => today()]);
|
||
|
|
Payment::factory()->failed()->create(['initiated_at' => today()]);
|
||
|
|
Payment::factory()->create(['initiated_at' => today()]); // pending, excluded from resolved total
|
||
|
|
Payment::factory()->failed()->create(['initiated_at' => today()->subDays(40)]); // outside window
|
||
|
|
|
||
|
|
Livewire::test(PaymentFailureRateWidget::class)
|
||
|
|
->assertOk()
|
||
|
|
->assertSee('25%')
|
||
|
|
->assertSee('1 failed of 4 resolved (last 30 days)');
|
||
|
|
});
|