fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -10,10 +10,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 PortalAuditConsumerLotTest extends TestCase
|
||||
{
|
||||
use AuthenticatesQaActors;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -57,7 +59,7 @@ class PortalAuditConsumerLotTest extends TestCase
|
||||
$this->getJson($url)->assertOk()->assertJsonPath('territory_registered', true)->assertJsonPath('selected_geometry_available', false)->assertJsonCount(0, 'areas');
|
||||
$private = '/management/territory-geometries?territory_id='.$locality;
|
||||
$this->actingAs(User::factory()->create())->getJson($private)->assertForbidden();
|
||||
$this->actingAs($manager)->getJson($private)->assertOk()->assertJsonPath('selected_geometry_available', false)->assertJsonPath('context_geometry_count', 1)
|
||||
$this->actingAsWithMfa($manager)->getJson($private)->assertOk()->assertJsonPath('selected_geometry_available', false)->assertJsonPath('context_geometry_count', 1)
|
||||
->assertJsonPath('areas.0.territory_id', $post)->assertJsonPath('areas.0.source_date', '2019-06-07')->assertJsonPath('areas.0.geometry.type', 'Polygon')->assertJsonPath('investment_site', false);
|
||||
$this->getJson('/management/territory-geometries?territory_id='.$post)->assertJsonPath('selected_geometry_available', true);
|
||||
$this->getJson('/management/territory-geometries?territory_id=bad')->assertUnprocessable();
|
||||
@@ -74,7 +76,7 @@ class PortalAuditConsumerLotTest extends TestCase
|
||||
$manager = $this->manager();
|
||||
$owner = User::factory()->create();
|
||||
foreach (['project-preparation', 'project-change', 'project-follow-up'] as $index => $code) {
|
||||
$service = $this->actingAs($manager)->postJson('/management/balcao/servicos', ['code' => $code, 'confirm' => true])->assertCreated()->json('id');
|
||||
$service = $this->actingAsWithMfa($manager)->postJson('/management/balcao/servicos', ['code' => $code, 'confirm' => true])->assertCreated()->json('id');
|
||||
$case = $this->actingAs($owner)->postJson('/balcao-virtual/dossiers', ['title' => 'Synthetic QA '.$code, 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
|
||||
$id = $this->postJson('/balcao-virtual/dossiers/'.$case.'/pedidos', ['service_version_id' => $service, 'client_key' => (string) Str::uuid()])->assertCreated()->json('id');
|
||||
$url = '/balcao-virtual/pedidos/'.$id;
|
||||
@@ -95,14 +97,14 @@ class PortalAuditConsumerLotTest extends TestCase
|
||||
$this->assertSame('PT', app(VirtualDesk::class)->decode($cipher)['country']);
|
||||
$this->putJson($url, ['version' => 2, 'payload' => $payload, 'submit' => true, 'consent' => true])->assertOk()->assertJsonPath('status', 'submitted');
|
||||
$this->postJson($url.'/estado', ['version' => 3, 'status' => 'reviewing', 'reason' => 'Synthetic self review'])->assertForbidden();
|
||||
$this->actingAs($manager)->postJson($url.'/estado', ['version' => 3, 'status' => 'returned', 'reason' => 'Synthetic authorized correction', 'editable_fields' => ['country', 'declared_origin_country_code']])->assertOk()->assertJsonPath('version', 4);
|
||||
$this->actingAsWithMfa($manager)->postJson($url.'/estado', ['version' => 3, 'status' => 'returned', 'reason' => 'Synthetic authorized correction', 'editable_fields' => ['country', 'declared_origin_country_code']])->assertOk()->assertJsonPath('version', 4);
|
||||
$this->actingAs($owner)->putJson($url, ['version' => 4, 'payload' => [...$payload, 'title' => 'Unauthorized change']])->assertUnprocessable();
|
||||
$this->putJson($url, ['version' => 4, 'payload' => [...$payload, 'country' => 'MZ', 'declared_origin_country_code' => 'PT']])->assertOk()->assertJsonPath('version', 5);
|
||||
$this->getJson($url)->assertJsonPath('request.payload.country', 'MZ')->assertJsonPath('request.payload.declared_origin_country_code', 'PT');
|
||||
$this->putJson($url, ['version' => 4, 'payload' => $payload])->assertConflict();
|
||||
$this->actingAs(User::factory()->create())->getJson($url)->assertForbidden();
|
||||
$this->assertDatabaseHas('desk_requests', ['id' => $id, 'version' => 5, 'status' => 'returned']);
|
||||
$this->actingAs($manager)->get('/management/interests?origin=PT')->assertInertia(fn (Assert $p) => $p
|
||||
$this->actingAsWithMfa($manager)->get('/management/interests?origin=PT')->assertInertia(fn (Assert $p) => $p
|
||||
->where('originStatistics.desk.0.code', 'PT')->where('originStatistics.desk.0.count', $index + 1)
|
||||
->has('originStatistics.interests', 0)->has('originStatistics.businesses', 0));
|
||||
$this->get('/management/interests?origin=ZA')->assertInertia(fn (Assert $p) => $p->has('originStatistics.desk', 0));
|
||||
|
||||
Reference in New Issue
Block a user