feat(qa): consolidate eleven financial report tables pending private visual acceptance
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\VirtualDesk;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InvestorIntegralReportTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_private_report_snapshots_are_preserved_in_the_exact_result_version_without_exposing_them_in_events(): void
|
||||
{
|
||||
$identity = DB::selectOne('select current_database() as name, inet_server_port() as port');
|
||||
$this->assertStringEndsWith('_test', $identity->name);
|
||||
$this->assertSame(55441, (int) $identity->port);
|
||||
$this->withoutVite();
|
||||
Http::fake();
|
||||
$owner = User::factory()->create();
|
||||
config(['investor-path.enabled' => true, 'portal.managers' => [$owner->email], 'suitecrm.enabled' => false, 'investmoz_ai.enabled' => false]);
|
||||
$this->actingAs($owner);
|
||||
if (! DB::table('desk_service_versions')->where('code', 'project-preparation')->exists()) {
|
||||
$this->postJson('/management/balcao/servicos', ['code' => 'project-preparation', 'confirm' => true])->assertCreated();
|
||||
}
|
||||
$case = $this->postJson('/investimentos', ['title' => 'QA synthetic report transport', 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
|
||||
// Transport contract only: no invented financial amounts or calculated results.
|
||||
$economic = [
|
||||
'purpose' => 'simulate_only',
|
||||
'financial_tools_snapshot' => json_encode(['version' => 1, 'data' => []], JSON_THROW_ON_ERROR),
|
||||
'business_plan_snapshot' => json_encode(['version' => 17, 'plan' => ['fixture' => 'synthetic transport only']], JSON_THROW_ON_ERROR),
|
||||
'project_team_snapshot' => json_encode([['competency' => 'QA role', 'state' => 'unknown', 'action' => '', 'estimated_cost' => '', 'due_date' => '']], JSON_THROW_ON_ERROR),
|
||||
'project_execution_snapshot' => json_encode([['title' => 'QA milestone', 'due_date' => '', 'status' => 'planned', 'planned_amount' => '', 'actual_amount' => '']], JSON_THROW_ON_ERROR),
|
||||
];
|
||||
$draft = $this->postJson('/api/v1/simulation-drafts', ['context' => $case, 'personal_snapshot' => [], 'economic_snapshot' => $economic], ['Idempotency-Key' => (string) Str::uuid()])->assertCreated()->json('data.id');
|
||||
$view = $this->getJson('/investimentos/'.$case)->assertOk()->json();
|
||||
$request = ['version' => $view['case']['version'], 'draft_id' => $draft, 'draft_version' => 1];
|
||||
$result = $this->postJson('/investimentos/'.$case.'/resultados', $request)->assertOk()->json('result');
|
||||
foreach (['business_plan_snapshot', 'project_team_snapshot', 'project_execution_snapshot'] as $field) {
|
||||
$this->assertSame($economic[$field], $result['preparation_snapshot'][$field]);
|
||||
}
|
||||
$this->postJson('/investimentos/'.$case.'/resultados', $request)->assertOk()->assertJsonPath('result.id', $result['id']);
|
||||
$this->flushSession();
|
||||
$this->actingAs($owner)->getJson('/investimentos/'.$case)->assertOk()->assertJsonPath('results.0.preparation_snapshot', $result['preparation_snapshot']);
|
||||
$event = app(VirtualDesk::class)->decode(DB::table('desk_events')->where('case_id', $case)->where('action', 'tool_evidence_returned')->value('payload'));
|
||||
foreach (['business_plan_snapshot', 'project_team_snapshot', 'project_execution_snapshot'] as $field) {
|
||||
$this->assertArrayNotHasKey($field, $event['preparation_snapshot']);
|
||||
}
|
||||
$this->actingAs(User::factory()->create())->getJson('/investimentos/'.$case)->assertForbidden();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user