feat: add workforce evidence and sourced economic context map layers
This commit is contained in:
@@ -55,15 +55,34 @@ class InvestmentThematicMapTest extends TestCase
|
||||
$record = $this->record($prefix, [$this->proof(), $this->proof('infrastructure'), $this->proof('resource', 'methodology'), $this->proof('demand')]);
|
||||
$before = $record->fresh()->getRawOriginal('workflow_context');
|
||||
$response = $this->getJson($this->url($prefix))->assertOk()->assertJsonPath('matched_count', 1)
|
||||
->assertJsonPath('thematic_records.0.id', $record->id)->assertJsonCount(2, 'thematic_records.0.evidence')
|
||||
->assertJsonPath('thematic_records.0.id', $record->id)->assertJsonCount(3, 'thematic_records.0.evidence')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.source', 'Synthetic public source')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.period', '2026')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.scope', 'Synthetic district')
|
||||
->assertJsonPath('thematic_records.0.evidence.2.category', 'economic_potential')
|
||||
->assertJsonPath('thematic_records.0.evidence.2.source_category', 'demand')
|
||||
->assertJsonPath('thematic_records.0.state', 'hypothesis')->assertJsonCount(0, 'features')->assertJsonCount(1, 'unlocated');
|
||||
$this->assertStringNotContainsString('PRIVATE-DRAFT-MUST-NOT-LEAK', $response->getContent());
|
||||
$this->assertSame($before, $record->fresh()->getRawOriginal('workflow_context'));
|
||||
}
|
||||
|
||||
public function test_workforce_is_explicit_and_economic_context_preserves_each_source_without_inferred_totals(): void
|
||||
{
|
||||
$prefix = 'THEME-'.Str::uuid();
|
||||
$this->record($prefix, [$this->proof('workforce'), $this->proof('activity'), $this->proof('supply'), $this->proof('demand'), $this->proof('workforce', 'methodology')]);
|
||||
$r = $this->getJson($this->url($prefix))->assertOk()->assertJsonCount(4, 'thematic_records.0.evidence')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.category', 'workforce')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.source_category', 'workforce')
|
||||
->assertJsonPath('thematic_records.0.state', 'hypothesis')->assertJsonCount(0, 'features')->json('thematic_records.0');
|
||||
foreach (['activity', 'supply', 'demand'] as $i => $source) {
|
||||
$this->assertSame('economic_potential', $r['evidence'][$i + 1]['category']);
|
||||
$this->assertSame($source, $r['evidence'][$i + 1]['source_category']);
|
||||
$this->assertSame('2026', $r['evidence'][$i + 1]['period']);
|
||||
}
|
||||
$this->assertArrayNotHasKey('available_workers', $r);
|
||||
$this->assertArrayNotHasKey('potential_score', $r);
|
||||
}
|
||||
|
||||
public function test_unpublished_future_restricted_and_unselected_private_evidence_are_not_disclosed(): void
|
||||
{
|
||||
$prefix = 'THEME-'.Str::uuid();
|
||||
|
||||
@@ -62,6 +62,26 @@ final class ProactiveInvestmentTest extends TestCase
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function test_workforce_evidence_saves_recovers_and_requires_existing_explicit_publication(): void
|
||||
{
|
||||
$input = F::input();
|
||||
$input['proactive']['evidence'][0]['category'] = 'workforce';
|
||||
$id = $this->postJson('/minhas-oportunidades/drafts', $input)->assertCreated()->json('id');
|
||||
$o = Opportunity::findOrFail($id);
|
||||
$analysis = app(OpportunityManagement::class)->values($o)['proactive'];
|
||||
$this->assertSame('workforce', $analysis['evidence'][0]['category']);
|
||||
$this->assertNull(app(ProactiveInvestment::class)->publicData($o));
|
||||
$this->publish($o);
|
||||
$this->getJson('/api/v1/investment/map?opportunity_id='.$id)->assertOk()
|
||||
->assertJsonPath('thematic_records.0.evidence.0.category', 'workforce')
|
||||
->assertJsonPath('thematic_records.0.evidence.0.source', $analysis['evidence'][0]['source'])
|
||||
->assertJsonCount(1, 'thematic_records.0.evidence')->assertJsonCount(0, 'features');
|
||||
$analysis['evidence'][0]['category'] = 'demand';
|
||||
$this->putJson('/minhas-oportunidades/'.$id.'/draft', ['etag' => app(OpportunityManagement::class)->etag($o->fresh()), 'proactive' => $analysis,
|
||||
'reason' => 'SYNTHETIC QA later private changes must not replace the published workforce source'])->assertOk();
|
||||
$this->getJson('/api/v1/investment/map?opportunity_id='.$id)->assertOk()->assertJsonPath('thematic_records.0.evidence.0.category', 'workforce');
|
||||
}
|
||||
|
||||
public function test_legacy_records_without_analysis_add_no_publication_lookup(): void
|
||||
{
|
||||
$o = new Opportunity;
|
||||
|
||||
Reference in New Issue
Block a user