b2in/tests/Feature/DisplayWebFeedTest.php
Kevin Adametz 6d53243ea6 B2in Interior: Relaunch der Website, Kernmarken-CMS und Terminanfrage
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>
2026-08-28 15:31:19 +00:00

142 lines
4.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
use App\Models\Display;
use App\Models\DisplayPlaylist;
use App\Models\DisplayPlaylistItem;
use App\Models\DisplayVersion;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
function publishedDisplay(array $attributes = []): Display
{
$display = Display::factory()->create(array_merge(['is_active' => true], $attributes));
$playlist = DisplayPlaylist::factory()->create([
'display_id' => $display->id,
'status' => DisplayPlaylist::STATUS_PUBLISHED,
'published_at' => now(),
]);
DisplayPlaylistItem::factory()->create([
'display_playlist_id' => $playlist->id,
'display_version_id' => DisplayVersion::factory()->create()->id,
'sort_order' => 0,
]);
return $display->fresh();
}
// ========================================
// Embed-Route
// ========================================
it('serves the player for a published display', function () {
$display = publishedDisplay();
$this->get(route('display.embed', ['display' => $display->id]))
->assertSuccessful()
->assertHeader('X-Robots-Tag', 'noindex');
});
it('never hands out a preview token', function () {
$display = publishedDisplay();
$token = $display->ensurePreviewToken();
// Die Route liefert eine Datei (BinaryFileResponse) – der Inhalt kommt aus der Datei selbst.
$response = $this->get(route('display.embed', ['display' => $display->id]))->assertSuccessful();
$body = file_get_contents($response->baseResponse->getFile()->getPathname());
expect($body)->not->toContain($token)
->and($body)->toContain('DisplayPlayer');
});
it('returns 404 for an inactive display', function () {
$display = publishedDisplay(['is_active' => false]);
$this->get(route('display.embed', ['display' => $display->id]))->assertNotFound();
});
it('returns 404 while only a draft exists', function () {
$display = Display::factory()->create(['is_active' => true]);
$playlist = DisplayPlaylist::factory()->create([
'display_id' => $display->id,
'status' => DisplayPlaylist::STATUS_DRAFT,
]);
DisplayPlaylistItem::factory()->create([
'display_playlist_id' => $playlist->id,
'display_version_id' => DisplayVersion::factory()->create()->id,
'sort_order' => 0,
]);
$this->get(route('display.embed', ['display' => $display->id]))->assertNotFound();
});
it('returns 404 for a published playlist without modules', function () {
$display = Display::factory()->create(['is_active' => true]);
DisplayPlaylist::factory()->create([
'display_id' => $display->id,
'status' => DisplayPlaylist::STATUS_PUBLISHED,
]);
$this->get(route('display.embed', ['display' => $display->id]))->assertNotFound();
});
it('returns 404 for an unknown display', function () {
$this->get('/embed/display/999999')->assertNotFound();
});
// ========================================
// Sektion auf der Website
// ========================================
it('embeds the display on the homepage once one is published', function () {
$display = publishedDisplay();
$this->get('/')
->assertSuccessful()
->assertSee(route('display.embed', ['display' => $display->id]))
->assertSee('Aktuelles aus unserem');
});
it('shows no display section while nothing is published', function () {
$this->get('/')
->assertSuccessful()
->assertDontSee('/embed/display/')
->assertDontSee('Aktuelles aus unserem');
});
it('prefers the display that is configured in the cms', function () {
publishedDisplay();
$second = publishedDisplay();
\FluxCms\Core\Models\CmsContent::create([
'group' => 'referenzen',
'key' => 'display_feed',
'type' => 'json',
'value' => ['de' => ['title' => 'Showroom', 'display_id' => (string) $second->id]],
'order' => 0,
]);
$this->get('/')
->assertSuccessful()
->assertSee(route('display.embed', ['display' => $second->id]));
});
it('falls back to another display when the configured one is gone', function () {
$display = publishedDisplay();
\FluxCms\Core\Models\CmsContent::create([
'group' => 'referenzen',
'key' => 'display_feed',
'type' => 'json',
'value' => ['de' => ['title' => 'Showroom', 'display_id' => '999999']],
'order' => 0,
]);
$this->get('/')
->assertSuccessful()
->assertSee(route('display.embed', ['display' => $display->id]));
});