Criar Hotel: a actividade escolhida no dossier mantém-se ao longo do percurso
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
Uma oportunidade, sector, parque ou território acrescentado depois só propõe outra actividade; o sector e a actividade do dossier deixam de ser trocados ou apagados sem o investidor o pedir. A pré-visualização mostra «conserva … ; a fonte propõe …» e há uma opção explícita para mudar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Sector;
|
||||
use App\Models\User;
|
||||
use App\Services\InvestmentZones;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
@@ -100,4 +101,34 @@ class InvestmentContextContinuityTest extends TestCase
|
||||
$this->postJson('/investimentos/'.$id.'/contexto/previa', ['version' => $view['case']['version'], 'selection' => [], 'declarations' => ['project_title' => 'Título revisto']])
|
||||
->assertOk()->assertJsonPath('dependency_changed', false)->assertJsonPath('review_steps', []);
|
||||
}
|
||||
|
||||
public function test_the_primary_activity_is_kept_until_the_investor_explicitly_changes_it(): void
|
||||
{
|
||||
// Mapa de erros, "Criar Hotel": a hotel dossier is never moved to another activity by a later reference.
|
||||
$owner = User::factory()->create();
|
||||
$id = $this->dossier($owner, 'Criar Hotel');
|
||||
// Synthetic sectors, rolled back with the transaction; never catalogue data.
|
||||
[$tourism, $agro] = array_map(fn (string $name) => Sector::forceCreate(['name' => 'SINTÉTICO QA '.$name, 'slug' => 'sintetico-qa-'.Str::lower(Str::random(12)), 'is_active' => true]), ['Hotelaria', 'Agronegócio']);
|
||||
$apply = function (array $selection, array $replace = []) use ($id): array {
|
||||
$view = $this->getJson('/investimentos/'.$id.'/contexto')->assertOk()->json();
|
||||
$body = ['version' => $view['case']['version'], 'selection' => $selection, 'replace_fields' => $replace];
|
||||
$plan = $this->postJson('/investimentos/'.$id.'/contexto/previa', $body)->assertOk()->json();
|
||||
$this->postJson('/investimentos/'.$id.'/contexto/confirmar', [...$body, 'preview_hash' => $plan['preview_hash'], 'operation_key' => (string) Str::uuid(), 'confirm' => true])->assertOk();
|
||||
|
||||
return $plan;
|
||||
};
|
||||
$apply(['sector' => 'sector:'.$tourism->id]);
|
||||
$this->getJson('/investimentos/'.$id.'/contexto')->assertJsonPath('context.fields.sector_id', (string) $tourism->id);
|
||||
|
||||
$plan = $apply(['sector' => 'sector:'.$agro->id]);
|
||||
$this->assertSame((string) $tourism->id, $plan['fields']['sector_id']);
|
||||
$this->assertContains(['field' => 'sector', 'value' => $tourism->name, 'proposed' => $agro->name], $plan['maintained']);
|
||||
$this->getJson('/investimentos/'.$id.'/contexto')->assertJsonPath('context.fields.sector', $tourism->name);
|
||||
|
||||
$apply(['sector' => null]);
|
||||
$this->getJson('/investimentos/'.$id.'/contexto')->assertJsonPath('context.fields.sector_id', (string) $tourism->id);
|
||||
|
||||
$apply(['sector' => 'sector:'.$agro->id], ['sector_id', 'sector']);
|
||||
$this->getJson('/investimentos/'.$id.'/contexto')->assertJsonPath('context.fields.sector_id', (string) $agro->id)->assertJsonPath('context.fields.sector', $agro->name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user