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); } }