fix: keep internal agribusiness delivery notes out of portal presentation
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-23 11:22:39 +02:00
parent 4ad1bf402b
commit 165c2f6171
9 changed files with 81 additions and 15 deletions
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace Tests\Unit;
use App\Models\Opportunity;
use App\Services\CorridorAgribusinessOpportunities;
use App\Services\OpportunityPublicText;
use Tests\TestCase;
class OpportunityPublicTextTest extends TestCase
{
public function test_public_serialization_omits_generated_internal_notes_without_changing_original_or_other_content(): void
{
$source = ['source' => 'investimentos nos corredores.docx', 'source_sha256' => CorridorAgribusinessOpportunities::SOURCE_HASH, 'corridor' => 'Corredor de Maputo'];
$body = 'Produção de arroz.'."\n\nFonte: ".$source['source'].'; SHA-256 '.$source['source_sha256']."\n\n".CorridorAgribusinessOpportunities::LIMITATIONS;
$record = new Opportunity(['description' => $body]);
$record->workflow_context = ['corridor_agribusiness' => $source];
$public = $record->toArray();
$this->assertStringContainsString('Produção de arroz.', $public['description']);
$this->assertStringNotContainsString('SHA-256', $public['description']);
$this->assertStringNotContainsString('.docx', $public['description']);
$this->assertSame($body, $record->description);
$this->assertArrayNotHasKey('workflow_context', $public);
$other = new Opportunity(['description' => $body]);
$this->assertSame($body, OpportunityPublicText::description($other, $body));
$this->assertSame('Texto revisto pela equipa.', OpportunityPublicText::description($record, 'Texto revisto pela equipa.'));
}
}