Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 10m3s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 10m59s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 11m24s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m26s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m54s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 8m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m26s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 49s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
75 lines
3.6 KiB
PHP
75 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Layout\Footer;
|
|
use App\Models\Role;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class FooterTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private function content(): array
|
|
{
|
|
return ['blocks' => [
|
|
['id' => 'text1', 'type' => 'text', 'data' => ['html' => '<p>Musterstift gGmbH, Hauptstraße 1</p>']],
|
|
['id' => 'text2', 'type' => 'text', 'data' => ['html' => '<p>Nur für die Pflege</p>'], 'visibility' => ['role' => ['999999']]],
|
|
['id' => 'tile1', 'type' => 'dashboard.widget', 'data' => ['widget' => 'core.quick-links']],
|
|
]];
|
|
}
|
|
|
|
public function test_draft_publish_and_rendering_for_everyone(): void
|
|
{
|
|
$admin = User::factory()->admin()->create();
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)->get('/')->assertInertia(fn (Assert $p) => $p->where('footerContent', null));
|
|
$this->actingAs($admin)->get('/fusszeile/gestalten')->assertOk()->assertInertia(fn (Assert $p) => $p
|
|
->component('HomepageEditor')->where('config.kind', 'footer')->has('content.blocks', 1));
|
|
|
|
$this->actingAs($admin)->putJson('/fusszeile/gestalten/entwurf', ['content' => $this->content()])->assertOk()->assertJsonPath('state.has_draft', true);
|
|
$this->actingAs($user)->get('/')->assertInertia(fn (Assert $p) => $p->where('footerContent', null));
|
|
|
|
// Vorschau des Entwurfs nur für die Administration
|
|
$this->actingAs($admin)->get('/?fusszeile=entwurf')->assertInertia(fn (Assert $p) => $p->has('footerContent.blocks', 2));
|
|
$this->actingAs($user)->get('/?fusszeile=entwurf')->assertInertia(fn (Assert $p) => $p->where('footerContent', null));
|
|
|
|
$this->actingAs($admin)->postJson('/fusszeile/gestalten/veroeffentlichen')->assertOk()->assertJsonPath('state.published', true);
|
|
|
|
// Zielgruppen-Blöcke fallen für andere weg, Kacheln werden aufgelöst
|
|
$this->actingAs($user)->get('/neuigkeiten')->assertInertia(fn (Assert $p) => $p
|
|
->has('footerContent.blocks', 2)
|
|
->where('footerContent.blocks.0.data.html', '<p>Musterstift gGmbH, Hauptstraße 1</p>')
|
|
->where('footerContent.blocks.1.type', 'dashboard.widget'));
|
|
}
|
|
|
|
public function test_only_appearance_managers_edit_and_hiding_works(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
$this->actingAs($user)->get('/fusszeile/gestalten')->assertForbidden();
|
|
$this->actingAs($user)->postJson('/fusszeile/gestalten/veroeffentlichen')->assertForbidden();
|
|
|
|
$role = Role::query()->create(['name' => 'Kommunikation']);
|
|
$role->grants()->create(['ability' => 'appearance.manage']);
|
|
$editor = User::factory()->withRoles([$role])->create();
|
|
|
|
$this->actingAs($editor)->postJson('/fusszeile/gestalten/veroeffentlichen', ['content' => $this->content()])->assertOk();
|
|
$this->assertTrue(app(Footer::class)->isActive());
|
|
$this->actingAs($editor)->get('/admin/startseite-menue/fusszeile')->assertOk()->assertSee('veröffentlicht');
|
|
|
|
app(Footer::class)->unpublish();
|
|
$this->actingAs($user)->get('/')->assertInertia(fn (Assert $p) => $p->where('footerContent', null));
|
|
$this->assertCount(1, app(Footer::class)->revisions());
|
|
}
|
|
|
|
public function test_homepage_editor_still_works_with_the_shared_base(): void
|
|
{
|
|
$admin = User::factory()->admin()->create();
|
|
|
|
$this->actingAs($admin)->get('/startseite/gestalten')->assertOk()->assertInertia(fn (Assert $p) => $p->where('config.kind', 'homepage')->has('state.mode'));
|
|
}
|
|
}
|