commit14
This commit is contained in:
@@ -16,6 +16,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
|
||||
require_once __DIR__.'/../Support/QualificationFixture.php';
|
||||
require_once __DIR__.'/../Support/SupplyFixture.php';
|
||||
|
||||
beforeEach(function () {
|
||||
$this->f = qualificationFixture();
|
||||
@@ -51,6 +52,46 @@ test('documentary qualification freezes process criteria without financial decis
|
||||
$this->get('/requisicoes/'.$this->f['r']->id.'/processo')->assertInertia(fn (Assert $page) => $page->where('documents', fn ($documents) => collect($documents)->contains('kind', 'Qualificação documental')));
|
||||
});
|
||||
|
||||
test('formal task documentary resumes only my incomplete analysis and reuses the existing answers', function () {
|
||||
$set = defineDocumentaryQualification($this);
|
||||
$first = recordDocumentaryAssessment($this, $set);
|
||||
$path = '/requisicoes/tarefas?module=purchases&search=documental';
|
||||
$this->get($path)->assertInertia(fn (Assert $page) => $page->where('tasks.total', 1)
|
||||
->where('tasks.data.0.href', $this->url.'?version='.$set->id.'"ation_id='.$this->f['quote']->id.'#qualification-assess'));
|
||||
$this->get($this->url.'?version='.$set->id.'"ation_id='.$this->f['quote']->id)->assertInertia(fn (Assert $page) => $page
|
||||
->where('focusQuotationId', $this->f['quote']->id)->where('canAssess', true)->where('records.0.id', $first->id)
|
||||
->where('records.0.answers.0.evidence', $this->f['assessment']['answers'][0]['evidence']));
|
||||
$this->actingAs($this->f['other_analyst'])->get($path)->assertInertia(fn (Assert $page) => $page->where('tasks.total', 0));
|
||||
$answers = $first->answers;
|
||||
$answers[1] = ['criterion_id' => 2, 'result' => 'not_met', 'evidence' => 'Documento sintético', 'reason' => 'Resultado negativo fundamentado no ensaio.'];
|
||||
recordDocumentaryAssessment($this, $set, ['previous_id' => $first->id, 'answers' => $answers]);
|
||||
$this->get($path)->assertInertia(fn (Assert $page) => $page->where('tasks.total', 0));
|
||||
expect($first->fresh()->answers[1]['result'])->toBe('pending')->and(QualificationAssessment::query()->count())->toBe(2)->and(BudgetEntry::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
test('formal task documentary does not continue an old basis or create new analyst assignments', function () {
|
||||
$set = defineDocumentaryQualification($this);
|
||||
$first = recordDocumentaryAssessment($this, $set);
|
||||
$before = [QualificationAssessment::query()->count(), AuditLog::query()->count()];
|
||||
$this->get('/requisicoes/tarefas?module=purchases&search=documental')->assertOk();
|
||||
expect([QualificationAssessment::query()->count(), AuditLog::query()->count()])->toBe($before);
|
||||
$this->f['quote']->update(['reference' => 'REFERÊNCIA-ALTERADA']);
|
||||
$this->get('/requisicoes/tarefas?module=purchases&search=documental')->assertInertia(fn (Assert $page) => $page->where('tasks.total', 0));
|
||||
$this->get($this->url.'?quotation_id='.$this->f['quote']->id)->assertInertia(fn (Assert $page) => $page->where('isCurrent', false)->where('canAssess', false));
|
||||
$this->post('/qualificacoes/'.$set->id.'/analises', [...$this->f['assessment'], 'previous_id' => $first->id])->assertSessionHasErrors('qualification');
|
||||
$this->getJson($this->url.'?quotation_id=999999')->assertUnprocessable();
|
||||
});
|
||||
|
||||
test('formal task documentary does not let an administrative reading grant authorise another department analysis', function () {
|
||||
$set = defineDocumentaryQualification($this);
|
||||
$department = Department::query()->create(['tenant_id' => $this->f['tenant']->id, 'name' => 'Outro departamento sintético']);
|
||||
$head = User::factory()->create(['tenant_id' => $this->f['tenant']->id, 'department_id' => $department->id]);
|
||||
supplyGrant($head, ['admin', 'department_head']);
|
||||
$this->actingAs($head)->get($this->url)->assertInertia(fn (Assert $page) => $page->where('canAssess', false));
|
||||
$this->post('/qualificacoes/'.$set->id.'/analises', $this->f['assessment'])->assertForbidden();
|
||||
expect(QualificationAssessment::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
test('documentary criteria versions and analyst corrections never overwrite earlier records', function () {
|
||||
$set = defineDocumentaryQualification($this);
|
||||
$first = recordDocumentaryAssessment($this, $set);
|
||||
|
||||
Reference in New Issue
Block a user