b2in/tests/Feature/FourthBrandTest.php

114 lines
4.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Livewire\Web\Components\Ui\AppointmentWidget;
use App\Models\CmsBrand;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
// ========================================
// Otterpohl als vierte Kernmarke (Arbeitsplan 14.09., Punkt 1.2; Slug „tischlerei“, Nachtrag 9 + 15)
// ========================================
beforeEach(function () {
$this->seed(\Database\Seeders\CmsBrandSeeder::class);
});
it('creates Otterpohl as the fourth brand without touching the existing ones', function () {
expect(CmsBrand::count())->toBe(4);
$brand = CmsBrand::where('slug', 'tischlerei')->firstOrFail();
expect($brand->order)->toBe(4)
->and($brand->is_published)->toBeTrue()
->and($brand->getTranslation('name', 'de'))->toBe('Otterpohl Möbelservice')
->and($brand->logo)->toBe('marken/otterpohl.png')
->and($brand->sections)->toHaveCount(3)
->and($brand->services)->toHaveCount(8);
// Erneutes Seeden legt nichts doppelt an.
$this->seed(\Database\Seeders\CmsBrandSeeder::class);
expect(CmsBrand::count())->toBe(4);
});
it('shows four tiles on the homepage in a two by two grid', function () {
$html = $this->get('/')->assertSuccessful()->getContent();
expect($html)->toContain('Otterpohl')
->toContain('/marken/tischlerei')
->toMatch('/<div [^>]*class="grid sm:grid-cols-2 gap-8[^"]*"/')
->not->toContain('xl:grid-cols-4');
});
it('lists Otterpohl on the brands page after the three established brands', function () {
$html = $this->get('/marken')->assertSuccessful()->getContent();
preg_match_all('#wire:key="brand-([a-z-]+)"#', $html, $matches);
expect($matches[1])->toBe(['cabinet', 'rotpunkt', 'februe', 'tischlerei']);
expect($html)->toContain('Individuelle Möbel, Türen, Treppen und Küchen');
});
it('serves the Otterpohl detail page with the delivered texts and the logo', function () {
$this->get('/marken/tischlerei')
->assertSuccessful()
->assertSee('marken/otterpohl.png')
->assertSee('Nicht easy click &amp; buy. Aber dennoch easy to get.', false)
->assertSee('Ziemlich nah an der eierlegenden Wollmilchsau')
->assertSee('Vom einzelnen Möbel bis zum ganzen Raum', false)
->assertSee('Planung trifft Handwerk')
->assertSee('Türen &amp; Treppen', false)
->assertSee('Lack &amp; Echtholzfurnier', false)
->assertSee('Das Ganze statt nur das Einzelne')
->assertSee('data-appointment-topic="tischlerei"', false);
});
it('carries the v2 text: no more since-2014 claim, closing block as cta', function () {
$html = $this->get('/marken/tischlerei')->assertSuccessful()->getContent();
// Die lange Fassung vom 17.09. ist komplett abgelöst.
expect($html)->not->toContain('Seit 2014')
->not->toContain('Farbe darf auch genau die Farbe sein')
->not->toContain('Ihre Idee. Handwerklich umgesetzt.');
// Der Schlussblock der Zulieferung steht als Abschluss hinter Leistungen und Galerie.
// Ohne Livewire-Snapshot vergleichen: er trägt die Felder in Datenreihenfolge.
$visible = preg_replace('/wire:snapshot="[^"]*"/', '', $html) ?? $html;
$services = strpos($visible, 'Individuelle Möbel &amp; Sonderanfertigungen');
$closing = strpos($visible, 'Das Ganze statt nur das Einzelne');
expect($services)->not->toBeFalse()
->and($closing)->not->toBeFalse()
->and($services < $closing)->toBeTrue();
});
it('offers the joinery among the other brands of every detail page, three across', function () {
$html = $this->get('/marken/cabinet')->assertSuccessful()->getContent();
expect($html)->toContain('other-tischlerei')
->toContain('sm:grid-cols-2 lg:grid-cols-3');
});
it('labels the widget on the joinery page and offers the joinery as a topic everywhere', function () {
$this->get('/marken/tischlerei')
->assertSuccessful()
->assertSee('Persönliche Beratung zur Maßarbeit vereinbaren', false);
expect(Livewire::test(AppointmentWidget::class)->get('topics'))->toHaveKey('tischlerei');
$this->get('/contact')
->assertSuccessful()
->assertSee('value="tischlerei"', false);
});
it('keeps Otterpohl in the lang fallback while no brands are maintained', function () {
CmsBrand::query()->delete();
$this->get('/')
->assertSuccessful()
->assertSee('Otterpohl Möbelservice')
->assertSee('Nicht easy click &amp; buy. Aber dennoch easy to get.', false);
});