Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan() - Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture) - Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans) - Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the render test for all themes now includes the floor plan - Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5) - styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04b5189bd8
commit
f7cbc66451
26 files changed
+877
-1
No files matched your search
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Resources\FloorPlans\FloorPlanResource;
|
||||
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
|
||||
use App\Models\Amenity;
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Page;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Database\Seeders\WebsiteContentSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FloorPlanTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
|
||||
$this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]);
|
||||
$this->withoutVite();
|
||||
$this->property = Property::sole();
|
||||
}
|
||||
|
||||
public function test_floor_plan_belongs_to_the_landlord_of_its_apartment(): void
|
||||
{
|
||||
$plan = FloorPlan::factory()->for($this->property)->create();
|
||||
|
||||
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
|
||||
$this->assertTrue($this->property->floorPlan->is($plan));
|
||||
}
|
||||
|
||||
public function test_area_points_are_parsed_in_percent_and_invalid_pairs_are_dropped(): void
|
||||
{
|
||||
$this->assertSame([[10.0, 20.5], [50.0, 20.5], [50.0, 65.0]], FloorPlan::points(' 10,20.5 50,20.5 50,65 abc 150,3 '));
|
||||
$this->assertSame([], FloorPlan::points(null));
|
||||
}
|
||||
|
||||
public function test_section_shows_visible_rooms_with_area_photo_equipment_and_hint(): void
|
||||
{
|
||||
$roomPhoto = Photo::factory()->create(['alt_text' => 'Glasdusche im Bad']);
|
||||
$shower = Amenity::factory()->for($this->property)->create(['name' => 'Dusche mit niedrigem Einstieg']);
|
||||
FloorPlan::factory()->for($this->property)->create([
|
||||
'photo_id' => Photo::factory()->create(['alt_text' => 'Grundriss der Wohnung'])->id,
|
||||
'rooms' => [
|
||||
['id' => 'a', 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65', 'photo_ids' => [$roomPhoto->id], 'amenity_ids' => [$shower->id], 'is_visible' => true],
|
||||
['id' => 'b', 'name' => 'Abstellkammer', 'points' => '1,1 2,1 2,2', 'is_visible' => false],
|
||||
['id' => 'c', 'name' => 'Ohne Fläche', 'points' => '1,1 2,2', 'is_visible' => true],
|
||||
],
|
||||
]);
|
||||
$this->placeSectionOnApartmentPage();
|
||||
|
||||
$this->get('/wohnung')
|
||||
->assertOk()
|
||||
->assertSee('Der Grundriss')
|
||||
->assertSee('points="50,40 66,40 66,65"', false)
|
||||
->assertSee('id="raum-bad-1"', false)
|
||||
->assertSee('Bad mit Glasdusche.')
|
||||
->assertSee('Flache Dusche mit kleiner Kante.')
|
||||
->assertSee('Dusche mit niedrigem Einstieg')
|
||||
->assertSee('Glasdusche im Bad')
|
||||
->assertDontSee('Abstellkammer')
|
||||
->assertDontSee('Ohne Fläche');
|
||||
}
|
||||
|
||||
public function test_section_shows_nothing_without_a_floor_plan(): void
|
||||
{
|
||||
$this->placeSectionOnApartmentPage();
|
||||
|
||||
$this->get('/wohnung')->assertOk()->assertDontSee('Der Grundriss');
|
||||
}
|
||||
|
||||
public function test_content_editor_creates_a_floor_plan_and_a_room_needs_an_area(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->role(UserRole::Content)->create());
|
||||
$planPhoto = Photo::factory()->create();
|
||||
|
||||
$this->get(FloorPlanResource::getUrl('index'))->assertOk();
|
||||
|
||||
Livewire::test(CreateFloorPlan::class)
|
||||
->fillForm([
|
||||
'property_id' => $this->property->id,
|
||||
'photo_id' => $planPhoto->id,
|
||||
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10', 'is_visible' => true]],
|
||||
])
|
||||
->call('create')
|
||||
->assertHasFormErrors(['rooms.diele.points']);
|
||||
|
||||
Livewire::test(CreateFloorPlan::class)
|
||||
->fillForm([
|
||||
'property_id' => $this->property->id,
|
||||
'photo_id' => $planPhoto->id,
|
||||
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10 20,30 10,30', 'is_visible' => true]],
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$plan = FloorPlan::sole();
|
||||
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
|
||||
$this->assertSame(['Diele'], $plan->visibleRooms()->pluck('name')->all());
|
||||
}
|
||||
|
||||
private function placeSectionOnApartmentPage(): void
|
||||
{
|
||||
$page = Site::sole()->pages()->where('slug', 'wohnung')->sole();
|
||||
$page->update(['sections' => [...$page->sections, ['type' => 'floor_plan', 'data' => ['heading' => 'Der Grundriss']]]]);
|
||||
$this->assertInstanceOf(Page::class, $page);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user