chore: cleanup dead code + format with Pint

- Remove unused FeaturesController (empty stubs, no routes)
- Remove ConvertSpatialFile CLI command (unused; service used in LayerManager)
- Remove MigrateGeojsonToFeatures CLI command (one-shot migration, not referenced)
- Remove .claude/worktrees/ (11 old agent worktrees from June)
- Apply Laravel Pint formatting across 219 files (style only, no functional changes)

Tests: 101 passing (319 assertions)
API routes: unchanged (8 routes intact)
This commit is contained in:
Javier Braña
2026-08-28 13:04:28 +02:00
parent 2dccd59385
commit 90630379fb
139 changed files with 2888 additions and 2510 deletions
+84 -82
View File
@@ -11,6 +11,8 @@ use App\Models\Media;
use App\Models\Phase;
use App\Models\Project;
use App\Models\User;
use Database\Seeders\PermissionCatalogSeeder;
use Database\Seeders\RolesAndPermissionsSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
@@ -25,8 +27,8 @@ class InspectionFormTest extends TestCase
{
parent::setUp();
Storage::fake('public');
$this->seed(\Database\Seeders\RolesAndPermissionsSeeder::class);
$this->seed(\Database\Seeders\PermissionCatalogSeeder::class);
$this->seed(RolesAndPermissionsSeeder::class);
$this->seed(PermissionCatalogSeeder::class);
}
private function createTestData(): array
@@ -100,7 +102,7 @@ class InspectionFormTest extends TestCase
'mediable_type' => Inspection::class,
'mediable_id' => $inspection->id,
'name' => 'original.jpg',
'file_path' => 'uploads/inspections/' . $inspection->id . '/original.jpg',
'file_path' => 'uploads/inspections/'.$inspection->id.'/original.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
@@ -150,7 +152,7 @@ class InspectionFormTest extends TestCase
'mediable_type' => Inspection::class,
'mediable_id' => $inspection->id,
'name' => 'to_delete.jpg',
'file_path' => 'uploads/inspections/' . $inspection->id . '/to_delete.jpg',
'file_path' => 'uploads/inspections/'.$inspection->id.'/to_delete.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
@@ -161,7 +163,7 @@ class InspectionFormTest extends TestCase
'mediable_type' => Inspection::class,
'mediable_id' => $inspection->id,
'name' => 'keep.jpg',
'file_path' => 'uploads/inspections/' . $inspection->id . '/keep.jpg',
'file_path' => 'uploads/inspections/'.$inspection->id.'/keep.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
@@ -233,86 +235,86 @@ class InspectionFormTest extends TestCase
}
public function test_delete_inspection_removes_inspection_and_media(): void
{
[$user, $project, $feature, $template] = $this->createTestData();
{
[$user, $project, $feature, $template] = $this->createTestData();
$inspection = Inspection::create([
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $template->id,
'user_id' => $user->id,
'inspector_user_id' => $user->id,
'status' => 'completed',
'completed_at' => now(),
'result' => 'pass',
'notes' => 'Note',
'data' => ['altura' => '5.0'],
]);
$photo = Media::create([
'mediable_type' => Inspection::class,
'mediable_id' => $inspection->id,
'name' => 'test.jpg',
'file_path' => 'uploads/inspections/' . $inspection->id . '/test.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
'category' => 'image',
'uploaded_by' => $user->id,
]);
$inspection = Inspection::create([
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $template->id,
'user_id' => $user->id,
'inspector_user_id' => $user->id,
'status' => 'completed',
'completed_at' => now(),
'result' => 'pass',
'notes' => 'Note',
'data' => ['altura' => '5.0'],
]);
$photo = Media::create([
'mediable_type' => Inspection::class,
'mediable_id' => $inspection->id,
'name' => 'test.jpg',
'file_path' => 'uploads/inspections/'.$inspection->id.'/test.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
'category' => 'image',
'uploaded_by' => $user->id,
]);
// Test direct model delete first
$inspection->delete();
$this->assertSoftDeleted('inspections', ['id' => $inspection->id]);
$this->assertDatabaseMissing('media', ['id' => $photo->id]);
// Restore for the actual test
$inspection->restore();
$this->assertDatabaseHas('inspections', ['id' => $inspection->id, 'deleted_at' => null]);
// Test direct model delete first
$inspection->delete();
$this->assertSoftDeleted('inspections', ['id' => $inspection->id]);
$this->assertDatabaseMissing('media', ['id' => $photo->id]);
// Now test through Livewire component
$inspection2 = Inspection::create([
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $template->id,
'user_id' => $user->id,
'inspector_user_id' => $user->id,
'status' => 'completed',
'completed_at' => now(),
'result' => 'pass',
'notes' => 'Note',
'data' => ['altura' => '5.0'],
]);
$photo2 = Media::create([
'mediable_type' => Inspection::class,
'mediable_id' => $inspection2->id,
'name' => 'test2.jpg',
'file_path' => 'uploads/inspections/' . $inspection2->id . '/test2.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
'category' => 'image',
'uploaded_by' => $user->id,
]);
// Restore for the actual test
$inspection->restore();
$this->assertDatabaseHas('inspections', ['id' => $inspection->id, 'deleted_at' => null]);
$component = Livewire::actingAs($user)
->test(ProjectMap::class, ['project' => $project])
->call('selectFeature', $feature->id);
// Debug: check if component is instantiated
$component->assertSet('project.id', $project->id);
$component->assertSet('selectedFeature.id', $feature->id);
// Call deleteInspection and capture events
$component->call('deleteInspection', $inspection2->id);
// Check if notify was dispatched
$component->assertDispatched('notify', 'Inspección eliminada correctamente');
$this->assertSoftDeleted('inspections', ['id' => $inspection2->id]);
$this->assertDatabaseMissing('media', ['id' => $photo2->id]);
}
// Now test through Livewire component
$inspection2 = Inspection::create([
'project_id' => $project->id,
'layer_id' => $feature->layer_id,
'feature_id' => $feature->id,
'template_id' => $template->id,
'user_id' => $user->id,
'inspector_user_id' => $user->id,
'status' => 'completed',
'completed_at' => now(),
'result' => 'pass',
'notes' => 'Note',
'data' => ['altura' => '5.0'],
]);
$photo2 = Media::create([
'mediable_type' => Inspection::class,
'mediable_id' => $inspection2->id,
'name' => 'test2.jpg',
'file_path' => 'uploads/inspections/'.$inspection2->id.'/test2.jpg',
'file_type' => 'image/jpeg',
'file_extension' => 'jpg',
'file_size' => 1000,
'category' => 'image',
'uploaded_by' => $user->id,
]);
$component = Livewire::actingAs($user)
->test(ProjectMap::class, ['project' => $project])
->call('selectFeature', $feature->id);
// Debug: check if component is instantiated
$component->assertSet('project.id', $project->id);
$component->assertSet('selectedFeature.id', $feature->id);
// Call deleteInspection and capture events
$component->call('deleteInspection', $inspection2->id);
// Check if notify was dispatched
$component->assertDispatched('notify', 'Inspección eliminada correctamente');
$this->assertSoftDeleted('inspections', ['id' => $inspection2->id]);
$this->assertDatabaseMissing('media', ['id' => $photo2->id]);
}
public function test_delete_inspection_forbidden_without_permission(): void
{
@@ -342,4 +344,4 @@ class InspectionFormTest extends TestCase
$this->assertDatabaseHas('inspections', ['id' => $inspection->id, 'deleted_at' => null]);
}
}
}