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

This commit is contained in:
2026-11-29 05:28:30 +02:00
parent 1ddabbbdcc
commit 448948a487
137 changed files with 9481 additions and 1926 deletions
+18 -1
View File
@@ -5,6 +5,7 @@ use App\Models\User;
use App\Services\ReceiptWorkflow;
use App\Services\SupplyCoordination;
use App\Services\SupplyPlanning;
use App\Services\WarehouseReservations;
use Illuminate\Support\Facades\DB;
use Inertia\Testing\AssertableInertia as Assert;
@@ -25,11 +26,27 @@ test('availability reuses physical balance without treating planning needs as ph
app(SupplyPlanning::class)->save($f['receiver'], 'policy', supplyInput([], 'approve', $draft));
$movements = DB::table('stock_movements')->count();
$this->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
->component('stock/availability')->where('rows.data.0.physical_milli', 10000)->where('rows.data.0.usable_milli', 10000)
->component('stock/availability')->where('reservationsAvailable', true)->where('rows.data.0.physical_milli', 10000)->where('rows.data.0.usable_milli', 10000)
->where('rows.data.0.planned_milli', 20000)->where('rows.data.0.physical_commitment_milli', 0)->where('rows.data.0.free_milli', 10000)->where('rows.data.0.at_minimum', true));
expect(DB::table('stock_movements')->count())->toBe($movements);
});
test('availability does not infer a free balance when physical reservations are unavailable', function () {
$f = receiptFixture('100.000');
$this->actingAs($f['receiver']);
app(ReceiptWorkflow::class)->confirm($f['receiver'], $f['order'], receiptPayload($f, '10.000'));
$reservations = Mockery::mock(WarehouseReservations::class);
$reservations->shouldReceive('ready')->andReturn(false);
$reservations->shouldNotReceive('committed');
$this->app->instance(WarehouseReservations::class, $reservations);
$movements = DB::table('stock_movements')->count();
$this->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p
->where('reservationsAvailable', false)->where('rows.data.0.physical_milli', 10000)
->where('rows.data.0.usable_milli', 10000)->where('rows.data.0.physical_commitment_milli', null)
->where('rows.data.0.free_milli', null)->where('rows.data.0.at_minimum', false));
expect(DB::table('stock_movements')->count())->toBe($movements);
});
test('availability is tenant scoped and does not disclose planning without permission', function () {
$f = receiptFixture();
$this->actingAs($f['receiver'])->get('/stock/disponibilidade?warehouse_id='.$f['warehouse']->id)->assertOk()->assertInertia(fn (Assert $p) => $p