varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+66
View File
@@ -41,6 +41,23 @@ class PortalManagementTest extends TestCase
$this->getJson('/management/opportunities?page=-1')->assertUnprocessable();
}
public function test_unspecified_geography_has_a_private_review_filter_without_assigning_a_location(): void
{
$this->actingAs($this->manager());
$sector = $this->sector();
$pending = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'GEO-PENDING', 'slug' => 'geo-pending',
'title' => 'Pendência territorial', 'status' => 'published', 'published_at' => now()->subMinute(),
'geography_scope' => 'unspecified', 'primary_territory_id' => null]);
$specific = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'GEO-SPECIFIC', 'slug' => 'geo-specific',
'title' => 'Território específico', 'status' => 'published', 'published_at' => now()->subMinute(), 'geography_scope' => 'specific']);
$this->get('/management/opportunities?geography_scope=unspecified')->assertInertia(fn (AssertableInertia $page) => $page
->where('geographyReviewCount', 1)->where('records.total', 1)
->where('records.data.0.id', $pending->id)->where('records.data.0.geography_scope', 'unspecified'));
$this->assertNull($pending->fresh()->primary_territory_id);
$this->assertSame('specific', $specific->fresh()->geography_scope);
}
protected function beforeRefreshingDatabase(): void
{
$this->assertSame('testing', app()->environment());
@@ -199,6 +216,55 @@ class PortalManagementTest extends TestCase
$this->assertStringNotContainsString('consent@example.invalid', $event->payload);
}
public function test_contact_consent_revocation_blocks_conversion_and_emits_no_duplicate_events(): void
{
$manager = $this->manager();
$interest = InterestRequest::create(['reference' => 'IR-CONTACT-CONSENT', 'integration_id' => (string) Str::uuid(),
'full_name' => 'Pessoa de teste', 'email' => 'contact-consent@example.invalid', 'investor_type' => 'empresa',
'country' => 'MZ', 'sector_interest' => 'Energia', 'message' => 'Pedido de contacto para teste.',
'privacy_consent' => true]);
$consentId = (string) Str::uuid();
DB::table('consents')->insert(['id' => $consentId, 'source_system' => 'portal-intake',
'external_id' => 'test-contact-consent', 'version_no' => 1, 'data_classification' => 'confidential',
'correlation_id' => (string) Str::uuid(), 'subject_ref' => $interest->reference,
'purpose' => 'respond_to_interest', 'status' => 'granted', 'granted_at' => now(),
'interest_request_id' => $interest->id, 'policy_version' => '2026-09-30',
'created_at' => now(), 'updated_at' => now()]);
$this->actingAs($manager)->get('/management/interests/'.$interest->id)
->assertInertia(fn (AssertableInertia $page) => $page
->where('consents.0.purpose', 'respond_to_interest')->where('consents.0.status', 'granted'));
$this->actingAs(User::factory()->create())
->patch('/management/interests/'.$interest->id.'/consent/contact', [
'reason' => 'O titular pediu para cessar o contacto sobre o pedido.',
])->assertForbidden();
$this->actingAs($manager);
$this->patch('/management/interests/'.$interest->id.'/consent/contact', [
'reason' => 'O titular pediu para cessar o contacto sobre o pedido.',
])->assertRedirect();
$this->patch('/management/interests/'.$interest->id.'/consent/contact', [
'reason' => 'O titular pediu para cessar o contacto sobre o pedido.',
])->assertRedirect();
$this->post('/management/crm/convert/'.$interest->id, [
'legal_name' => 'Empresa de teste', 'investor_type' => 'domestic', 'owner_user_id' => $manager->id,
'title' => 'Lead de teste', 'next_action' => 'Rever pedido', 'due_at' => now()->addDay()->toIso8601String(),
])->assertSessionHasErrors('investor_id');
$this->assertDatabaseHas('consents', ['id' => $consentId, 'status' => 'withdrawn']);
$this->assertDatabaseHas('business_workflow_transitions', ['interest_request_id' => $interest->id,
'to_status' => 'received']);
$event = DB::table('outbox_events')->where('event_type', 'InterestConsentWithdrawn')
->where('aggregate_id', $consentId)->first();
$this->assertNotNull($event);
$this->assertStringNotContainsString('contact-consent@example.invalid', $event->payload);
$this->assertStringContainsString('respond_to_interest', $event->payload);
$this->assertSame(1, DB::table('outbox_events')->where('event_type', 'InterestConsentWithdrawn')
->where('aggregate_id', $consentId)->count());
$this->assertSame(1, DB::table('business_workflow_transitions')
->where('interest_request_id', $interest->id)->count());
$this->assertDatabaseCount('leads', 0);
}
public function test_overdue_task_escalation_is_opt_in_and_idempotent(): void
{
$interest = InterestRequest::create(['reference' => 'IR-SLA', 'full_name' => 'Pessoa de teste',