commit melhorias compras5
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-22 19:39:09 +02:00
parent 36dcfdf00c
commit db1615fac1
79 changed files with 4082 additions and 120 deletions
@@ -10,6 +10,17 @@ use Inertia\Testing\AssertableInertia as Assert;
require_once __DIR__.'/../Support/ReceiptFixture.php';
afterEach(function () {
if ($this->committedDraftReportFixture ?? false) {
if (! app()->environment('testing') || DB::getDriverName() !== 'pgsql'
|| ! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', DB::connection()->getDatabaseName()) || DB::transactionLevel() !== 0) {
throw new LogicException('Draft report cleanup requires the disposable PostgreSQL database.');
}
DB::statement('DROP SCHEMA public CASCADE');
DB::statement('CREATE SCHEMA public');
}
});
beforeEach(function () {
$this->f = receiptFixture();
$this->actingAs($this->f['issuer']);
@@ -38,6 +49,13 @@ test('incomplete draft persists unknown values without invented amounts and cann
$this->get('/requisicoes/'.$r->id.'/editar')->assertInertia(fn (Assert $page) => $page->where('incompleteDraftsAvailable', true)->where('requisition.draft_input.values.justification', 'Ini'));
$this->get('/requisicoes/'.$r->id)->assertOk()->assertInertia(fn (Assert $page) => $page->where('requisition.total_minor', null));
$this->get('/requisicoes/'.$r->id.'/processo')->assertOk();
if (DB::getDriverName() === 'pgsql') {
if (! preg_match('/^compras_receipts_test_[a-f0-9]{12}$/D', DB::connection()->getDatabaseName()) || DB::transactionLevel() !== 1) {
throw new LogicException('Commit only the isolated synthetic draft before the native read-only report transaction.');
}
DB::commit();
$this->committedDraftReportFixture = true;
}
$this->get('/relatorios?search='.$r->number)->assertOk()->assertInertia(fn (Assert $page) => $page->where('records.data.0.total_minor', null));
$this->postJson('/requisicoes/'.$r->id.'/submeter')->assertUnprocessable();
expect($r->fresh()->status)->toBe('draft')->and(DB::table('budget_entries')->count())->toBe($entries);