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
@@ -148,6 +148,47 @@ test('conditions use exact amount category and cost centre and current rules do
expect($r->fresh()->status)->toBe('approved');
});
test('explicit RQ01 category conditions combine with native filters and remain frozen through the full approval journey', function () {
$this->plan['levels'] = [$this->plan['levels'][0]];
$this->plan['levels'][0] += ['procurement_categories' => ['office_equipment']];
$this->plan['levels'][0]['categories'] = ['Material'];
$this->plan['levels'][0]['min_amount'] = '116.00';
$this->plan['levels'][0]['cost_center_ids'] = [(string) $this->f['r']->cost_center_id];
$this->body['items'][0] += ['procurement_category' => 'office_equipment', 'category_reason' => 'Artigo sintético de escritório fora do catálogo.'];
$matched = submitConfiguredRequest($this);
expect($matched->steps()->count())->toBe(4)
->and($matched->approval_snapshot['additional_levels']['configured_1']['procurement_categories'])->toBe(['office_equipment']);
$next = $this->body;
$next['operation_key'] = (string) Str::uuid();
$next['items'][0]['procurement_category'] = 'other';
$this->postJson('/requisicoes', $next)->assertRedirect();
$different = Requisition::query()->latest('id')->firstOrFail();
$this->postJson('/requisicoes/'.$different->id.'/submeter', ['operation_key' => (string) Str::uuid(), 'process_version' => 1])->assertRedirect();
expect($different->steps()->count())->toBe(3);
$snapshot = $matched->approval_snapshot;
$this->postJson('/administracao/parametrizacao/approval_levels', [...$this->plan, 'version' => 2, 'enabled' => false])->assertRedirect();
expect($matched->fresh()->approval_snapshot)->toBe($snapshot);
foreach ([$this->head, $this->buyer, $this->financier, $this->approvers[0]] as $actor) {
configuredDecision($this, $actor, $matched);
}
expect($matched->fresh()->status)->toBe('approved');
});
test('RQ01 filtered plans refuse an absent classification schema instead of dropping a required approval', function () {
$this->plan['levels'] = [$this->plan['levels'][0] + ['procurement_categories' => ['office_equipment']]];
$this->postJson('/administracao/parametrizacao/approval_levels', $this->plan)->assertRedirect();
$this->body['items'][0] += ['procurement_category' => 'office_equipment', 'category_reason' => 'Artigo sintético de escritório fora do catálogo.'];
$this->postJson('/requisicoes', $this->body)->assertRedirect();
$request = Requisition::query()->latest('id')->firstOrFail();
$policy = $this->f['tenant']->fresh()->requisition_approval_policy;
DB::getSchemaBuilder()->table('requisition_items', fn ($table) => $table->dropColumn('category_context'));
$this->postJson('/requisicoes/'.$request->id.'/submeter', ['operation_key' => (string) Str::uuid(), 'process_version' => 1])->assertServiceUnavailable();
$this->postJson('/administracao/parametrizacao/approval_levels', [...$this->plan, 'version' => 2])->assertUnprocessable();
expect($request->fresh()->status)->toBe('draft')->and($request->steps()->count())->toBe(0)
->and(DB::table('budget_entries')->where('requisition_id', $request->id)->count())->toBe(0)
->and($this->f['tenant']->fresh()->requisition_approval_policy)->toBe($policy);
});
test('revoked membership and expired maintenance do not approve or expose assigned requests and repeated identity cannot decide two stages', function () {
$r = submitConfiguredRequest($this);
foreach ([$this->head, $this->buyer, $this->financier] as $actor) {