Lass Menüeinträge auf eine Sprungmarke der Zielseite zeigen
Zweiter Schritt in „Ziel ändern“, neue Spalte navigation_items.anchor (nullable, abwärtskompatibel). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b43fbb7d1
commit
04a9a4f83f
5 files changed
+274
-7
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -32,6 +33,7 @@ class NavigationItem extends Model
|
||||
'label',
|
||||
'page_id',
|
||||
'url',
|
||||
'anchor',
|
||||
'placement',
|
||||
'sort_order',
|
||||
'is_visible',
|
||||
@@ -86,7 +88,9 @@ public function href(): ?string
|
||||
}
|
||||
|
||||
if ($this->page !== null) {
|
||||
return $this->page->path === '/' ? url('/') : url($this->page->path);
|
||||
$anchor = PageSections::cleanAnchor($this->anchor);
|
||||
|
||||
return ($this->page->path === '/' ? url('/') : url($this->page->path)).($anchor !== null ? '#'.$anchor : '');
|
||||
}
|
||||
|
||||
if ($this->url === null || $this->url === '' || ! SafeUrl::isSafe($this->url)) {
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Domain\Cms\LinkTargets;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page as CmsPage;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Filament\Support\Bestand;
|
||||
@@ -74,7 +76,7 @@ class Webpraesenz extends Page
|
||||
/** Ausgewählter Eintrag (Schlüssel „e{id}“ oder „n{zähler}“ für neue Einträge). */
|
||||
public ?string $auswahl = null;
|
||||
|
||||
/** @var array<string, array{id: ?int, label: string, page_id: ?int, url: string, placement: string, parent: ?string, is_visible: bool}> */
|
||||
/** @var array<string, array{id: ?int, label: string, page_id: ?int, url: string, anchor: string, placement: string, parent: ?string, is_visible: bool}> */
|
||||
public array $eintraege = [];
|
||||
|
||||
/** Globale Reihenfolge der Schlüssel; entspricht sort_order. @var list<string> */
|
||||
@@ -103,6 +105,9 @@ class Webpraesenz extends Page
|
||||
/** Eintrag, dessen Ziel gerade gewählt wird. */
|
||||
public ?string $zielwahl = null;
|
||||
|
||||
/** Zweiter Schritt der Zielwahl: gewählte Seite, deren Sprungmarke noch zu wählen ist. */
|
||||
public ?int $zielSeite = null;
|
||||
|
||||
public string $zielSuche = '';
|
||||
|
||||
public static function canAccess(): bool
|
||||
@@ -327,6 +332,7 @@ public function ladeMenues(): void
|
||||
'label' => (string) $item->label,
|
||||
'page_id' => $item->page_id,
|
||||
'url' => (string) ($item->url ?? ''),
|
||||
'anchor' => (string) ($item->anchor ?? ''),
|
||||
'placement' => (string) $item->placement,
|
||||
'parent' => $item->parent_id !== null ? 'e'.$item->parent_id : null,
|
||||
'is_visible' => (bool) $item->is_visible,
|
||||
@@ -364,6 +370,7 @@ private function bereichsStaende(): array
|
||||
trim($e['label']),
|
||||
$e['page_id'] !== null ? (int) $e['page_id'] : null,
|
||||
trim($e['url']),
|
||||
trim($e['anchor'] ?? ''),
|
||||
(bool) $e['is_visible'],
|
||||
$this->elternVon($k),
|
||||
];
|
||||
@@ -562,6 +569,7 @@ public function eintragHinzufuegen(): void
|
||||
'label' => '',
|
||||
'page_id' => null,
|
||||
'url' => '',
|
||||
'anchor' => '',
|
||||
'placement' => $this->menue,
|
||||
'parent' => null,
|
||||
'is_visible' => true,
|
||||
@@ -595,7 +603,7 @@ public function updatedEintraege(mixed $value, string $pfad): void
|
||||
match ($feld) {
|
||||
'placement' => $this->bereichGeaendert($k),
|
||||
'parent' => $this->elternGeaendert($k),
|
||||
'page_id' => $this->eintraege[$k]['page_id'] = blank($value) ? null : (int) $value,
|
||||
'page_id' => $this->seiteGeaendert($k, $value),
|
||||
'is_visible' => $this->eintraege[$k]['is_visible'] = (bool) $value,
|
||||
default => null,
|
||||
};
|
||||
@@ -673,10 +681,18 @@ private function ansEnde(string $k): void
|
||||
$this->folge = [...array_values(array_filter($this->folge, fn (string $x): bool => $x !== $k)), $k];
|
||||
}
|
||||
|
||||
/** Eine andere Zielseite hat eigene Sprungmarken: Die bisherige Marke entfällt. */
|
||||
private function seiteGeaendert(string $k, mixed $value): void
|
||||
{
|
||||
$this->eintraege[$k]['page_id'] = blank($value) ? null : (int) $value;
|
||||
$this->eintraege[$k]['anchor'] = '';
|
||||
}
|
||||
|
||||
public function zielAdresseNutzen(string $k): void
|
||||
{
|
||||
if (isset($this->eintraege[$k])) {
|
||||
$this->eintraege[$k]['page_id'] = null;
|
||||
$this->eintraege[$k]['anchor'] = '';
|
||||
$this->js("requestAnimationFrame(() => document.getElementById('menue-adresse')?.focus())");
|
||||
}
|
||||
}
|
||||
@@ -692,6 +708,7 @@ public function oeffneZielwahl(string $k): void
|
||||
public function schliesseZielwahl(): void
|
||||
{
|
||||
$this->zielwahl = null;
|
||||
$this->zielSeite = null;
|
||||
}
|
||||
|
||||
public function waehleZiel(int $seiteId): void
|
||||
@@ -702,8 +719,48 @@ public function waehleZiel(int $seiteId): void
|
||||
|
||||
$this->eintraege[$this->zielwahl]['page_id'] = $seiteId;
|
||||
$this->eintraege[$this->zielwahl]['url'] = '';
|
||||
$this->eintraege[$this->zielwahl]['anchor'] = '';
|
||||
$this->resetErrorBag("eintraege.{$this->zielwahl}.url");
|
||||
$this->zielwahl = null;
|
||||
|
||||
// Hat die Seite Sprungmarken, folgt als zweiter Schritt die Wahl der Marke; sonst ist die Auswahl fertig.
|
||||
if ($this->zielMarken($seiteId) !== []) {
|
||||
$this->zielSeite = $seiteId;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->schliesseZielwahl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zweiter Schritt von „Ziel ändern“: Sprungmarke der gewählten Seite übernehmen (leer = Seitenanfang).
|
||||
*/
|
||||
public function waehleMarke(?string $marke = null): void
|
||||
{
|
||||
if ($this->zielwahl === null || $this->zielSeite === null || ! isset($this->eintraege[$this->zielwahl])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$marke = filled($marke) ? $marke : null;
|
||||
|
||||
if ($marke !== null && ! in_array($marke, array_column($this->zielMarken($this->zielSeite), 'anchor'), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->eintraege[$this->zielwahl]['anchor'] = $marke ?? '';
|
||||
$this->schliesseZielwahl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprungmarken einer Seite für den zweiten Schritt.
|
||||
*
|
||||
* @return list<array{anchor: string, label: string, hidden: bool, published: bool}>
|
||||
*/
|
||||
public function zielMarken(int $seiteId): array
|
||||
{
|
||||
$seite = $this->seitenCache()->get($seiteId);
|
||||
|
||||
return $seite === null ? [] : app(LinkTargets::class)->anchorsForPage($seite);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -755,7 +812,7 @@ public function zielVon(string $k): array
|
||||
|
||||
return $seite === null
|
||||
? ['art' => 'fehlt', 'titel' => null, 'pfad' => null, 'zustand' => ['label' => 'Zielseite nicht mehr vorhanden', 'ton' => 'achtung'], 'seite' => null]
|
||||
: ['art' => 'seite', 'titel' => $seite->latestRevision?->contentTitle() ?: $seite->path, 'pfad' => $seite->path, 'zustand' => $this->seitenZustand($seite), 'seite' => $seite];
|
||||
: ['art' => 'seite', 'titel' => $seite->latestRevision?->contentTitle() ?: $seite->path, 'pfad' => $seite->path.(trim($e['anchor'] ?? '') !== '' ? '#'.trim($e['anchor']) : ''), 'zustand' => $this->seitenZustand($seite), 'seite' => $seite];
|
||||
}
|
||||
|
||||
if (trim($e['url']) !== '') {
|
||||
@@ -919,6 +976,7 @@ private function pruefen(): array
|
||||
|| $alt->label !== $e['label']
|
||||
|| $alt->page_id !== ($e['page_id'] !== null ? (int) $e['page_id'] : null)
|
||||
|| (string) ($alt->url ?? '') !== $e['url']
|
||||
|| (string) ($alt->anchor ?? '') !== trim($e['anchor'] ?? '')
|
||||
|| $alt->placement !== $e['placement']
|
||||
|| ($alt->parent_id !== null ? 'e'.$alt->parent_id : null) !== $this->elternVon($k)
|
||||
|| (bool) $alt->is_visible !== (bool) $e['is_visible']
|
||||
@@ -936,16 +994,19 @@ private function pruefen(): array
|
||||
'placement' => $e['placement'],
|
||||
'page_id' => $e['page_id'],
|
||||
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
||||
'anchor' => trim($e['anchor'] ?? '') === '' ? null : trim($e['anchor']),
|
||||
], [
|
||||
'label' => ['required', 'string', 'max:80'],
|
||||
'placement' => ['required', 'in:'.implode(',', array_keys(self::BEREICHE))],
|
||||
'page_id' => ['nullable', 'integer', 'exists:pages,id'],
|
||||
'url' => ['nullable', 'string', 'max:500', SafeUrl::rule()],
|
||||
'anchor' => ['nullable', 'string', 'max:'.PageSections::MAX_ANCHOR, 'regex:'.PageSections::ANCHOR_PATTERN],
|
||||
], [
|
||||
'label.required' => 'Bitte einen Menütext eingeben.',
|
||||
'label.max' => 'Der Menütext hat höchstens 80 Zeichen.',
|
||||
'url.max' => 'Die Adresse hat höchstens 500 Zeichen.',
|
||||
'page_id.exists' => 'Diese Seite gibt es nicht mehr.',
|
||||
'anchor.regex' => 'Die Sprungmarke ist ungültig. Bitte über „Ziel ändern“ eine vorhandene wählen.',
|
||||
]);
|
||||
|
||||
$meldungen = $validator->errors()->toArray();
|
||||
@@ -1044,6 +1105,8 @@ private function schreiben(array $geaendert): array
|
||||
'label' => trim($e['label']),
|
||||
'page_id' => $e['page_id'] !== null ? (int) $e['page_id'] : null,
|
||||
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
||||
// Eine Sprungmarke gehört zur Zielseite; ohne Seite (freie Adresse) entfällt sie.
|
||||
'anchor' => $e['page_id'] !== null && trim($e['anchor'] ?? '') !== '' ? trim($e['anchor']) : null,
|
||||
'placement' => $e['placement'],
|
||||
'parent_id' => $eltern !== null ? ($ids[$eltern] ?? $this->eintraege[$eltern]['id']) : null,
|
||||
'is_visible' => (bool) $e['is_visible'],
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ergänzend und abwärtskompatibel: Ein Menüeintrag mit Zielseite kann auf eine Sprungmarke dieser Seite zeigen.
|
||||
* Ohne Wert (bisher alle Einträge) führt er zum Seitenanfang. Ältere Programmstände ignorieren die Spalte.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->string('anchor', 60)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->dropColumn('anchor');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -3,6 +3,9 @@
|
||||
$e = $this->eintraege[$this->zielwahl];
|
||||
$seiten = $this->zielSeiten();
|
||||
$aktuell = $e['page_id'] !== null ? (int) $e['page_id'] : null;
|
||||
$zweiter = $this->zielSeite !== null;
|
||||
$marken = $zweiter ? $this->zielMarken($this->zielSeite) : [];
|
||||
$aktuelleMarke = trim($e['anchor'] ?? '');
|
||||
@endphp
|
||||
<div class="vw vw-dialog" role="dialog" aria-modal="true" aria-labelledby="ziel-titel" wire:key="zielwahl-{{ $this->zielwahl }}"
|
||||
x-data x-trap.noscroll="true"
|
||||
@@ -11,12 +14,30 @@
|
||||
<div class="vw-dialog-karte is-schmal">
|
||||
<div class="vw-dialog-kopf">
|
||||
<div>
|
||||
<h2 id="ziel-titel">Zielseite wählen</h2>
|
||||
<h2 id="ziel-titel">{{ $zweiter ? 'Sprungmarke wählen' : 'Zielseite wählen' }}</h2>
|
||||
<p>Für den Menüeintrag <strong>{{ trim($e['label']) ?: 'Ohne Menütext' }}</strong>. Die Auswahl veröffentlicht keine Seite.</p>
|
||||
</div>
|
||||
<button type="button" class="vw-btn is-icon" wire:click="schliesseZielwahl" aria-label="Schließen, ohne zu übernehmen">@include('filament.verwaltung.icon', ['name' => 'x'])</button>
|
||||
</div>
|
||||
<div class="vw-dialog-inhalt vw-zielwahl">
|
||||
@if ($zweiter)
|
||||
<ul class="vw-ziel-liste">
|
||||
<li wire:key="marke-anfang">
|
||||
<x-vw.eintrag as="button" type="button" wire:click="waehleMarke" titel="Seitenanfang" meta="Ohne Sprungmarke" symbol="dokument" @class(['is-aktuell' => $aktuelleMarke === '']) aria-current="{{ $aktuelleMarke === '' ? 'true' : 'false' }}"></x-vw.eintrag>
|
||||
</li>
|
||||
@foreach ($marken as $marke)
|
||||
<li wire:key="marke-{{ $marke['anchor'] }}">
|
||||
<x-vw.eintrag as="button" type="button" wire:click="waehleMarke('{{ $marke['anchor'] }}')" :titel="$marke['label']" :meta="'#'.$marke['anchor']" symbol="dokument" @class(['is-aktuell' => $aktuelleMarke === $marke['anchor']]) aria-current="{{ $aktuelleMarke === $marke['anchor'] ? 'true' : 'false' }}">
|
||||
<span class="vw-zustaende">
|
||||
@if ($marke['hidden'])<span class="vw-zustand is-achtung">Abschnitt ausgeblendet, Link führt ins Leere</span>@endif
|
||||
@if (! $marke['published'] && ! $marke['hidden'])<span class="vw-zustand is-offen">Noch nicht veröffentlicht</span>@endif
|
||||
</span>
|
||||
</x-vw.eintrag>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<p class="vw-feld-hilfe">Der Menüeintrag führt dann zu diesem Abschnitt der Seite. „Seitenanfang“ lässt die Marke weg.</p>
|
||||
@else
|
||||
<label class="vw-feldlabel" for="ziel-suche">Seite suchen</label>
|
||||
<span class="vw-suchfeld">
|
||||
@include('filament.verwaltung.icon', ['name' => 'suche'])
|
||||
@@ -36,10 +57,11 @@
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
<div class="vw-dialog-fuss">
|
||||
<div class="vw-dialog-fuss-zeile">
|
||||
<span class="vw-feld-hilfe">Ein Klick übernimmt die Seite als Ziel in den Arbeitsstand.</span>
|
||||
<span class="vw-feld-hilfe">{{ $zweiter ? 'Ein Klick übernimmt die Sprungmarke in den Arbeitsstand.' : 'Ein Klick übernimmt die Seite als Ziel in den Arbeitsstand.' }}</span>
|
||||
<div class="vw-knoepfe">
|
||||
<button type="button" class="vw-btn" wire:click="schliesseZielwahl">Abbrechen</button>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Pages\Webpraesenz;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Features\SupportTesting\Testable;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Menüeinträge mit Sprungmarke: zweiter Schritt der Zielwahl, Speichern, Wirkung in der Navigation der Website.
|
||||
*/
|
||||
class WebpraesenzAnchorTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
private function menus(): Testable
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return Livewire::withQueryParams(['bereich' => 'menues'])->actingAs($editor, 'staff')->test(Webpraesenz::class);
|
||||
}
|
||||
|
||||
private function pageWithAnchors(): Page
|
||||
{
|
||||
$service = app(PageService::class);
|
||||
$page = Page::query()->create(['path' => '/kurse']);
|
||||
$revision = $service->saveRevision($page, [
|
||||
['layout' => 'u4', 'style' => [], 'name' => 'Anmeldung', 'anchor' => 'anmeldung', 'slots' => [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Kurse']]]],
|
||||
['layout' => 'u4', 'style' => [], 'anchor' => 'preise', 'hidden' => true, 'slots' => [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Preise']]]],
|
||||
], null, null, null);
|
||||
$service->publish($page, $revision);
|
||||
|
||||
return $page->fresh();
|
||||
}
|
||||
|
||||
public function test_a_page_with_anchors_leads_to_a_second_step_and_the_anchor_is_saved(): void
|
||||
{
|
||||
$page = $this->pageWithAnchors();
|
||||
|
||||
$this->menus()
|
||||
->call('zeigeMenue', 'header')
|
||||
->call('eintragHinzufuegen')
|
||||
->set('eintraege.n1.label', 'Kurs anmelden')
|
||||
->call('oeffneZielwahl', 'n1')
|
||||
->call('waehleZiel', $page->id)
|
||||
->assertSet('zielSeite', $page->id)
|
||||
->assertSet('zielwahl', 'n1')
|
||||
->assertSee('Sprungmarke wählen')
|
||||
->assertSee('Anmeldung')
|
||||
->assertSee('Abschnitt ausgeblendet')
|
||||
->call('waehleMarke', 'anmeldung')
|
||||
->assertSet('zielwahl', null)
|
||||
->assertSet('zielSeite', null)
|
||||
->assertSet('eintraege.n1.anchor', 'anmeldung')
|
||||
->call('speichern')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$item = NavigationItem::query()->where('label', 'Kurs anmelden')->firstOrFail();
|
||||
$this->assertSame($page->id, $item->page_id);
|
||||
$this->assertSame('anmeldung', $item->anchor);
|
||||
$this->assertSame(url('/kurse').'#anmeldung', $item->href());
|
||||
|
||||
$this->get('/')->assertOk()->assertSee('/kurse#anmeldung', false);
|
||||
}
|
||||
|
||||
public function test_the_page_start_leaves_the_anchor_empty_and_unknown_anchors_are_refused(): void
|
||||
{
|
||||
$page = $this->pageWithAnchors();
|
||||
|
||||
$component = $this->menus()
|
||||
->call('zeigeMenue', 'header')
|
||||
->call('eintragHinzufuegen')
|
||||
->set('eintraege.n1.label', 'Kurse')
|
||||
->call('oeffneZielwahl', 'n1')
|
||||
->call('waehleZiel', $page->id)
|
||||
->call('waehleMarke', 'gibt-es-nicht')
|
||||
->assertSet('zielwahl', 'n1')
|
||||
->assertSet('eintraege.n1.anchor', '')
|
||||
->call('waehleMarke')
|
||||
->assertSet('zielwahl', null)
|
||||
->call('speichern')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$item = NavigationItem::query()->where('label', 'Kurse')->firstOrFail();
|
||||
$this->assertNull($item->anchor);
|
||||
$this->assertSame(url('/kurse'), $item->href());
|
||||
$component->assertSet('eintraege.e'.$item->id.'.anchor', '');
|
||||
}
|
||||
|
||||
public function test_a_new_target_page_or_a_free_address_drops_the_old_anchor(): void
|
||||
{
|
||||
$page = $this->pageWithAnchors();
|
||||
$impressum = Page::query()->where('path', '/impressum')->firstOrFail();
|
||||
|
||||
$this->menus()
|
||||
->call('zeigeMenue', 'header')
|
||||
->call('eintragHinzufuegen')
|
||||
->set('eintraege.n1.label', 'Wechsel')
|
||||
->call('oeffneZielwahl', 'n1')
|
||||
->call('waehleZiel', $page->id)
|
||||
->call('waehleMarke', 'anmeldung')
|
||||
->assertSet('eintraege.n1.anchor', 'anmeldung')
|
||||
->call('oeffneZielwahl', 'n1')
|
||||
->call('waehleZiel', $impressum->id)
|
||||
->assertSet('eintraege.n1.anchor', '')
|
||||
->assertSet('zielwahl', null)
|
||||
->call('oeffneZielwahl', 'n1')
|
||||
->call('waehleZiel', $page->id)
|
||||
->call('waehleMarke', 'anmeldung')
|
||||
->call('zielAdresseNutzen', 'n1')
|
||||
->assertSet('eintraege.n1.anchor', '')
|
||||
->assertSet('eintraege.n1.page_id', null);
|
||||
}
|
||||
|
||||
public function test_a_stale_anchor_in_the_working_state_is_refused_on_save(): void
|
||||
{
|
||||
$page = $this->pageWithAnchors();
|
||||
|
||||
$this->menus()
|
||||
->call('zeigeMenue', 'header')
|
||||
->call('eintragHinzufuegen')
|
||||
->set('eintraege.n1.label', 'Defekt')
|
||||
->set('eintraege.n1.page_id', $page->id)
|
||||
->set('eintraege.n1.anchor', 'Kaputt!')
|
||||
->call('speichern')
|
||||
->assertHasErrors(['eintraege.n1.anchor']);
|
||||
|
||||
$this->assertDatabaseMissing('navigation_items', ['label' => 'Defekt']);
|
||||
}
|
||||
|
||||
public function test_the_anchor_does_not_change_which_entry_counts_as_active(): void
|
||||
{
|
||||
$page = $this->pageWithAnchors();
|
||||
$item = NavigationItem::query()->create(['label' => 'Kurse', 'page_id' => $page->id, 'anchor' => 'anmeldung', 'placement' => 'header', 'sort_order' => 1]);
|
||||
|
||||
$this->assertSame('/kurse', $item->fresh()->targetPath());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user