- Seitenliste: zuletzt bearbeitete Seiten zuerst, „Zuletzt bearbeitet“ in deutscher Zeit (jede Revision und Veröffentlichung aktualisiert die Seite), Pfad und Datum sortierbar, 25/50/100 je Seite. Bisher stand eine neue Seite ohne Suche auf einer späteren Listenseite. - Kopfzeile und Fußbereich zeigen die freigegebene Lara-&-Felix- Wortmarke (Kompaktfassung aus Brand-UI-Kit 08) als zugeschnittene WebP-Ableitung mit festen Maßen; Ausgangszustand ≈ 80 px, kompakt 60 px, Smartphone 48 px. Mitgliederbereich unverändert. - Abschnittsgestaltung „Abstand oben“ (wie Abstand / gering / kein): Der erste Abschnitt kann direkt unter der Kopfzeile beginnen; der Abstand unten und alle anderen Abschnitte bleiben unverändert. Tests: Erwartung an die Wortmarke bewusst angepasst (brand-logo statt brand-lockup); neue Tests für Liste, Bearbeitungsdatum und Abstand oben. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
4.4 KiB
PHP
97 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Cms\Page;
|
|
use App\Domain\Cms\PageService;
|
|
use App\Domain\Cms\Sections\PageSections;
|
|
use App\Domain\Cms\Sections\SectionStyle;
|
|
use App\Filament\Resources\Pages\Pages\ListPages;
|
|
use App\Models\User;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Nachprüfung 18.11.2026: Jede Seite ist in der Seitenliste ohne Suche auffindbar (zuletzt bearbeitete zuerst),
|
|
* und der erste Abschnitt kann ohne oder mit geringem Abstand an die Kopfzeile anschließen.
|
|
*/
|
|
class CmsPageListAndSpacingTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Carbon::setTestNow();
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_page_list_shows_the_most_recently_edited_page_first(): void
|
|
{
|
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
|
$editor = User::factory()->redakteur()->create();
|
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
$service = app(PageService::class);
|
|
|
|
Carbon::setTestNow('2026-11-18 08:00:00');
|
|
$pages = collect(range(1, 12))->map(fn (int $i) => Page::query()->create(['path' => '/seite-'.$i]));
|
|
|
|
// Die zuerst angelegte Seite wird zuletzt bearbeitet: Sie muss vorn stehen, obwohl sie die kleinste Kennung hat.
|
|
Carbon::setTestNow('2026-11-18 09:30:00');
|
|
$service->saveRevision($pages->first(), [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Neu']]], null, null, $editor);
|
|
$this->assertSame('2026-11-18 09:30:00', $pages->first()->fresh()->updated_at->toDateTimeString());
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(ListPages::class)
|
|
->assertCanSeeTableRecords($pages->all())
|
|
->assertCanSeeTableRecords([$pages->first(), $pages->last()], inOrder: true)
|
|
->assertSee('18.11.2026 10:30', false)
|
|
->assertSee('Zuletzt bearbeitet');
|
|
}
|
|
|
|
public function test_publishing_also_counts_as_an_edit(): void
|
|
{
|
|
Carbon::setTestNow('2026-11-18 08:00:00');
|
|
$page = Page::query()->create(['path' => '/veroeffentlichen']);
|
|
$revision = app(PageService::class)->saveRevision($page, [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'A']]], null, null, null);
|
|
|
|
Carbon::setTestNow('2026-11-18 11:00:00');
|
|
app(PageService::class)->publish($page->fresh(), $revision);
|
|
|
|
$this->assertSame('2026-11-18 11:00:00', $page->fresh()->updated_at->toDateTimeString());
|
|
}
|
|
|
|
public function test_first_section_can_start_directly_below_the_header_without_changing_other_spacing(): void
|
|
{
|
|
$page = Page::query()->create(['path' => '/abstand']);
|
|
$service = app(PageService::class);
|
|
$hero = ['type' => 'hero', 'v' => 2, 'data' => ['heading' => 'Einstieg']];
|
|
$revision = $service->saveRevision($page, [
|
|
['layout' => 'u4', 'style' => ['spacing_top' => 'none', 'spacing' => 'large'], 'slots' => [$hero]],
|
|
['layout' => 'u4', 'style' => ['spacing_top' => 'small'], 'slots' => [['type' => 'prose', 'v' => 1, 'data' => ['body' => 'Text']]]],
|
|
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'prose', 'v' => 1, 'data' => ['body' => 'Weiter']]]],
|
|
], null, null, null);
|
|
$service->publish($page, $revision);
|
|
|
|
$html = $this->get('/abstand')->assertOk()->getContent();
|
|
$this->assertMatchesRegularExpression('#class="page-section section-bg-default section-width-standard section-space-large section-space-top-none section-layout-u4"#', $html);
|
|
$this->assertStringContainsString('section-space-normal section-space-top-small section-layout-u4', $html);
|
|
$this->assertSame(2, substr_count($html, 'section-space-top-'), 'Ohne Angabe gilt der normale Abstand; keine zusätzliche Klasse.');
|
|
$this->assertSame('same', $revision->sections[2]['style']['spacing_top']);
|
|
$this->assertStringContainsString('oben kein abstand', SectionStyle::summary($revision->sections[0]['style']));
|
|
}
|
|
|
|
public function test_top_spacing_accepts_only_its_enumerated_values(): void
|
|
{
|
|
$this->expectException(ValidationException::class);
|
|
|
|
app(PageSections::class)->normalize([
|
|
['layout' => 'u4', 'style' => ['spacing_top' => '0px'], 'slots' => [['type' => 'prose', 'v' => 1, 'data' => ['body' => 'Text']]]],
|
|
]);
|
|
}
|
|
}
|