fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -9,10 +9,12 @@ use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\Support\AuthenticatesQaActors;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BusinessMarketplacePublicTest extends TestCase
|
||||
{
|
||||
use AuthenticatesQaActors;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -57,6 +59,9 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
$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, ['Idempotency-Key' => $key])->assertUnauthorized();
|
||||
$this->assertDatabaseCount('interest_requests', 0);
|
||||
$this->actingAs(User::factory()->create());
|
||||
$this->postJson('/api/v1/interest-requests', [...$payload, 'country' => 'ZZ'], ['Idempotency-Key' => (string) Str::uuid()])->assertUnprocessable();
|
||||
$this->assertDatabaseCount('interest_requests', 0);
|
||||
|
||||
@@ -71,7 +76,7 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
$this->assertDatabaseCount('interest_requests', 1);
|
||||
$this->assertDatabaseCount('outbox_events', 1);
|
||||
|
||||
$this->postJson('/api/v1/interest-requests', [...$payload, 'message' => 'Another valid message for this active interest.'])
|
||||
$this->postJson('/api/v1/interest-requests', [...$payload, 'message' => 'Another valid message for this active interest.'], ['Idempotency-Key' => (string) Str::uuid()])
|
||||
->assertStatus(409);
|
||||
$this->assertDatabaseCount('interest_requests', 1);
|
||||
$interest = InterestRequest::firstOrFail();
|
||||
@@ -79,7 +84,7 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
$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
|
||||
$this->actingAsWithMfa($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)
|
||||
@@ -123,13 +128,13 @@ class BusinessMarketplacePublicTest extends TestCase
|
||||
->assertInertia(fn ($page) => $page->component('investment/business-opportunity')
|
||||
->where('record.modality', 'land_right'));
|
||||
|
||||
$this->postJson('/api/v1/interest-requests', [
|
||||
$this->actingAs(User::factory()->create())->postJson('/api/v1/interest-requests', [
|
||||
'existingBusinessId' => $business['id'], 'modality' => 'real_estate',
|
||||
'fullName' => 'Synthetic investor', 'email' => 'portal-integration-test@gmail.com', 'phone' => '+258 840000000',
|
||||
'investorType' => 'empresa', 'country' => 'MZ', 'sectorInterest' => 'Imobiliário',
|
||||
'message' => 'Synthetic interest in the published real estate opportunity.',
|
||||
'privacyConsent' => true,
|
||||
])->assertCreated();
|
||||
], ['Idempotency-Key' => (string) Str::uuid()])->assertCreated();
|
||||
$this->assertDatabaseHas('interest_requests', ['existing_business_id' => $business['id'], 'modality' => 'real_estate', 'status' => 'received']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user