add tests
This commit is contained in:
1 parent
aa23eec392
commit
0bbb4571bd
5 files changed
+300
No files matched your search
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('guests are redirected to the login page', function () {
|
||||
@@ -31,3 +34,67 @@ test('search input is wired to component', function () {
|
||||
->set('search', 'Test Firma')
|
||||
->assertSet('search', 'Test Firma');
|
||||
});
|
||||
|
||||
test('overview aggregates open alert metrics', function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$acme = Company::factory()->create(['legal_name' => 'Acme Investigations AG']);
|
||||
$globex = Company::factory()->create(['legal_name' => 'Globex Risk GmbH']);
|
||||
|
||||
Transaction::factory()->for($acme)->requiresReview()->status(Transaction::STATUS_TRUE_POSITIVE)->create([
|
||||
'amount' => 120000,
|
||||
'risk_score' => 90,
|
||||
'executed_at' => Carbon::parse('2024-01-10 09:00:00'),
|
||||
'signals' => ['Sanktionsliste'],
|
||||
]);
|
||||
|
||||
Transaction::factory()->for($globex)->requiresReview()->status(Transaction::STATUS_FALSE_POSITIVE)->create([
|
||||
'amount' => 45000,
|
||||
'risk_score' => 60,
|
||||
'executed_at' => Carbon::parse('2024-01-11 12:30:00'),
|
||||
]);
|
||||
|
||||
Transaction::factory()->for($acme)->requiresReview(false)->status(Transaction::STATUS_FALSE_POSITIVE)->create([
|
||||
'amount' => 8000,
|
||||
'risk_score' => 20,
|
||||
'executed_at' => Carbon::parse('2024-01-09 08:15:00'),
|
||||
]);
|
||||
|
||||
$component = Volt::test('company-search');
|
||||
|
||||
$overview = $component->get('overview');
|
||||
|
||||
expect($overview['companies'])->toBe(2)
|
||||
->and($overview['open_alerts'])->toBe(2)
|
||||
->and($overview['open_volume'])->toEqualWithDelta(165000, 0.001)
|
||||
->and($overview['avg_risk'])->toEqualWithDelta(75, 0.001)
|
||||
->and($overview['watchlist_hits'])->toBe(1)
|
||||
->and($overview['automation_share'])->toBe(68);
|
||||
});
|
||||
|
||||
test('search filters companies by ticker and name', function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$match = Company::factory()->create([
|
||||
'name' => 'Fintrac Labs',
|
||||
'legal_name' => 'Fintrac Labs AG',
|
||||
'ticker' => 'FTR',
|
||||
]);
|
||||
|
||||
$other = Company::factory()->create([
|
||||
'name' => 'Velocity Partners',
|
||||
'ticker' => 'VLP',
|
||||
]);
|
||||
|
||||
Transaction::factory()->for($match)->requiresReview()->create(['amount' => 250000]);
|
||||
Transaction::factory()->for($other)->requiresReview()->create(['amount' => 125000]);
|
||||
|
||||
$component = Volt::test('company-search');
|
||||
|
||||
$component->set('search', 'FTR');
|
||||
|
||||
$companies = $component->get('companies');
|
||||
|
||||
expect($companies)->toHaveCount(1)
|
||||
->and($companies->first()->id)->toBe($match->id);
|
||||
});
|
||||
Reference in new issue
Block a user