fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -15,10 +15,12 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\Support\AuthenticatesQaActors;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PortalAuditNextLotTest extends TestCase
|
||||
{
|
||||
use AuthenticatesQaActors;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -36,7 +38,7 @@ class PortalAuditNextLotTest extends TestCase
|
||||
{
|
||||
$manager = User::factory()->create();
|
||||
config(['portal.managers' => [$manager->email]]);
|
||||
$this->actingAs($manager);
|
||||
$this->actingAsWithMfa($manager);
|
||||
foreach (array_keys(OpportunityMaturity::STAGES) as $index => $stage) {
|
||||
$input = ['creation_key' => (string) Str::uuid(), 'reason' => 'Verificação das oito etapas exclusivamente na QA', 'maturity_level' => $index + 1];
|
||||
if ($index < 6) {
|
||||
@@ -84,7 +86,9 @@ class PortalAuditNextLotTest extends TestCase
|
||||
$this->getJson($url)->assertOk()->assertJsonPath('record.payload.country', 'PT')->assertJsonPath('record.payload.declared_origin_country_code', 'ZA')->assertJsonCount(249, 'countries');
|
||||
$this->getJson('/api/v1/existing-business/listings?country=PT&origin=ZA')->assertOk()->assertJsonPath('records.total', 1);
|
||||
$this->getJson('/api/v1/existing-business/listings?origin=PT')->assertOk()->assertJsonPath('records.total', 0);
|
||||
$this->actingAsWithMfa($manager);
|
||||
$this->assertSame([], app(DeclaredOriginStatistics::class)->forManager($manager)['businesses']);
|
||||
$this->actingAs($owner);
|
||||
$this->putJson($url, [...$input, 'version_no' => 1, 'payload' => [...$payload, 'country' => 'Portugal']])->assertOk()->assertJsonPath('version_no', 2);
|
||||
$this->getJson($url)->assertOk()->assertJsonPath('record.payload.country', 'Portugal');
|
||||
$this->putJson($url, [...$input, 'version_no' => 2, 'payload' => $payload])->assertOk()->assertJsonPath('version_no', 3);
|
||||
@@ -94,12 +98,13 @@ class PortalAuditNextLotTest extends TestCase
|
||||
$this->assertSame(4, ExistingBusiness::findOrFail($record['id'])->version_no);
|
||||
$this->postJson($url.'/transitions', ['version_no' => 4, 'action' => 'submitted', 'note' => 'Submissão privada exclusivamente na base QA', 'review_consent' => true, 'confirmation_code' => $record['code']])->assertOk()->assertJsonPath('status', 'submitted');
|
||||
$this->getJson($url)->assertOk()->assertJsonPath('record.payload.declared_origin_country_code', 'ZA')->assertJsonPath('record.payload.country', 'PT');
|
||||
$this->actingAsWithMfa($manager);
|
||||
$stats = app(DeclaredOriginStatistics::class)->forManager($manager, 'ZA');
|
||||
$this->assertSame(1, $stats['businesses'][0]['count']);
|
||||
$this->assertSame('ZA', $stats['businesses'][0]['code']);
|
||||
$this->assertSame([], $stats['interests']);
|
||||
$this->assertSame([], app(DeclaredOriginStatistics::class)->forManager($manager, 'PT')['businesses']);
|
||||
$this->actingAs($manager)->get('/management/interests?origin=ZA')->assertInertia(fn (Assert $page) => $page->where('originStatistics.businesses.0.count', 1));
|
||||
$this->actingAsWithMfa($manager)->get('/management/interests?origin=ZA')->assertInertia(fn (Assert $page) => $page->where('originStatistics.businesses.0.count', 1));
|
||||
$this->actingAs(User::factory()->create())->getJson($url)->assertForbidden();
|
||||
$this->getJson('/api/v1/existing-business/listings?country=PT&origin=ZA')->assertOk()->assertJsonPath('records.total', 0);
|
||||
$this->assertDatabaseCount('existing_business_revisions', 5);
|
||||
@@ -134,7 +139,7 @@ class PortalAuditNextLotTest extends TestCase
|
||||
$this->assertSame('PT', $interest->country);
|
||||
$this->assertSame('ZA', $interest->metadata['declared_origin_country_code']);
|
||||
$this->getJson($url)->assertOk()->assertJsonPath('case.payload.parcels.0.locality_id', $parent)->assertJsonPath('case.payload.declared_origin_country_code', 'ZA');
|
||||
$this->actingAs($manager)->get('/management/interests?country=PT&origin=ZA')->assertInertia(fn (Assert $page) => $page->where('requests.total', 1)->where('requests.data.0.country', 'PT')->where('requests.data.0.declaredOrigin.code', 'ZA')->where('originStatistics.interests.0.count', 1));
|
||||
$this->actingAsWithMfa($manager)->get('/management/interests?country=PT&origin=ZA')->assertInertia(fn (Assert $page) => $page->where('requests.total', 1)->where('requests.data.0.country', 'PT')->where('requests.data.0.declaredOrigin.code', 'ZA')->where('originStatistics.interests.0.count', 1));
|
||||
$this->get('/management/interests?origin=PT')->assertInertia(fn (Assert $page) => $page->where('requests.total', 0)->has('originStatistics.interests', 0));
|
||||
$this->get('/management/interests?origin=unknown')->assertInertia(fn (Assert $page) => $page->where('requests.total', 0));
|
||||
$this->actingAs(User::factory()->create())->getJson($url)->assertNotFound();
|
||||
|
||||
Reference in New Issue
Block a user