withoutVite(); $ids = []; $parent = null; foreach (['country' => 'SYNTHETIC Moçambique', 'province' => 'SYNTHETIC Zambézia', 'district' => 'SYNTHETIC Mocuba'] as $type => $name) { $id = (string) Str::uuid(); DB::table('geo_locations')->insert(['id' => $id, 'parent_id' => $parent, 'name' => $name, 'code' => $id, 'location_type' => $type, 'source_system' => 'cartografia-workbook', 'data_classification' => 'public', 'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:QA:'.$id]); $ids[$type] = $parent = $id; } [$province, $district] = [$ids['province'], $ids['district']]; $project = (string) Str::uuid(); DB::table('projects')->insert(['id' => $project, 'code' => 'SYNTHETIC-MOCUBA', 'name' => 'Projecto fictício', 'status' => 'draft', 'primary_territory_id' => $district, 'metadata' => '{}', 'data_classification' => 'public']); $dossier = InvestmentDossier::create(['project_id' => $project, 'title' => 'SYNTHETIC Cidadela', 'source' => 'Synthetic fixture only', 'content' => [], 'publication_status' => 'published', 'published_at' => now()->subMinute(), 'data_classification' => 'public', 'approval_basis' => 'document_owner', 'approval_evidence' => 'Synthetic QA fixture only']); $gaps = fn () => collect($this->get('/carteira/'.$dossier->id)->assertOk()->viewData('page')['props']['geography']['locations'])->firstWhere('id', $district)['gaps']; $this->assertSame(['admin_post' => 'to_verify', 'locality' => 'to_verify', 'coordinates' => 'to_verify', 'polygon' => 'to_verify', 'source_date' => 'to_verify'], $gaps()); $manager = User::factory()->create(); config(['portal.managers' => [$manager->email]]); $this->actingAsWithMfa($manager); $this->actingAs($manager)->getJson('/management/lacunas')->assertOk()->assertJsonCount(5, 'items')->assertJsonPath('items.0.dossier', 'SYNTHETIC Cidadela'); $this->postJson('/management/lacunas', ['dossier_id' => $dossier->id, 'location_id' => $district, 'field' => 'admin_post', 'status' => 'not_in_source', 'note' => 'Documento de origem consultado: não indica o posto administrativo.'])->assertOk(); $this->postJson('/management/lacunas', ['dossier_id' => $dossier->id, 'location_id' => $district, 'field' => 'coordinates', 'status' => 'missing_in_portal'])->assertOk(); $this->postJson('/management/lacunas', ['dossier_id' => $dossier->id, 'location_id' => $province, 'field' => 'admin_post', 'status' => 'not_in_source'])->assertUnprocessable(); $this->getJson('/management/lacunas')->assertOk()->assertJsonCount(3, 'items'); $this->getJson('/management/lacunas?status=not_in_source')->assertOk()->assertJsonCount(1, 'items'); $this->assertSame(1, DB::table('audit_events')->where('action', 'information_gap_reviewed')->where('entity_id', $dossier->id)->where('after_data->field', 'admin_post')->count()); $this->assertSame(['admin_post' => 'not_in_source', 'locality' => 'to_verify', 'coordinates' => 'missing_in_portal', 'polygon' => 'to_verify', 'source_date' => 'to_verify'], $gaps()); $this->postJson('/management/lacunas', ['dossier_id' => $dossier->id, 'location_id' => $district, 'field' => 'admin_post', 'status' => 'to_verify'])->assertOk(); $this->assertSame('to_verify', $gaps()['admin_post']); $this->actingAs(User::factory()->create())->getJson('/management/lacunas')->assertForbidden(); } }