fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+8 -3
View File
@@ -12,10 +12,12 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Inertia\Testing\AssertableInertia;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Tests\Support\AuthenticatesQaActors;
use Tests\TestCase;
class InvestmentWorkspaceTest extends TestCase
{
use AuthenticatesQaActors;
use RefreshDatabase;
private function draft(User $user): string
@@ -63,6 +65,7 @@ class InvestmentWorkspaceTest extends TestCase
$id = $this->draft($user);
$this->postJson('/api/v1/investment/submissions/'.$id.'/submit', $this->payload())->assertOk();
config(['portal.managers' => [$user->email]]);
$this->actingAsWithMfa($user);
$stats = app(DeclaredOriginStatistics::class)->forManager($user);
$this->assertSame([['code' => null, 'name' => 'Não informado', 'count' => 1]], $stats['interests']);
$this->assertSame([], $stats['desk']);
@@ -83,6 +86,7 @@ class InvestmentWorkspaceTest extends TestCase
}
$before = InterestRequest::orderBy('id')->get()->toArray();
config(['portal.managers' => [$user->email]]);
$this->actingAsWithMfa($user);
$this->get('/management/crm/leads?origin=PT')->assertOk()->assertInertia(fn (AssertableInertia $page) => $page
->where('filters.origin', 'PT')->has('originStatistics.interests', 1)
->where('originStatistics.interests.0.code', 'PT')->where('originStatistics.interests.0.count', 1));
@@ -120,6 +124,7 @@ class InvestmentWorkspaceTest extends TestCase
$this->assertDatabaseCount('memberships', 0);
$this->assertDatabaseCount('organizations', 0);
config(['portal.managers' => [$user->email]]);
$this->actingAsWithMfa($user);
$this->get('/management/history')->assertInertia(fn (AssertableInertia $page) => $page
->has('events.data', 3)->where('events.data.0.after_data.values.version', 1));
$this->actingAs(User::factory()->create())->getJson('/api/v1/investment/profile')->assertJsonCount(0, 'companies');
@@ -144,7 +149,7 @@ class InvestmentWorkspaceTest extends TestCase
$this->postJson($url, [...$message, 'body' => 'Outro conteúdo com a mesma chave.'])->assertConflict();
$this->assertDatabaseCount('investment_messages', 1);
$this->assertStringNotContainsString('Mensagem privada', DB::table('investment_messages')->value('body'));
$this->actingAs($manager)->getJson('/api/v1/investment/notifications')->assertJsonPath('unread', 1);
$this->actingAsWithMfa($manager)->getJson('/api/v1/investment/notifications')->assertJsonPath('unread', 1);
$this->postJson($url, ['client_key' => (string) Str::uuid(), 'body' => 'Resposta sintética da equipa.'])->assertOk();
$this->actingAs($owner)->getJson('/api/v1/investment/notifications')->assertJsonPath('unread', 2);
$this->getJson('/api/v1/investment/submissions/'.$id)->assertJsonCount(2, 'messages')->assertJsonPath('messages.1.sender_role', 'support');
@@ -154,7 +159,7 @@ class InvestmentWorkspaceTest extends TestCase
$this->actingAs(User::factory()->create())->postJson($url, $message)->assertNotFound();
$this->postJson('/api/v1/investment/notifications/'.$notification->id.'/read')->assertNotFound();
config(['portal.managers' => []]);
$this->actingAs($manager)->getJson('/api/v1/investment/notifications')->assertJsonCount(0, 'notifications.data');
$this->actingAsWithMfa($manager)->getJson('/api/v1/investment/notifications')->assertJsonCount(0, 'notifications.data');
$this->getJson('/api/v1/investment/submissions/'.$id)->assertNotFound();
}
@@ -183,7 +188,7 @@ class InvestmentWorkspaceTest extends TestCase
$id = $this->draft($owner);
$this->postJson('/api/v1/investment/submissions/'.$id.'/submit', $this->payload())->assertOk();
$interest = InterestRequest::firstOrFail();
$this->actingAs($manager)->patch('/management/interests/'.$interest->id, ['status' => 'in_review'])->assertRedirect();
$this->actingAsWithMfa($manager)->patch('/management/interests/'.$interest->id, ['status' => 'in_review'])->assertRedirect();
$this->patch('/management/interests/'.$interest->id, ['status' => 'in_review'])->assertRedirect();
$this->patchJson('/api/v1/investment/admin/interests/'.$interest->id.'/status', ['status' => 'in_review'])->assertOk()->assertJsonPath('status', 'in_review');
$this->assertDatabaseCount('investment_notifications', 2);