@@ -53,11 +53,41 @@ test('direction release preserves declarations applies to the complete correctio
|
||||
->and(ConflictRelease::query()->count())->toBe(1)
|
||||
->and(AuditLog::query()->where('action', 'conflict.release_authorised')->count())->toBe(1);
|
||||
$this->get('/conflitos/'.$root->id)->assertInertia(fn (Assert $page) => $page->where('canAuthoriseRelease', false)->where('release.declaration_id', $latest->id));
|
||||
$this->get('/conflitos')->assertInertia(fn (Assert $page) => $page->where('releasedRoots', [$root->id])->where('declarations.data.0.has_conflict', true));
|
||||
$this->actingAs($this->owner)->get('/conflitos')->assertForbidden();
|
||||
$this->actingAs($this->admin);
|
||||
$this->post('/conflitos/'.$latest->id.'/levantamento', [...$input, 'reason' => 'Alteração indevida do fundamento após decisão.'])->assertConflict();
|
||||
ConflictDeclaration::query()->create([...$root->only(['tenant_id', 'user_id', 'supplier_id', 'requisition_id', 'has_conflict', 'known_since', 'reason']), 'declared_at' => now()]);
|
||||
expect($guard->hasConflict($this->buyer->id, $this->supplier->id, $this->r->id))->toBeTrue();
|
||||
});
|
||||
|
||||
test('release consultation is limited to the roots on the visible declaration page', function () {
|
||||
config(['conflict-releases.qa_enabled' => true]);
|
||||
for ($index = 0; $index < 16; $index++) {
|
||||
$this->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
}
|
||||
$first = ConflictDeclaration::query()->oldest('id')->firstOrFail();
|
||||
$last = ConflictDeclaration::query()->latest('id')->firstOrFail();
|
||||
$this->actingAs($this->owner)->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
$other = ConflictDeclaration::query()->latest('id')->firstOrFail();
|
||||
$profile = DB::table('organization_profiles')->insertGetId(['tenant_id' => $this->tenant->id, 'name' => 'Compras exclusivamente sintéticas',
|
||||
'permissions' => json_encode(['procurement']), 'version' => 1, 'created_at' => now(), 'updated_at' => now()]);
|
||||
DB::table('organization_memberships')->insert(['tenant_id' => $this->tenant->id, 'user_id' => $this->buyer->id,
|
||||
'profile_id' => $profile, 'maintenance' => false, 'created_at' => now(), 'updated_at' => now()]);
|
||||
configureConflictDirection($this->admin);
|
||||
$this->actingAs($this->admin);
|
||||
foreach ([$first, $last, $other] as $row) {
|
||||
$this->post('/conflitos/'.$row->id.'/levantamento', ['operation_key' => (string) Str::uuid(),
|
||||
'reason' => 'Decisão exclusivamente sintética para conferir a consulta paginada.'])->assertSessionHasNoErrors();
|
||||
}
|
||||
$originals = ConflictDeclaration::query()->orderBy('id')->get()->toJson();
|
||||
$auditCount = AuditLog::query()->count();
|
||||
$this->actingAs($this->buyer)->get('/conflitos')->assertOk()->assertInertia(fn (Assert $page) => $page->has('declarations.data', 15)->where('releasedRoots', [$last->id]));
|
||||
$this->get('/conflitos?page=2')->assertOk()->assertInertia(fn (Assert $page) => $page->has('declarations.data', 1)->where('releasedRoots', [$first->id]));
|
||||
expect(ConflictDeclaration::query()->orderBy('id')->get()->toJson())->toBe($originals)
|
||||
->and(AuditLog::query()->count())->toBe($auditCount);
|
||||
});
|
||||
|
||||
test('direction authority is current scoped and never inherited from admin or finance', function () {
|
||||
config(['conflict-releases.qa_enabled' => true]);
|
||||
$this->post('/conflitos', personalConflict($this->supplier->id))->assertSessionHasNoErrors();
|
||||
|
||||
Reference in New Issue
Block a user