Adapt land status to saved investment land need
This commit is contained in:
@@ -30,6 +30,39 @@ class InvestmentCorridorContextTest extends TestCase
|
||||
$entry=collect(app(CorridorAgribusinessOpportunities::class)->entries())->firstWhere('corridor',config('investment_corridors.'.$corridor.'.name'));
|
||||
return Opportunity::where('management_creation_key',$entry['key'])->firstOrFail();
|
||||
}
|
||||
public function test_land_status_uses_the_real_decision_preserves_inactive_values_and_allows_incomplete_drafts(): void
|
||||
{
|
||||
$id=$this->postJson('/investimentos',['title'=>'QA situação do terreno','client_key'=>(string)Str::uuid(),'reuse_consent'=>true])->assertCreated()->json('id');
|
||||
$setNeed=function(string $need) use($id): array {
|
||||
$version=$this->getJson('/investimentos/'.$id.'/contexto')->json('case.version');
|
||||
$this->postJson('/investimentos/'.$id.'/aplicabilidade',['version'=>$version,'land_needed'=>$need,'external_funding'=>'unknown','viability'=>'unknown','reason'=>'Cenário QA '.$need])->assertOk();
|
||||
return $this->getJson('/investimentos/'.$id.'/contexto')->assertOk()->json();
|
||||
};
|
||||
$view=$setNeed('yes');
|
||||
$body=['context'=>$id,'personal_snapshot'=>[],'economic_snapshot'=>['purpose'=>'simulate_only','context_applicability_snapshot'=>$view['prefill']['simulator']['context_applicability_snapshot'],'land_status'=>'duat','selection_labels'=>['land_status'=>'DUAT']]];
|
||||
$created=$this->postJson('/api/v1/simulation-drafts',$body,['Idempotency-Key'=>(string)Str::uuid()])->assertCreated();
|
||||
$draft=$created->json('data.id');$etag=$created->headers->get('ETag');
|
||||
foreach(['no','unknown'] as $need){
|
||||
$view=$setNeed($need);
|
||||
$this->assertSame($need,json_decode($view['prefill']['simulator']['context_applicability_snapshot'],true)['land_preparation']['need']);
|
||||
$update=$this->putJson('/api/v1/simulation-drafts/'.$draft,['personal_snapshot'=>[],'economic_snapshot'=>['purpose'=>'simulate_only','context_applicability_snapshot'=>$body['economic_snapshot']['context_applicability_snapshot']]],['If-Match'=>$etag])->assertOk();
|
||||
$recovered=$this->getJson('/api/v1/simulation-drafts/'.$draft.'?context='.$id)->assertOk();
|
||||
// Omitting context cannot bypass the real dossier decision. Hidden values are retained.
|
||||
$this->assertSame('duat',$recovered->json('data.economic_snapshot.land_status'));
|
||||
$this->assertSame('DUAT',$recovered->json('data.economic_snapshot.selection_labels.land_status'));
|
||||
$this->assertSame($need,json_decode($recovered->json('data.economic_snapshot.context_applicability_snapshot'),true)['land_preparation']['need']);
|
||||
$etag=$update->headers->get('ETag');
|
||||
}
|
||||
$setNeed('yes');
|
||||
$this->flushSession();$this->actingAs($this->investor);
|
||||
$this->getJson('/api/v1/simulation-drafts/'.$draft.'?context='.$id)->assertOk()->assertJsonPath('data.economic_snapshot.land_status','duat');
|
||||
$updated=$this->putJson('/api/v1/simulation-drafts/'.$draft,[...$body,'economic_snapshot'=>['purpose'=>'simulate_only','land_status'=>'leased']],['If-Match'=>$etag])->assertOk();
|
||||
$recovered=$this->getJson('/api/v1/simulation-drafts/'.$draft.'?context='.$id)->assertOk()->assertJsonPath('data.economic_snapshot.land_status','leased');
|
||||
$this->assertSame('yes',json_decode($recovered->json('data.economic_snapshot.context_applicability_snapshot'),true)['land_preparation']['need']);
|
||||
$this->putJson('/api/v1/simulation-drafts/'.$draft,[...$body,'economic_snapshot'=>['purpose'=>'simulate_only','land_status'=>'invalid']],['If-Match'=>$updated->headers->get('ETag')])->assertUnprocessable();
|
||||
$empty=app(\App\Services\InvestorContext::class)->prefill(['fields'=>['site_tenure'=>'lease'],'revision'=>0,'provenance'=>[],'land_preparation'=>['need'=>'yes','reason'=>'QA']]);
|
||||
$this->assertSame('leased',$empty['simulator']['land_status']);
|
||||
}
|
||||
public function test_simulator_reuses_names_for_the_exact_chosen_territory_and_sector_without_creating_a_location(): void
|
||||
{
|
||||
$id=$this->postJson('/investimentos',['title'=>'QA continuidade simulador','client_key'=>(string)Str::uuid(),'reuse_consent'=>true])->assertCreated()->json('id');
|
||||
|
||||
Reference in New Issue
Block a user