commit compras1 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 07:11:35 +02:00
parent d58b75c87a
commit eb32c74c56
202 changed files with 17463 additions and 1526 deletions
+15
View File
@@ -3,6 +3,7 @@
use App\Enums\PurchasingRole;
use App\Models\StockMovement;
use App\Models\StockOperation;
use App\Models\User;
use App\Models\Warehouse;
use App\Services\ReceiptWorkflow;
use App\Services\RequisitionWorkflow;
@@ -30,6 +31,20 @@ test('issues are exact, idempotent and cannot make stock negative', function ()
expect((int) StockMovement::query()->sum('quantity_milli'))->toBe(400)->and(StockOperation::query()->count())->toBe(1);
});
test('stock preparation consultations keep native visibility private history and source quantities intact', function () {
$before = StockMovement::query()->get()->toArray();
$operations = StockOperation::query()->get()->toArray();
foreach (['/stock', '/stock/operacoes'] as $url) {
$response = $this->get($url)->assertOk()->assertViewHas('page', fn (array $page) => $page['encryptHistory'] === true);
expect($response->headers->get('Cache-Control'))->toContain('private')->toContain('no-store');
}
$requester = User::factory()->create(['tenant_id' => $this->f['tenant']->id, 'department_id' => $this->f['department']->id, 'purchasing_role' => PurchasingRole::Requester]);
$this->actingAs($requester)->get('/stock')->assertForbidden();
$this->get('/stock/operacoes')->assertForbidden();
expect(StockMovement::query()->get()->toArray())->toBe($before)
->and(StockOperation::query()->get()->toArray())->toBe($operations);
});
test('transfer creates exactly two opposite ledger entries and rejects repeated references', function () {
$this->p['kind'] = 'transfer';
$this->p['destination_warehouse_id'] = $this->dest->id;