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:
@@ -3,17 +3,19 @@
|
||||
namespace Tests\Feature\Api;
|
||||
|
||||
use App\Models\Feature;
|
||||
use App\Models\FeatureType;
|
||||
use App\Models\Inspection;
|
||||
use App\Models\InspectionTemplate;
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueComment;
|
||||
use App\Models\IssueTask;
|
||||
use App\Models\Layer;
|
||||
use App\Models\Media;
|
||||
use App\Models\Phase;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProgressUpdate;
|
||||
use App\Models\User;
|
||||
use App\Models\Project;
|
||||
use App\Models\SyncLog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -38,15 +40,15 @@ class MobileApiTest extends TestCase
|
||||
private function makeProject(?User $member = null): Project
|
||||
{
|
||||
$project = Project::create([
|
||||
'reference' => 'TEST-1',
|
||||
'name' => 'Proyecto Test',
|
||||
'address' => 'Calle Falsa 123',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'reference' => 'TEST-1',
|
||||
'name' => 'Proyecto Test',
|
||||
'address' => 'Calle Falsa 123',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'end_date_estimated' => now()->addMonths(6)->toDateString(),
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $member?->id ?? User::factory()->create()->id,
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $member?->id ?? User::factory()->create()->id,
|
||||
]);
|
||||
|
||||
if ($member) {
|
||||
@@ -59,10 +61,10 @@ class MobileApiTest extends TestCase
|
||||
private function makePhase(Project $project, string $name = 'Fase 1'): Phase
|
||||
{
|
||||
return Phase::create([
|
||||
'project_id' => $project->id,
|
||||
'name' => $name,
|
||||
'order' => 1,
|
||||
'color' => '#3b82f6',
|
||||
'project_id' => $project->id,
|
||||
'name' => $name,
|
||||
'order' => 1,
|
||||
'color' => '#3b82f6',
|
||||
'progress_percent' => 0,
|
||||
]);
|
||||
}
|
||||
@@ -70,10 +72,10 @@ class MobileApiTest extends TestCase
|
||||
private function makeLayer(Phase $phase): Layer
|
||||
{
|
||||
return Layer::create([
|
||||
'project_id' => $phase->project_id,
|
||||
'phase_id' => $phase->id,
|
||||
'name' => 'Capa 1',
|
||||
'color' => '#10b981',
|
||||
'project_id' => $phase->project_id,
|
||||
'phase_id' => $phase->id,
|
||||
'name' => 'Capa 1',
|
||||
'color' => '#10b981',
|
||||
'uploaded_by' => $phase->project->created_by,
|
||||
]);
|
||||
}
|
||||
@@ -82,10 +84,10 @@ class MobileApiTest extends TestCase
|
||||
{
|
||||
return Feature::create([
|
||||
'layer_id' => $layer->id,
|
||||
'name' => 'Elemento 1',
|
||||
'name' => 'Elemento 1',
|
||||
'geometry' => ['type' => 'Point', 'coordinates' => [-3.0, 40.0]],
|
||||
'progress' => 0,
|
||||
'status' => 'planned',
|
||||
'status' => 'planned',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -96,8 +98,8 @@ class MobileApiTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
|
||||
$res = $this->postJson('/api/v1/login', [
|
||||
'email' => $user->email,
|
||||
'password' => 'password',
|
||||
'email' => $user->email,
|
||||
'password' => 'password',
|
||||
'device_name' => 'Pixel-Test',
|
||||
]);
|
||||
|
||||
@@ -110,8 +112,8 @@ class MobileApiTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->postJson('/api/v1/login', [
|
||||
'email' => $user->email,
|
||||
'password' => 'incorrecta',
|
||||
'email' => $user->email,
|
||||
'password' => 'incorrecta',
|
||||
'device_name' => 'Pixel-Test',
|
||||
])->assertStatus(422);
|
||||
}
|
||||
@@ -239,7 +241,7 @@ class MobileApiTest extends TestCase
|
||||
$new = $this->makePhase($project, 'Fase nueva');
|
||||
|
||||
Sanctum::actingAs($user, ['mobile-sync']);
|
||||
$res = $this->getJson("/api/v1/projects/{$project->id}/bundle?since=" . urlencode($since->toIso8601String()))->assertOk();
|
||||
$res = $this->getJson("/api/v1/projects/{$project->id}/bundle?since=".urlencode($since->toIso8601String()))->assertOk();
|
||||
|
||||
$ids = collect($res->json('phases'))->pluck('id');
|
||||
$this->assertTrue($ids->contains($new->id));
|
||||
@@ -262,7 +264,7 @@ class MobileApiTest extends TestCase
|
||||
$feature->delete(); // soft delete
|
||||
|
||||
Sanctum::actingAs($user, ['mobile-sync']);
|
||||
$res = $this->getJson("/api/v1/projects/{$project->id}/bundle?since=" . urlencode($since->toIso8601String()))->assertOk();
|
||||
$res = $this->getJson("/api/v1/projects/{$project->id}/bundle?since=".urlencode($since->toIso8601String()))->assertOk();
|
||||
|
||||
$this->assertContains($feature->id, $res->json('deleted.features'));
|
||||
|
||||
@@ -274,7 +276,7 @@ class MobileApiTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
$project = $this->makeProject($user);
|
||||
$tpl = InspectionTemplate::create([
|
||||
'name' => 'Plantilla A',
|
||||
'name' => 'Plantilla A',
|
||||
'fields' => [['name' => 'ok', 'label' => 'OK', 'type' => 'boolean']],
|
||||
]);
|
||||
$project->inspectionTemplates()->attach($tpl->id);
|
||||
@@ -362,7 +364,7 @@ class MobileApiTest extends TestCase
|
||||
$user->givePermissionTo('update progress');
|
||||
$project = $this->makeProject($user);
|
||||
$feature = $this->makeFeature($this->makeLayer($this->makePhase($project)));
|
||||
$type = \App\Models\FeatureType::create(['name' => 'Pilar', 'color' => '#ffffff']);
|
||||
$type = FeatureType::create(['name' => 'Pilar', 'color' => '#ffffff']);
|
||||
|
||||
Sanctum::actingAs($user, ['mobile-sync']);
|
||||
$this->postJson('/api/v1/sync', ['operations' => [[
|
||||
@@ -431,7 +433,7 @@ class MobileApiTest extends TestCase
|
||||
'file' => UploadedFile::fake()->image('foto.jpg'),
|
||||
])->assertOk()->assertJsonPath('status', 'duplicate');
|
||||
|
||||
$this->assertEquals(1, \App\Models\Media::where('uuid', $uuid)->count());
|
||||
$this->assertEquals(1, Media::where('uuid', $uuid)->count());
|
||||
}
|
||||
|
||||
// ── Issue tasks / comments (enriquecimiento incidencias) ─────────────────────
|
||||
@@ -439,10 +441,10 @@ class MobileApiTest extends TestCase
|
||||
private function makeIssue(Project $project, ?User $reporter = null): Issue
|
||||
{
|
||||
return Issue::create([
|
||||
'project_id' => $project->id,
|
||||
'title' => 'Incidencia test',
|
||||
'status' => 'open',
|
||||
'priority' => 'medium',
|
||||
'project_id' => $project->id,
|
||||
'title' => 'Incidencia test',
|
||||
'status' => 'open',
|
||||
'priority' => 'medium',
|
||||
'reported_by' => $reporter?->id ?? $project->created_by,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ class FeatureManagementTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $user;
|
||||
|
||||
private Project $project;
|
||||
|
||||
private Feature $feature;
|
||||
|
||||
protected function setUp(): void
|
||||
|
||||
@@ -24,11 +24,12 @@ class GlobalTemplatesTest extends TestCase
|
||||
private function project(User $owner, string $ref = 'P'): Project
|
||||
{
|
||||
$p = Project::create([
|
||||
'reference' => $ref, 'name' => 'P-' . $ref, 'address' => 'x', 'lat' => 40, 'lng' => -3,
|
||||
'reference' => $ref, 'name' => 'P-'.$ref, 'address' => 'x', 'lat' => 40, 'lng' => -3,
|
||||
'start_date' => now()->toDateString(), 'end_date_estimated' => now()->addMonth()->toDateString(),
|
||||
'status' => 'in_progress', 'created_by' => $owner->id,
|
||||
]);
|
||||
$p->users()->attach($owner->id, ['role_in_project' => 'supervisor']);
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
@@ -124,8 +125,8 @@ class GlobalTemplatesTest extends TestCase
|
||||
$admin->givePermissionTo('manage templates');
|
||||
|
||||
$csv = "group,name,label,question,type,required,options,min,max,step,help\n"
|
||||
. "Dimensiones,altura,Altura (m),¿Cumple la cota?,decimal,1,,0,100,0.1,Medir con flexómetro\n"
|
||||
. "Acabados,ok,¿Acabado?,,boolean,0,,,,,\n";
|
||||
."Dimensiones,altura,Altura (m),¿Cumple la cota?,decimal,1,,0,100,0.1,Medir con flexómetro\n"
|
||||
."Acabados,ok,¿Acabado?,,boolean,0,,,,,\n";
|
||||
$file = UploadedFile::fake()->createWithContent('plantilla.csv', $csv);
|
||||
|
||||
$cmp = Livewire::actingAs($admin)
|
||||
@@ -159,7 +160,7 @@ class GlobalTemplatesTest extends TestCase
|
||||
$user = User::factory()->create();
|
||||
$project = $this->project($user, 'M');
|
||||
|
||||
$assigned = InspectionTemplate::create(['name' => 'Asignada', 'fields' => []]);
|
||||
$assigned = InspectionTemplate::create(['name' => 'Asignada', 'fields' => []]);
|
||||
$unassigned = InspectionTemplate::create(['name' => 'Otra', 'fields' => []]);
|
||||
$project->inspectionTemplates()->attach($assigned->id);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Livewire\Issues\IssueForm;
|
||||
use App\Models\Feature;
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueChecklistTemplate;
|
||||
use App\Models\IssueTask;
|
||||
use App\Models\Layer;
|
||||
use App\Models\Phase;
|
||||
use App\Models\Project;
|
||||
@@ -18,8 +17,8 @@ use App\Notifications\IssueStatusChangedNotification;
|
||||
use App\Notifications\IssueTaskAssignedNotification;
|
||||
use App\Notifications\IssueTaskOverdueNotification;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Livewire;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Tests\TestCase;
|
||||
@@ -29,7 +28,9 @@ class IssuesEnhancementsTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $user;
|
||||
|
||||
private User $assignee;
|
||||
|
||||
private Project $project;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -44,15 +45,15 @@ class IssuesEnhancementsTest extends TestCase
|
||||
$this->assignee = User::factory()->create();
|
||||
|
||||
$this->project = Project::create([
|
||||
'reference' => 'ENH-1',
|
||||
'name' => 'Proyecto Enh',
|
||||
'address' => 'Calle 1',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'reference' => 'ENH-1',
|
||||
'name' => 'Proyecto Enh',
|
||||
'address' => 'Calle 1',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'end_date_estimated' => now()->addMonths(3)->toDateString(),
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $this->user->id,
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $this->user->id,
|
||||
]);
|
||||
$this->project->users()->attach($this->user->id, ['role_in_project' => 'supervisor']);
|
||||
$this->project->users()->attach($this->assignee->id, ['role_in_project' => 'worker']);
|
||||
@@ -61,10 +62,10 @@ class IssuesEnhancementsTest extends TestCase
|
||||
private function makeIssue(array $attrs = []): Issue
|
||||
{
|
||||
return Issue::create(array_merge([
|
||||
'project_id' => $this->project->id,
|
||||
'title' => 'Incidencia enh',
|
||||
'status' => 'open',
|
||||
'priority' => 'medium',
|
||||
'project_id' => $this->project->id,
|
||||
'title' => 'Incidencia enh',
|
||||
'status' => 'open',
|
||||
'priority' => 'medium',
|
||||
'reported_by' => $this->user->id,
|
||||
], $attrs));
|
||||
}
|
||||
@@ -79,6 +80,7 @@ class IssuesEnhancementsTest extends TestCase
|
||||
'project_id' => $this->project->id, 'phase_id' => $phase->id,
|
||||
'name' => 'L', 'color' => '#111', 'uploaded_by' => $this->user->id,
|
||||
]);
|
||||
|
||||
return Feature::create([
|
||||
'layer_id' => $layer->id, 'name' => 'Muro norte',
|
||||
'geometry' => ['type' => 'Point', 'coordinates' => [-3.0, 40.0]],
|
||||
@@ -148,8 +150,8 @@ class IssuesEnhancementsTest extends TestCase
|
||||
$issue = $this->makeIssue();
|
||||
$template = IssueChecklistTemplate::create([
|
||||
'project_id' => $this->project->id,
|
||||
'name' => 'Plantilla',
|
||||
'items' => ['Picar', 'Sellar', 'Pintar'],
|
||||
'name' => 'Plantilla',
|
||||
'items' => ['Picar', 'Sellar', 'Pintar'],
|
||||
]);
|
||||
|
||||
Livewire::actingAs($this->user)
|
||||
@@ -168,11 +170,11 @@ class IssuesEnhancementsTest extends TestCase
|
||||
Notification::fake();
|
||||
$issue = $this->makeIssue();
|
||||
$task = $issue->tasks()->create([
|
||||
'title' => 'Tarea vencida',
|
||||
'title' => 'Tarea vencida',
|
||||
'assigned_to' => $this->assignee->id,
|
||||
'due_date' => now()->subDays(2)->toDateString(),
|
||||
'is_done' => false,
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'due_date' => now()->subDays(2)->toDateString(),
|
||||
'is_done' => false,
|
||||
'uuid' => (string) Str::uuid(),
|
||||
]);
|
||||
|
||||
$this->artisan('issues:notify-overdue')->assertSuccessful();
|
||||
|
||||
@@ -26,23 +26,23 @@ class IssuesTablePageTest extends TestCase
|
||||
$user->givePermissionTo(['view issues', 'edit issues', 'delete issues']);
|
||||
|
||||
$project = Project::create([
|
||||
'reference' => 'TBL-1',
|
||||
'name' => 'Proyecto Tabla',
|
||||
'address' => 'Calle Falsa 123',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'reference' => 'TBL-1',
|
||||
'name' => 'Proyecto Tabla',
|
||||
'address' => 'Calle Falsa 123',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'end_date_estimated' => now()->addMonths(6)->toDateString(),
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $user->id,
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $user->id,
|
||||
]);
|
||||
$project->users()->attach($user->id, ['role_in_project' => 'supervisor']);
|
||||
|
||||
$issue = Issue::create([
|
||||
'project_id' => $project->id,
|
||||
'title' => 'Grieta en muro',
|
||||
'status' => 'open',
|
||||
'priority' => 'high',
|
||||
'project_id' => $project->id,
|
||||
'title' => 'Grieta en muro',
|
||||
'status' => 'open',
|
||||
'priority' => 'high',
|
||||
'reported_by' => $user->id,
|
||||
]);
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ class MapTablesTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $user;
|
||||
|
||||
private Project $project;
|
||||
|
||||
private Feature $feature;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -84,12 +86,12 @@ class MapTablesTest extends TestCase
|
||||
{
|
||||
Inspection::create([
|
||||
'project_id' => $this->project->id,
|
||||
'layer_id' => $this->feature->layer_id,
|
||||
'layer_id' => $this->feature->layer_id,
|
||||
'feature_id' => $this->feature->id,
|
||||
'user_id' => $this->user->id,
|
||||
'data' => ['ok' => true],
|
||||
'status' => 'completed',
|
||||
'result' => 'pass',
|
||||
'user_id' => $this->user->id,
|
||||
'data' => ['ok' => true],
|
||||
'status' => 'completed',
|
||||
'result' => 'pass',
|
||||
]);
|
||||
|
||||
Livewire::actingAs($this->user)
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Livewire\Phases\PhaseList;
|
||||
use App\Livewire\Phases\PhaseTable;
|
||||
use App\Models\Phase;
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -17,6 +16,7 @@ class PhaseManagementTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $user;
|
||||
|
||||
private Project $project;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -30,15 +30,15 @@ class PhaseManagementTest extends TestCase
|
||||
$this->user->givePermissionTo(['manage phases', 'edit projects']);
|
||||
|
||||
$this->project = Project::create([
|
||||
'reference' => 'PH-1',
|
||||
'name' => 'Proyecto Fases',
|
||||
'address' => 'Calle 1',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'reference' => 'PH-1',
|
||||
'name' => 'Proyecto Fases',
|
||||
'address' => 'Calle 1',
|
||||
'lat' => 40.0,
|
||||
'lng' => -3.0,
|
||||
'start_date' => now()->toDateString(),
|
||||
'end_date_estimated' => now()->addMonths(3)->toDateString(),
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $this->user->id,
|
||||
'status' => 'in_progress',
|
||||
'created_by' => $this->user->id,
|
||||
]);
|
||||
$this->project->users()->attach($this->user->id, ['role_in_project' => 'supervisor']);
|
||||
}
|
||||
@@ -59,10 +59,10 @@ class PhaseManagementTest extends TestCase
|
||||
->assertHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas('phases', [
|
||||
'project_id' => $this->project->id,
|
||||
'name' => 'Cimentación',
|
||||
'color' => '#ff0000',
|
||||
'order' => 2,
|
||||
'project_id' => $this->project->id,
|
||||
'name' => 'Cimentación',
|
||||
'color' => '#ff0000',
|
||||
'order' => 2,
|
||||
'progress_percent' => 30,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class ProjectAssignmentsTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $admin;
|
||||
|
||||
private Project $project;
|
||||
|
||||
protected function setUp(): void
|
||||
|
||||
@@ -12,6 +12,7 @@ class SpatialFileConverterTest extends TestCase
|
||||
{
|
||||
$tmp = tempnam(sys_get_temp_dir(), 'kml_');
|
||||
file_put_contents($tmp, $content);
|
||||
|
||||
return new UploadedFile($tmp, $name, 'application/vnd.google-earth.kml+xml', null, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class UserLocaleTest extends TestCase
|
||||
|
||||
$admin = User::factory()->create();
|
||||
$admin->givePermissionTo(['create users', 'edit users']);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
@@ -56,10 +57,10 @@ class UserLocaleTest extends TestCase
|
||||
$admin = $this->admin();
|
||||
$company = $this->company();
|
||||
$target = User::factory()->create([
|
||||
'locale' => 'es',
|
||||
'locale' => 'es',
|
||||
'company_id' => $company->id,
|
||||
'first_name' => 'Bob',
|
||||
'last_name' => 'Stone',
|
||||
'last_name' => 'Stone',
|
||||
]);
|
||||
$target->assignRole('Tecnico');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user