@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\PurchasingRole;
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\PrivateAuditExport;
|
||||
use App\Models\SupplierDocument;
|
||||
use App\Models\User;
|
||||
@@ -46,6 +47,11 @@ afterEach(function () {
|
||||
|
||||
test('private audit creates a verified immutable package and replays without duplicating or changing business facts', function () {
|
||||
$before = DB::table('purchase_orders')->orderBy('id')->get()->toJson();
|
||||
foreach (['supplier_evaluation.approved', 'supplier_improvement.closed', 'supplier_response.decided', 'supplier.bank_viewed',
|
||||
'planning.created', 'order_cancellation.approved', 'warehouse_return.confirmed'] as $action) {
|
||||
AuditLog::query()->create(['tenant_id' => $this->actor->tenant_id, 'user_id' => $this->actor->id, 'action' => $action,
|
||||
'after' => ['evidence' => 'SYNTHETIC-EVENT-PAYLOAD-NOT-EXPORTED'], 'created_at' => now()]);
|
||||
}
|
||||
$input = ['operation_key' => (string) Str::uuid(), 'families' => ['configuration', 'purchasing', 'stock', 'finance'], 'purpose' => 'Synthetic QA audit'];
|
||||
$service = app(PrivateAuditExporter::class);
|
||||
$export = $service->generate($this->actor, $input);
|
||||
@@ -55,6 +61,12 @@ test('private audit creates a verified immutable package and replays without dup
|
||||
try {
|
||||
$manifest = json_decode($zip->getFromName('manifesto.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
expect($manifest['families'])->toHaveCount(4);
|
||||
$events = $zip->getFromName('dados/purchasing/eventos.ndjson');
|
||||
expect($events)->toBeString()->toContain('supplier_evaluation.approved')->toContain('supplier_improvement.closed')->toContain('supplier_response.decided')
|
||||
->toContain('planning.created')->toContain('order_cancellation.approved')
|
||||
->not->toContain('warehouse_return.confirmed')->not->toContain('supplier.bank_viewed')->not->toContain('SYNTHETIC-EVENT-PAYLOAD-NOT-EXPORTED');
|
||||
expect($zip->getFromName('dados/stock/eventos.ndjson'))->toContain('warehouse_return.confirmed')
|
||||
->not->toContain('planning.created')->not->toContain('order_cancellation.approved');
|
||||
foreach ($manifest['datasets'] as $dataset) {
|
||||
if ($dataset['state'] === 'not_installed') {
|
||||
expect($dataset['records'])->toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user