Files
Investidor-V2/tools/portal-visual-persistence-qa.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

37 lines
2.1 KiB
PHP

<?php
// Read only, guarded QA. Report semantic fields of the explicitly synthetic A/B cases; no credentials/ciphertexts.
use App\Models\SimulationFormDraft;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\DB;
require dirname(__DIR__).'/vendor/autoload.php';
require __DIR__.'/portal-qa-environment.php';
$target = portalQaEnvironment();
$app = require dirname(__DIR__).'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
portalQaAssertTarget($target);
DB::beginTransaction();
DB::statement('SET TRANSACTION READ ONLY');
$directory = storage_path('app/private/investmoz-v2/portal-audit');
$browser = json_decode(file_get_contents($directory.'/investor-ab-chromium-20261010.json'), true, 512, JSON_THROW_ON_ERROR);
$proof = ['captured_at' => gmdate('c'), 'target' => $target, 'read_only' => true, 'active_writes' => 0, 'scenarios' => []];
foreach ($browser['scenarios'] as $name => $entry) {
$draft = SimulationFormDraft::findOrFail($entry['draft_id']);
abort_unless((int) $draft->owner_user_id === 18, 403);
$economic = SimulationFormDraft::decryptSnapshot($draft->economic_snapshot);
$personal = SimulationFormDraft::decryptSnapshot($draft->personal_snapshot);
$proof['scenarios'][$name] = ['id' => $entry['id'], 'draft_id' => $draft->id, 'version' => $draft->version_no,
'economic_keys' => array_keys($economic), 'personal_keys' => array_keys($personal),
'selection' => array_intersect_key($economic, array_flip(['journey_type', 'detail_level', 'purpose', 'preferred_language', 'currency'])),
'project_title' => $economic['project_title'] ?? null, 'summary_length' => strlen($economic['project_summary'] ?? ''),
'labels' => array_intersect_key($economic['selection_labels'] ?? [], array_flip(['journey_type', 'detail_level', 'purpose', 'preferred_language', 'currency']))];
}
DB::rollBack();
$file = $directory.'/visual-persistence-qa.json';
if (is_file($file)) {
copy($file, $directory.'/visual-persistence-qa-'.gmdate('Ymd_His').'.json');
}
file_put_contents($file, json_encode($proof, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
echo json_encode($proof, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL;