oportunidades 5
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 14:15:28 +02:00
parent 6ddafc95ba
commit 01405cbf8a
144 changed files with 28903 additions and 1103 deletions
+12 -1
View File
@@ -21,6 +21,7 @@ class OpportunityResourcesTest extends TestCase
{
use RefreshDatabase;
/** @return array{User,Opportunity} */
private function setupDraft(): array
{
Storage::fake('local');
@@ -28,10 +29,15 @@ class OpportunityResourcesTest extends TestCase
$user = User::factory()->create();
config(['portal.managers' => [$user->email]]);
$id = $this->actingAs($user)->postJson('/management/opportunities/drafts', ['creation_key' => (string) Str::uuid(), 'reason' => 'Rascunho de recursos em QA isolada'])->assertCreated()->json('id');
if (! is_int($id)) {
throw new \RuntimeException('O cadastro QA deve devolver um ID inteiro de oportunidade.');
}
return [$user, Opportunity::findOrFail($id)];
}
/** @param array<string,mixed> $payload
* @return array<string,mixed> */
private function payload(Opportunity $opportunity, array $payload = []): array
{
return ['etag' => app(OpportunityManagement::class)->etag($opportunity), 'creation_key' => (string) Str::uuid(), 'payload' => $payload, 'reason' => 'Preparação e conferência em QA isolada'];
@@ -64,6 +70,7 @@ class OpportunityResourcesTest extends TestCase
$life = ['etag' => app(OpportunityManagement::class)->etag($o->fresh()), 'version' => 2, 'action' => 'delete', 'confirm' => true, 'reason' => 'Exclusão lógica de anexo apenas QA'];
$this->postJson('/management/opportunities/'.$o->id.'/resources/documents/'.$r->id.'/lifecycle', $life)->assertOk();
$this->assertSoftDeleted('opportunity_documents', ['id' => $r->id]);
$this->get('/management/opportunities/'.$o->id.'/resources/documents/'.$r->id.'/download')->assertNotFound();
$this->postJson('/management/opportunities/'.$o->id.'/resources/documents/'.$r->id.'/lifecycle', [...$life, 'etag' => app(OpportunityManagement::class)->etag($o->fresh()), 'version' => 3, 'action' => 'restore'])->assertOk();
$this->assertDatabaseHas('opportunity_documents', ['id' => $r->id, 'deleted_at' => null, 'version' => 4]);
$this->assertSame(4, DB::table('audit_events')->where('source_system', 'opportunity-resources')->count());
@@ -122,7 +129,11 @@ class OpportunityResourcesTest extends TestCase
$this->assertSame('pending', $document->malware_scan_status);
$webp = Crypt::decryptString(Storage::disk('local')->get($document->storage_key));
$this->assertStringNotContainsString('EXIF', $webp);
$this->assertSame('image/webp', getimagesizefromstring($webp)['mime']);
$size = getimagesizefromstring($webp);
if ($size === false) {
throw new \RuntimeException('Derivada QA não contém uma imagem válida.');
}
$this->assertSame('image/webp', $size['mime']);
(new ScanDocumentForMalware($document->id))->handle(new CleanScannerFixture);
}
$preview = URL::temporarySignedRoute('management.opportunity-image-preview', now()->addMinutes(10), ['id' => $o->id, 'resourceId' => $image->id, 'documentId' => $payload['derivatives'][0]['document_id']]);