@@ -8,6 +8,7 @@ use App\Models\User;
|
||||
use App\Services\AiPreparationPlan;
|
||||
use App\Services\PeopleAccess;
|
||||
use App\Services\PeopleClarifications;
|
||||
use App\Services\PeopleContractHandoff;
|
||||
use App\Services\PeopleEvidenceBrief;
|
||||
use App\Services\PeopleHiring;
|
||||
use App\Services\PeopleOperationalInsights;
|
||||
@@ -18,9 +19,53 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
require_once __DIR__.'/../Support/AiPlanFixture.php';
|
||||
|
||||
test('people dossier block reuses approved selection and draft without changing decisions or contract status', function (string $kind) {
|
||||
$record = hiringAssessment($this, $kind);
|
||||
$application = DB::table('people_applications')->sole();
|
||||
hiringCommand($this, $this->reviewer, $record, 'evaluate', ['application_id' => $application->id, 'answers' => [
|
||||
['score' => 8, 'evidence' => 'Competências fictícias verificadas.'], ['score' => 8, 'evidence' => 'Experiência fictícia verificada.']]])->assertRedirect();
|
||||
hiringCommand($this, $this->preparer, $record, 'select', ['application_id' => $application->id])->assertRedirect();
|
||||
hiringCommand($this, $this->approver, $record, 'confirm', ['outcome' => 'approved'])->assertRedirect();
|
||||
hiringCommand($this, $this->preparer, $record, 'contract', ['reference' => 'MINUTA-DOSSIER', 'starts_on' => today()->addWeek()->toDateString(), 'terms' => 'Minuta fictícia para preparação, sem assinatura.'])->assertRedirect();
|
||||
$before = [];
|
||||
foreach (['people_processes', 'people_applications', 'people_reviews', 'people_process_access', 'audit_logs'] as $table) {
|
||||
$before[$table] = DB::table($table)->orderBy('id')->get()->toArray();
|
||||
}
|
||||
$this->actingAs($this->preparer)->getJson('/pessoas/'.$record->id.'/dossier.json')->assertOk()
|
||||
->assertHeader('Cache-Control', 'max-age=0, no-store, private')->assertHeader('X-Content-Type-Options', 'nosniff')
|
||||
->assertJsonPath('schema', 'sgc.people.process-dossier.v1')->assertJsonPath('effect', 'preparation_only')
|
||||
->assertJsonPath('process.status', 'contract_draft')->assertJsonPath('process.contract.status', 'draft')
|
||||
->assertJsonPath('process.contract.reference', 'MINUTA-DOSSIER')->assertJsonPath('process.selected_application_id', $application->id)
|
||||
->assertJsonMissingPath('process.creation_hash')->assertJsonMissingPath('process.tenant_id');
|
||||
$this->getJson('/pessoas/'.$record->id.'/dossier.json')->assertOk();
|
||||
foreach ($before as $table => $rows) {
|
||||
expect(DB::table($table)->orderBy('id')->get()->toArray())->toEqual($rows);
|
||||
}
|
||||
expect(fn () => app(PeopleContractHandoff::class)->envelope($record->fresh()))->toThrow(HttpException::class);
|
||||
})->with(['service', 'staff']);
|
||||
|
||||
test('people dossier block shares page redactions and rejects expired or foreign access', function () {
|
||||
$this->body['annex'] = ['fields' => ['financial' => 'DOSSIER-FINANCIAL-SECRET'], 'requirements' => []];
|
||||
$record = hiringAssessment($this);
|
||||
$application = DB::table('people_applications')->sole();
|
||||
hiringCommand($this, $this->reviewer, $record, 'evaluate', ['application_id' => $application->id, 'answers' => [
|
||||
['score' => 8, 'evidence' => 'DOSSIER-INTERVIEW-SECRET', 'evidence_type' => 'verified'], ['score' => 8, 'evidence' => 'Experiência fictícia documentada.', 'evidence_type' => 'verified']]])->assertRedirect();
|
||||
hiringCommand($this, $this->preparer, $record, 'select', ['application_id' => $application->id])->assertRedirect();
|
||||
$this->actingAs($this->approver)->getJson('/pessoas/'.$record->id.'/dossier.json')->assertOk()
|
||||
->assertDontSee('DOSSIER-FINANCIAL-SECRET')->assertDontSee('DOSSIER-INTERVIEW-SECRET')
|
||||
->assertJsonMissingPath('process.rules.annex.fields.financial')->assertJsonMissingPath('process.selection.rules.annex.fields.financial')
|
||||
->assertJsonCount(0, 'candidates.0.reviews')->assertJsonCount(0, 'process.selection.rows.0.reviews')->assertJsonPath('process.contract', null);
|
||||
DB::table('people_process_access')->where('user_id', $this->approver->id)->update(['expires_at' => now()->subMinute()]);
|
||||
$this->getJson('/pessoas/'.$record->id.'/dossier.json')->assertForbidden();
|
||||
$foreign = Tenant::query()->create(['name' => 'Outra empresa fictícia']);
|
||||
$user = User::factory()->create(['tenant_id' => $foreign->id, 'purchasing_role' => PurchasingRole::Admin]);
|
||||
$this->actingAs($user)->getJson('/pessoas/'.$record->id.'/dossier.json')->assertNotFound();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->tenant = Tenant::query()->create(['name' => 'Empresa de contratação fictícia']);
|
||||
foreach (['preparer', 'reviewer', 'approver'] as $key) {
|
||||
|
||||
Reference in New Issue
Block a user