@@ -52,6 +52,22 @@ class InvestorGuidanceTest extends TestCase
|
||||
return $this->actingAs($this->manager)->postJson('/management/balcao/servicos', ['code' => 'project-preparation', 'confirm' => true])->assertCreated()->json('id');
|
||||
}
|
||||
|
||||
public function test_desk_declared_origin_is_recovered_and_invalid_country_preserves_draft(): void
|
||||
{
|
||||
$case = $this->dossier();
|
||||
$service = $this->service();
|
||||
$id = $this->actingAs($this->investor)->postJson('/balcao-virtual/dossiers/'.$case.'/pedidos', ['service_version_id' => $service, 'client_key' => (string) Str::uuid()])->assertCreated()->json('id');
|
||||
$url = '/balcao-virtual/pedidos/'.$id;
|
||||
$this->getJson($url)->assertOk()->assertJsonMissingPath('request.payload.declared_origin_country_code');
|
||||
$this->putJson($url, ['version' => 1, 'payload' => ['title' => 'Preparação QA', 'declared_origin_country_code' => 'PT']])->assertOk();
|
||||
$this->actingAs(User::factory()->create())->getJson($url)->assertForbidden();
|
||||
$this->actingAs($this->investor)->getJson($url)->assertOk()->assertJsonPath('request.payload.declared_origin_country_code', 'PT')->assertJsonPath('request.status', 'draft');
|
||||
$this->putJson($url, ['version' => 2, 'payload' => ['title' => 'Preparação QA', 'declared_origin_country_code' => 'ZZ']])->assertUnprocessable()->assertJsonValidationErrors('payload.declared_origin_country_code');
|
||||
$this->getJson($url)->assertJsonPath('request.payload.declared_origin_country_code', 'PT')->assertJsonPath('request.version', 2);
|
||||
$this->assertDatabaseCount('interest_requests', 0);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_panel_creation_redirect_confirms_persistence_and_never_submits_a_request(): void
|
||||
{
|
||||
$payload = ['title' => 'Dossier de teste QA do painel', 'client_key' => (string) Str::uuid(), 'reuse_consent' => true];
|
||||
@@ -76,9 +92,11 @@ class InvestorGuidanceTest extends TestCase
|
||||
$this->actingAs($this->manager)->postJson('/balcao-virtual/pedidos/'.$requestId.'/mensagens', ['body' => 'Resposta original do responsável.', 'client_key' => (string) Str::uuid()])->assertOk();
|
||||
config(['portal.managers' => []]);
|
||||
$this->actingAs($this->investor)->getJson('/balcao-virtual/pedidos/'.$requestId)->assertOk()->assertJsonPath('messages.0.kind', 'responsible_response')->assertJsonPath('messages.0.name', $this->manager->name);
|
||||
DB::table('desk_messages')->insert(['id' => (string) Str::uuid(), 'request_id' => $requestId, 'actor_id' => $this->investor->id,
|
||||
$historicalId = (string) Str::uuid();
|
||||
DB::table('desk_messages')->insert(['id' => $historicalId, 'request_id' => $requestId, 'actor_id' => $this->investor->id,
|
||||
'client_key' => (string) Str::uuid(), 'body' => Crypt::encryptString('Mensagem histórica sem tipo original.'), 'created_at' => now()->addSecond()]);
|
||||
$this->getJson('/balcao-virtual/pedidos/'.$requestId)->assertJsonPath('messages.1.kind', 'historical_unclassified');
|
||||
$messages = $this->getJson('/balcao-virtual/pedidos/'.$requestId)->assertOk()->json('messages');
|
||||
$this->assertSame('historical_unclassified', collect($messages)->firstWhere('id', $historicalId)['kind']);
|
||||
$this->assertDatabaseCount('desk_messages', 2);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
@@ -320,7 +338,7 @@ class InvestorGuidanceTest extends TestCase
|
||||
$this->mock(VirtualDesk::class)->shouldReceive('installed')->andReturn(false);
|
||||
$this->actingAs($this->investor)->getJson('/management/balcao-install')->assertForbidden();
|
||||
$view = $this->actingAs($this->manager)->getJson('/management/balcao-install')->assertOk()
|
||||
->assertJsonPath('target.database', 'investmoz_v2_20261008_test')->assertJsonPath('backupVerified', false)
|
||||
->assertJsonPath('target.database', DB::connection()->getDatabaseName())->assertJsonPath('backupVerified', false)
|
||||
->assertJsonStructure(['pendingMigrations', 'databaseReady', 'scanner', 'rollback', 'compatibilityVerified'])->json();
|
||||
$before = DB::table('migrations')->count();
|
||||
$this->postJson('/management/balcao-install', ['hash' => $view['hash'], 'confirm' => true])->assertStatus(422);
|
||||
|
||||
Reference in New Issue
Block a user