This commit is contained in:
2026-11-02 20:31:15 +02:00
parent 8ddfa93f45
commit 1da273f1f3
131 changed files with 14802 additions and 526 deletions
@@ -111,7 +111,8 @@ class BusinessMarketplacePublicTest extends TestCase
->where('filters.modality', 'real_estate')->has('results.data', 1));
$this->get('/negocios/'.$business['public_slug'])->assertOk()
->assertInertia(fn ($page) => $page->component('investment/business-opportunity')
->where('record.modality', 'real_estate'));
->where('record.modality', 'real_estate')
->where('similarCatalogueUrl', '/negocios?modality=real_estate'));
$this->get('/negocios/'.$business['public_slug'].'/manifestar-interesse')->assertOk()
->assertInertia(fn ($page) => $page->component('investment/business-interest')
->where('record.modality', 'real_estate'));
@@ -138,6 +139,45 @@ class BusinessMarketplacePublicTest extends TestCase
$this->assertDatabaseHas('interest_requests', ['existing_business_id' => $business['id'], 'modality' => 'real_estate', 'status' => 'received']);
}
public function test_similar_catalogue_uses_only_disclosed_primary_province_and_preserves_publication_limits(): void
{
$this->withoutVite();
$country = (string) Str::uuid();
$province = (string) Str::uuid();
DB::table('geo_locations')->insert([
['id' => $country, 'name' => 'Synthetic country', 'code' => $country, 'location_type' => 'country', 'parent_id' => null],
['id' => $province, 'name' => 'Synthetic province', 'code' => $province, 'location_type' => 'province', 'parent_id' => $country],
]);
foreach ([$country, $province] as $location) {
DB::table('geo_locations')->where('id', $location)->update([
'data_classification' => 'public', 'source_system' => 'cartografia-workbook',
'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:'.$location,
]);
}
$origin = $this->publishedBusiness();
$match = $this->publishedBusiness();
$reserved = $this->publishedBusiness();
$expired = $this->publishedBusiness();
foreach ([$origin, $match, $reserved, $expired] as $business) {
DB::table('existing_business_locations')->insert([
'id' => (string) Str::uuid(), 'existing_business_id' => $business['id'],
'province_id' => $province, 'precision_level' => 'province',
'is_primary' => true, 'is_public' => $business['id'] !== $reserved['id'],
]);
}
DB::table('existing_businesses')->where('id', $expired['id'])->update(['expires_at' => now()->subDay()]);
$url = '/negocios?modality=company_sale&province_id='.$province;
$this->get('/negocios/'.$origin['public_slug'])->assertInertia(fn (Assert $page) => $page
->where('similarCatalogueUrl', $url)->where('record.province', 'Synthetic province'));
$this->get('/negocios/'.$reserved['public_slug'])->assertInertia(fn (Assert $page) => $page
->where('similarCatalogueUrl', '/negocios?modality=company_sale')->where('record.province', null));
$this->getJson('/api/v1/business-opportunities?modality=company_sale&province_id='.$province)->assertOk()
->assertJsonCount(2, 'data')->assertJsonMissing(['id' => $reserved['id']])->assertJsonMissing(['id' => $expired['id']]);
DB::table('geo_locations')->where('id', $province)->update(['source_system' => 'unpublished-synthetic']);
$this->get('/negocios/'.$origin['public_slug'])->assertInertia(fn (Assert $page) => $page
->where('similarCatalogueUrl', '/negocios?modality=company_sale'));
}
/** @return array{id:string,public_slug:string} */
private function publishedBusiness(string $modality = 'company_sale'): array
{