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
+16 -2
View File
@@ -102,14 +102,28 @@ test('insufficient evidence remains explicit and needs correction before indepen
expect(AuditLog::query()->where('action', 'supplier_evaluation.return')->sole()->after['review_reason'])->toContain('Completar');
});
test('approved report keeps its reviewer identity when the selected history page is empty', function () {
$evaluation = submittedEvaluation($this);
$this->actingAs($this->reviewer)->post('/fornecedores/avaliacoes/'.$evaluation->id.'/approve', [
'version' => 2, 'reason' => 'Revisão independente com identidade preservada no relatório.',
])->assertRedirect();
$before = DB::table('audit_logs')->orderBy('id')->get()->toJson();
$this->actingAs($this->f['issuer'])->get('/fornecedores/avaliacoes/'.$evaluation->id.'/relatorio?history_page=99')
->assertOk()->assertInertia(fn (Assert $p) => $p->where('reportOnly', true)
->where('evaluation.reviewed_by', $this->reviewer->id)
->where('people.'.$this->reviewer->id, $this->reviewer->name)->has('history.data', 0));
expect(DB::table('audit_logs')->orderBy('id')->get()->toJson())->toBe($before);
});
test('approved evaluation is immutable and a new revision preserves the prior approved report', function () {
$e = submittedEvaluation($this);
$url = '/fornecedores/avaliacoes/'.$e->id;
$this->actingAs($this->reviewer)->post($url.'/approve', ['version' => 2, 'reason' => 'Evidências e âmbito conferidos independentemente.'])->assertRedirect();
$e->refresh();
$this->actingAs($this->f['issuer'])->put($url, ['version' => 3, 'payload' => $this->data['payload']])->assertConflict();
expect(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->update(['status' => 'draft']))->toThrow(QueryException::class);
expect(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->delete())->toThrow(QueryException::class);
expect(fn () => DB::transaction(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->update(['status' => 'draft'])))->toThrow(QueryException::class);
expect(fn () => DB::transaction(fn () => DB::table('supplier_evaluations')->where('id', $e->id)->delete()))->toThrow(QueryException::class);
expect($e->fresh()->status)->toBe('approved')->and(SupplierEvaluation::query()->whereKey($e->id)->count())->toBe(1);
$this->post($url.'/rever', ['version' => 3])->assertRedirect();
$child = SupplierEvaluation::query()->where('previous_id', $e->id)->sole();
$this->post($url.'/rever', ['version' => 3])->assertRedirect('/fornecedores/avaliacoes/'.$child->id);