Ajoute dossiers et association de site aux schémas d'infrastructure

- Navigation par dossiers dans la section Infrastructure (créer, parcourir,
  fil d'ariane), isolée du navigateur Documents comme les schémas eux-mêmes.
- Un schéma peut être associé à un site de l'organisation, avec filtre par
  site dans la liste.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mrKamoo
2026-08-24 07:57:45 +02:00
co-authored by Claude Sonnet 5
parent 3e5878192e
commit c1c6d56d1e
6 changed files with 241 additions and 24 deletions
+59
View File
@@ -2,6 +2,7 @@
namespace Tests\Feature;
use App\Models\Location;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -100,4 +101,62 @@ class InfrastructureTest extends TestCase
->assertDontSee('Schéma réseau - Mairie')
->assertSee('Compte-rendu.md');
}
public function test_can_create_a_folder_and_a_diagram_inside_it(): void
{
$user = User::factory()->create();
$org = Organization::create(['name' => 'Test Commune', 'slug' => 'test-commune', 'org_type' => 'client']);
$this->actingAs($user);
$component = Livewire::test('infrastructure.index', ['organization' => $org])
->set('newFolderName', 'Réseau')
->call('createFolder')
->assertHasNoErrors();
$folder = $org->documents()->where('type', 'diagram')->where('is_folder', true)->firstOrFail();
$this->assertSame('Réseau', $folder->name);
$component->set('folderId', $folder->id)
->set('newDiagramName', 'Schéma coeur de réseau')
->call('createDiagram')
->assertHasNoErrors();
$diagram = $org->documents()->where('type', 'diagram')->where('name', 'Schéma coeur de réseau')->firstOrFail();
$this->assertSame($folder->id, $diagram->folder_id);
// The folder itself must not leak into the general Documents browser.
Livewire::test('documents.index', ['organization' => $org])->assertDontSee('Réseau');
}
public function test_a_diagram_can_be_associated_with_a_site(): void
{
$user = User::factory()->create();
$org = Organization::create(['name' => 'Test Commune', 'slug' => 'test-commune', 'org_type' => 'client']);
$location = Location::create(['organization_id' => $org->id, 'name' => 'Mairie']);
$document = $org->documents()->create([
'name' => 'Schéma test',
'type' => 'diagram',
'content' => '<mxfile></mxfile>',
'current_version' => 1,
'created_by' => $user->id,
]);
$this->actingAs($user);
Livewire::test('documents.diagram-editor', ['organization' => $org, 'document' => $document])
->call('updateLocation', $location->id)
->assertHasNoErrors();
$this->assertSame($location->id, $document->refresh()->location_id);
Livewire::test('infrastructure.index', ['organization' => $org, 'locationId' => $location->id])
->assertSee('Schéma test');
$otherLocation = Location::create(['organization_id' => $org->id, 'name' => 'Annexe']);
Livewire::test('infrastructure.index', ['organization' => $org, 'locationId' => $otherLocation->id])
->assertDontSee('Schéma test');
}
}