Umsetzung von AP0-AP6 aus dev/2026-08-28/entwicklungsplan.md sowie der vorab gefundenen Befunde T1 und B1-B13. Befunde - CmsContentSeeder überschrieb bei jedem Lauf alle redaktionellen Inhalte; jetzt Redaktionsschutz plus gezielter Relaunch-Seeder (B1) - Magazin-CMS war nicht ans Frontend angebunden, Artikel jetzt über Slugs mit 301 von den alten numerischen URLs (B2) - Vier veröffentlichte Display-Playlists zeigten auf b2in.test und wären live nicht ladbar gewesen (B13) - Info-Tablet speicherte geleerte Öffnungszeiten nicht (T1) - /service und /portfolio lieferten seit Februar 500 (B12) Website - Startseite neu strukturiert und umgetextet, eigene Seite /marken mit Detailseite je Kernmarke, /netzwerk und Altrouten leiten dorthin - Galerie je Marke, getrennt nach realisierten Projekten und Visualisierungen; ohne gesetzte Kategorie gilt ein Bild als Entwurf - Seite /referenzen, gespeist aus den Markengalerien - Showroom-Display im 9:16-Rahmen über eine schreibgeschützte Embed-Route ohne Preview-Token - Terminanfrage-Widget auf allen Seiten, Markenauswahl aus dem CMS, WhatsApp per Klick-zum-Chat-Link mit vorbereitetem Text - FAQ, Über-uns, Kontakt und Magazin inhaltlich auf Interior umgestellt Sonstiges - Vorschau-Instanzen liefern noindex und verlinken sich bei unbekanntem Host auf sich selbst statt auf eine fremde Domain - Seeder-Zugangsdaten aus dem Code in die Konfiguration (B8) - Ablauf für die Vorschau: dev/2026-08-28/preview-deployment.md 833 Tests grün (3084 Assertions), Pint sauber. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
246 lines
8.1 KiB
PHP
246 lines
8.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\CmsBrand;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Volt\Volt;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
url()->forceRootUrl('https://'.config('domains.domain_portal'));
|
|
});
|
|
|
|
it('requires authentication', function () {
|
|
$this->get(route('cms.brands.index'))->assertRedirect('/login');
|
|
});
|
|
|
|
it('renders for authenticated users', function () {
|
|
$this->actingAs(User::factory()->create())
|
|
->get(route('cms.brands.index'))
|
|
->assertSuccessful()
|
|
->assertSee('Kernmarken');
|
|
});
|
|
|
|
it('creates a brand', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'neue-marke')
|
|
->set('brandName', 'Neue Marke')
|
|
->set('tagline', 'Ein Claim.')
|
|
->set('teaser', 'Kurztext für die Kachel.')
|
|
->call('save')
|
|
->assertHasNoErrors();
|
|
|
|
$brand = CmsBrand::where('slug', 'neue-marke')->firstOrFail();
|
|
|
|
expect($brand->getTranslation('name', 'de'))->toBe('Neue Marke');
|
|
expect($brand->getTranslation('tagline', 'de'))->toBe('Ein Claim.');
|
|
expect($brand->is_published)->toBeTrue();
|
|
});
|
|
|
|
it('rejects a slug that is already taken', function () {
|
|
CmsBrand::factory()->create(['slug' => 'cabinet']);
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'cabinet')
|
|
->set('brandName', 'Zweite CABINET')
|
|
->call('save');
|
|
|
|
expect(CmsBrand::where('slug', 'cabinet')->count())->toBe(1);
|
|
});
|
|
|
|
it('rejects a slug with invalid characters', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'Nicht Erlaubt!')
|
|
->set('brandName', 'Test')
|
|
->call('save')
|
|
->assertHasErrors(['slug']);
|
|
});
|
|
|
|
it('requires a name', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'ohne-namen')
|
|
->set('brandName', '')
|
|
->call('save')
|
|
->assertHasErrors(['brandName']);
|
|
});
|
|
|
|
it('edits an existing brand', function () {
|
|
$brand = CmsBrand::factory()->create(['slug' => 'cabinet', 'name' => ['de' => 'CABINET']]);
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openEdit', $brand->id)
|
|
->assertSet('slug', 'cabinet')
|
|
->set('tagline', 'Neuer Claim.')
|
|
->call('save')
|
|
->assertHasNoErrors();
|
|
|
|
expect($brand->fresh()->getTranslation('tagline', 'de'))->toBe('Neuer Claim.');
|
|
});
|
|
|
|
it('keeps both languages side by side', function () {
|
|
$brand = CmsBrand::factory()->create(['slug' => 'cabinet', 'name' => ['de' => 'CABINET', 'en' => 'CABINET']]);
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openEdit', $brand->id)
|
|
->set('tagline', 'Deutscher Claim')
|
|
->call('save')
|
|
->call('openEdit', $brand->id)
|
|
->call('switchLocale', 'en')
|
|
->set('tagline', 'English claim')
|
|
->call('save');
|
|
|
|
expect($brand->fresh()->getTranslation('tagline', 'de'))->toBe('Deutscher Claim');
|
|
expect($brand->fresh()->getTranslation('tagline', 'en'))->toBe('English claim');
|
|
});
|
|
|
|
it('drops empty service rows on save', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'mit-leistungen')
|
|
->set('brandName', 'Mit Leistungen')
|
|
->set('services', [
|
|
['title' => 'Aufmaß', 'description' => 'Vor Ort.'],
|
|
['title' => '', 'description' => ''],
|
|
])
|
|
->call('save');
|
|
|
|
expect(CmsBrand::where('slug', 'mit-leistungen')->firstOrFail()->services)->toHaveCount(1);
|
|
});
|
|
|
|
it('toggles the published state', function () {
|
|
$brand = CmsBrand::factory()->create(['is_published' => true]);
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')->call('togglePublished', $brand->id);
|
|
|
|
expect($brand->fresh()->is_published)->toBeFalse();
|
|
});
|
|
|
|
it('deletes a brand', function () {
|
|
$brand = CmsBrand::factory()->create();
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')->call('deleteBrand', $brand->id);
|
|
|
|
expect(CmsBrand::find($brand->id))->toBeNull();
|
|
});
|
|
|
|
it('saves the overview text and the highlights', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'mit-merkmalen')
|
|
->set('brandName', 'Mit Merkmalen')
|
|
->set('summary', "Erster Absatz.\n\nZweiter Absatz.")
|
|
->set('highlights', ['Erstes Merkmal', '', 'Zweites Merkmal'])
|
|
->call('save')
|
|
->assertHasNoErrors();
|
|
|
|
$brand = CmsBrand::where('slug', 'mit-merkmalen')->firstOrFail();
|
|
|
|
expect($brand->getTranslation('summary', 'de'))->toBe("Erster Absatz.\n\nZweiter Absatz.");
|
|
expect($brand->highlights)->toBe(['Erstes Merkmal', 'Zweites Merkmal']);
|
|
});
|
|
|
|
it('shows a brand added in the admin on the overview page', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'ganz-neue-marke')
|
|
->set('brandName', 'Ganz neue Marke')
|
|
->set('tagline', 'Frisch dabei.')
|
|
->set('summary', 'Beschreibung für die Übersicht.')
|
|
->set('highlights', ['Ein Merkmal'])
|
|
->call('save');
|
|
|
|
$this->get('/marken')
|
|
->assertSuccessful()
|
|
->assertSee('Ganz neue Marke')
|
|
->assertSee('Beschreibung für die Übersicht.', false)
|
|
->assertSee('Ein Merkmal')
|
|
->assertSee('/marken/ganz-neue-marke');
|
|
});
|
|
|
|
// ========================================
|
|
// Galerie
|
|
// ========================================
|
|
|
|
it('adds gallery entries with the category that was chosen', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
$component = Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->call('addGalleryImage', 'project')
|
|
->call('addGalleryImage', 'inspiration');
|
|
|
|
expect($component->get('gallery')[0]['category'])->toBe('project')
|
|
->and($component->get('gallery')[1]['category'])->toBe('inspiration');
|
|
});
|
|
|
|
it('saves the gallery with category and caption', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'mit-galerie')
|
|
->set('brandName', 'Mit Galerie')
|
|
->set('gallery', [
|
|
['image' => 'projekt.webp', 'category' => 'project', 'caption' => 'Ankleide in Bielefeld'],
|
|
['image' => 'entwurf.webp', 'category' => 'inspiration', 'caption' => ''],
|
|
])
|
|
->call('save')
|
|
->assertHasNoErrors();
|
|
|
|
$gallery = CmsBrand::where('slug', 'mit-galerie')->firstOrFail()->gallery;
|
|
|
|
expect($gallery)->toBe([
|
|
['image' => 'projekt.webp', 'category' => 'project', 'caption' => 'Ankleide in Bielefeld'],
|
|
['image' => 'entwurf.webp', 'category' => 'inspiration', 'caption' => ''],
|
|
]);
|
|
});
|
|
|
|
it('does not let an unknown category slip through as a completed project', function () {
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openCreate')
|
|
->set('slug', 'geschummelt')
|
|
->set('brandName', 'Geschummelt')
|
|
->set('gallery', [['image' => 'a.webp', 'category' => 'referenz']])
|
|
->call('save');
|
|
|
|
expect(CmsBrand::where('slug', 'geschummelt')->firstOrFail()->gallery[0]['category'])
|
|
->toBe(CmsBrand::GALLERY_INSPIRATION);
|
|
});
|
|
|
|
it('removes a gallery entry', function () {
|
|
$brand = CmsBrand::factory()->withGallery(projects: 2, inspirations: 1)->create(['slug' => 'mit-bildern']);
|
|
$this->actingAs(User::factory()->create());
|
|
|
|
Volt::test('admin.cms.brands-index')
|
|
->call('openEdit', $brand->id)
|
|
->call('removeGalleryImage', 0)
|
|
->call('save');
|
|
|
|
expect($brand->fresh()->gallery)->toHaveCount(2);
|
|
});
|