- Sites (Domain, Theme, Farben; mehrfähig für weitere Vermieter), Seiten aus Bausteinen mit Menüs, Erscheinungsbilder mit jährlichem Zeitplan, Priorität und signierter Vorschau - Theme-Kern (app/Themes): Manifest, Registry, Vererbung (Child-Themes), Token-Farben als CSS-Variablen, Bausteinkatalog als Registry (config/themes.php) - 15 Bausteine: Titelbereich mit Suche, Eckdaten, Text mit Bildern, Galerie, Ausstattung, Lage, Preise, Angebote, Kalender & Anfrage, Bewertungen, Gastgeber, FAQ, Abschluss, Kontakt, Fließtext - Theme Ostsee-Licht: Layout, Kopf/Fuß, Banner, mobile Buchungsleiste, Lightbox, selbst gehostete Schriften, Reduced Motion - Seiten Start, Wohnung, Kühlungsborn, Preise & Buchung, Kontakt, Impressum, Datenschutz; Sitemap, robots.txt, JSON-LD - Admin: Seiten-Baukasten, Erscheinungsbilder, Websites - Dokumentation docs/THEMES.md inkl. Übergabe für die Design-Sitzung Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
4.3 KiB
PHP
107 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Enums\PhotoCategory;
|
|
use App\Enums\UserRole;
|
|
use App\Filament\Pages\EditContent;
|
|
use App\Filament\Resources\Amenities\AmenityResource;
|
|
use App\Filament\Resources\Faqs\FaqResource;
|
|
use App\Filament\Resources\Notices\NoticeResource;
|
|
use App\Filament\Resources\Photos\Pages\ListPhotos;
|
|
use App\Filament\Resources\Photos\PhotoResource;
|
|
use App\Filament\Resources\Properties\PropertyResource;
|
|
use App\Models\Amenity;
|
|
use App\Models\Notice;
|
|
use App\Models\Photo;
|
|
use App\Models\User;
|
|
use App\Support\Content;
|
|
use Carbon\CarbonImmutable;
|
|
use Database\Seeders\PropertySeeder;
|
|
use Database\Seeders\WebsiteContentSeeder;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class WebsiteContentTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
Storage::fake('public');
|
|
$this->seed([PropertySeeder::class, WebsiteContentSeeder::class]);
|
|
$this->actingAs(User::factory()->role(UserRole::Content)->create());
|
|
}
|
|
|
|
public function test_content_editor_sees_website_areas_but_not_bookings(): void
|
|
{
|
|
foreach ([PhotoResource::class, AmenityResource::class, FaqResource::class, NoticeResource::class] as $resource) {
|
|
$this->get($resource::getUrl('index'))->assertOk();
|
|
}
|
|
$this->get(EditContent::getUrl())->assertOk()->assertSee('Webseiten-Texte');
|
|
$this->get(PropertyResource::getUrl('index'))->assertForbidden();
|
|
}
|
|
|
|
public function test_texts_fall_back_to_defaults_and_can_be_saved(): void
|
|
{
|
|
$this->assertStringContainsString('seit über 20 Jahren', Content::get('host.quote'));
|
|
|
|
Livewire::test(EditContent::class)
|
|
->set('data.host__quote', 'Willkommen an der Ostsee')
|
|
->set('data.legal__imprint', '<p>Angaben gemäß § 5 DDG</p><script>alert(1)</script>')
|
|
->call('save')
|
|
->assertNotified('Texte gespeichert');
|
|
|
|
$this->assertSame('Willkommen an der Ostsee', Content::get('host.quote'));
|
|
$this->assertStringContainsString('§ 5 DDG', (string) Content::html('legal.imprint'));
|
|
$this->assertStringNotContainsString('<script>', (string) Content::html('legal.imprint'));
|
|
}
|
|
|
|
public function test_uploaded_photos_get_webp_web_sizes(): void
|
|
{
|
|
$photo = Photo::factory()->create();
|
|
$photo->addMedia(UploadedFile::fake()->image('terrasse.jpg', 3000, 2000))->toMediaCollection(Photo::COLLECTION);
|
|
|
|
$media = $photo->fresh()->getFirstMedia(Photo::COLLECTION);
|
|
foreach (array_keys(Photo::WIDTHS) as $conversion) {
|
|
$this->assertTrue($media->hasGeneratedConversion($conversion), "conversion {$conversion}");
|
|
$this->assertStringEndsWith('.webp', $photo->url($conversion));
|
|
}
|
|
$this->assertStringContainsString('2048w', $photo->srcset());
|
|
}
|
|
|
|
public function test_several_photos_are_uploaded_at_once(): void
|
|
{
|
|
Livewire::test(ListPhotos::class)
|
|
->callAction('bulkUpload', [
|
|
'files' => [UploadedFile::fake()->image('wohn-zimmer.jpg', 1600, 1000), UploadedFile::fake()->image('kueche.jpg', 1600, 1000)],
|
|
'category' => PhotoCategory::Apartment->value,
|
|
])
|
|
->assertNotified('2 Bilder hochgeladen');
|
|
|
|
$this->assertSame(['Wohn zimmer', 'Kueche'], Photo::orderBy('sort_order')->pluck('alt_text')->all());
|
|
}
|
|
|
|
public function test_notices_are_visible_only_within_their_dates(): void
|
|
{
|
|
$this->travelTo(CarbonImmutable::parse('2026-11-10'));
|
|
Notice::factory()->create(['text' => 'aktuell', 'starts_on' => '2026-11-01', 'ends_on' => '2026-11-15']);
|
|
Notice::factory()->create(['text' => 'vorbei', 'ends_on' => '2026-11-09']);
|
|
Notice::factory()->create(['text' => 'inaktiv', 'is_active' => false]);
|
|
Notice::factory()->create(['text' => 'dauerhaft']);
|
|
|
|
$this->assertEqualsCanonicalizing(['aktuell', 'dauerhaft'], Notice::visible()->pluck('text')->all());
|
|
}
|
|
|
|
public function test_amenities_from_the_old_website_are_seeded(): void
|
|
{
|
|
$this->assertGreaterThan(20, Amenity::count());
|
|
$this->assertSame(6, Amenity::where('is_highlight', true)->count());
|
|
}
|
|
}
|