@@ -2,11 +2,13 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\InterestRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BusinessMarketplacePublicTest extends TestCase
|
||||
@@ -36,6 +38,8 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
|
||||
public function test_interest_is_limited_to_published_business_and_deduplicated_idempotently(): void
|
||||
{
|
||||
$this->withoutVite();
|
||||
config(['portal.notifications_enabled' => false]);
|
||||
$business = $this->publishedBusiness();
|
||||
$payload = [
|
||||
'existingBusinessId' => $business['id'],
|
||||
@@ -44,12 +48,17 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
'email' => 'portal-integration-test@gmail.com',
|
||||
'phone' => '+258 840000000',
|
||||
'investorType' => 'empresa',
|
||||
'country' => 'Moçambique',
|
||||
'country' => 'PT',
|
||||
'declared_origin_country_code' => 'ZA',
|
||||
'sectorInterest' => 'Energia',
|
||||
'message' => 'Synthetic interest for the published business listing.',
|
||||
'privacyConsent' => true,
|
||||
];
|
||||
$key = (string) Str::uuid();
|
||||
$this->get('/negocios/'.$business['public_slug'].'/manifestar-interesse')->assertInertia(fn (Assert $p) => $p
|
||||
->component('investment/business-interest')->has('countries', 249)->where('record.id', $business['id']));
|
||||
$this->postJson('/api/v1/interest-requests', [...$payload, 'country' => 'ZZ'], ['Idempotency-Key' => (string) Str::uuid()])->assertUnprocessable();
|
||||
$this->assertDatabaseCount('interest_requests', 0);
|
||||
|
||||
$first = $this->postJson('/api/v1/interest-requests', $payload, ['Idempotency-Key' => $key])->assertCreated();
|
||||
$second = $this->postJson('/api/v1/interest-requests', $payload, ['Idempotency-Key' => $key])->assertCreated();
|
||||
@@ -65,6 +74,18 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
$this->postJson('/api/v1/interest-requests', [...$payload, 'message' => 'Another valid message for this active interest.'])
|
||||
->assertStatus(409);
|
||||
$this->assertDatabaseCount('interest_requests', 1);
|
||||
$interest = InterestRequest::firstOrFail();
|
||||
$this->assertSame('PT', $interest->country);
|
||||
$this->assertSame('ZA', $interest->metadata['declared_origin_country_code']);
|
||||
$manager = User::factory()->create();
|
||||
config(['portal.managers' => [$manager->email]]);
|
||||
$this->actingAs($manager)->get('/management/interests/'.$interest->id)->assertInertia(fn (Assert $p) => $p
|
||||
->where('interest.country', 'PT')->where('declaredOrigin.code', 'ZA'));
|
||||
$this->get('/management/interests?country=PT&origin=ZA')->assertInertia(fn (Assert $p) => $p
|
||||
->where('requests.total', 1)->where('originStatistics.interests.0.code', 'ZA')->where('originStatistics.interests.0.count', 1)
|
||||
->has('originStatistics.businesses', 0));
|
||||
$this->get('/management/interests?origin=PT')->assertInertia(fn (Assert $p) => $p->where('requests.total', 0)->has('originStatistics.interests', 0));
|
||||
$this->actingAs(User::factory()->create())->get('/management/interests/'.$interest->id)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_public_catalogue_filters_by_existing_opportunity_modality_and_opens_response_flow(): void
|
||||
|
||||
Reference in New Issue
Block a user