@@ -160,13 +160,16 @@ test('tax configuration is versioned tenant scoped and never rewrites existing p
|
||||
});
|
||||
|
||||
test('comparison policy requires valid weights authority and current version without rewriting existing processes', function () {
|
||||
$body = ['version' => 1, 'minimum_proposals' => 2, 'minimum_evaluators' => 1, 'weights' => ['price' => 50, 'quality' => 20, 'delivery' => 10, 'history' => 10, 'payment' => 10], 'reason' => 'Regra comercial aprovada para novos processos.'];
|
||||
$body = ['version' => 1, 'minimum_proposals' => 2, 'minimum_evaluators' => 1, 'urgent_minimum_proposals' => 1, 'weights' => ['price' => 50, 'quality' => 20, 'delivery' => 10, 'history' => 10, 'payment' => 10], 'reason' => 'Regra comercial aprovada para novos processos.'];
|
||||
$this->postJson($this->base.'/comparison', [...$body, 'weights' => [...$body['weights'], 'price' => 49]])->assertUnprocessable();
|
||||
expect($this->f['tenant']->fresh()->comparison_policy)->toBeNull();
|
||||
$this->postJson($this->base.'/comparison', [...$body, 'minimum_evaluators' => 0])->assertUnprocessable();
|
||||
$this->postJson($this->base.'/comparison', [...$body, 'urgent_minimum_proposals' => 0])->assertUnprocessable();
|
||||
$this->postJson($this->base.'/comparison', [...$body, 'urgent_minimum_proposals' => 2])->assertUnprocessable();
|
||||
$this->postJson($this->base.'/comparison', [...$body, 'weights' => [...$body['weights'], 'other' => 0]])->assertUnprocessable();
|
||||
$this->postJson($this->base.'/comparison', $body)->assertRedirect();
|
||||
expect($this->f['tenant']->fresh()->comparison_policy['revision'])->toBe(1)->and($this->f['r']->fresh()->comparison_policy)->toBeNull();
|
||||
expect($this->f['tenant']->fresh()->comparison_policy['urgent_minimum_proposals'])->toBe(1);
|
||||
$this->postJson($this->base.'/comparison', $body)->assertUnprocessable();
|
||||
$this->get($this->base)->assertInertia(fn (Assert $page) => $page->where('comparisonPolicy.minimum_proposals', 2));
|
||||
expect(AuditLog::query()->where('action', 'organization.comparison')->count())->toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user