Beiträge mit dem Baukasten der Seiten, Galerie-Großansicht mit Blättern
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m41s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m57s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m59s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m35s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m41s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m57s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m59s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m35s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3b72b5327e
commit
bdd21a38cb
164 changed files with 1276 additions and 623 deletions
|
|
@ -158,7 +158,7 @@ class NewsWorkflowTest extends TestCase
|
|||
{
|
||||
$url = $this->actingAs($this->author)->postJson('/redaktion/neuigkeiten/bilder', ['image' => UploadedFile::fake()->image('bild.png', 800, 600)])->assertOk()->json('url');
|
||||
|
||||
$this->assertStringContainsString('news/inline/', $url);
|
||||
$this->assertStringContainsString('pagebuilder/news/', $url, 'Pfad, den Bild-Blöcke annehmen');
|
||||
$this->actingAs(User::factory()->create())->postJson('/redaktion/neuigkeiten/bilder', ['image' => UploadedFile::fake()->image('x.png')])->assertForbidden();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ use App\Models\User;
|
|||
use Filament\Actions\Testing\TestAction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsCategories\Pages\ManageNewsCategories;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\CreateNewsPost;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\EditNewsPost;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\ListNewsPosts;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
|
@ -61,19 +59,20 @@ class MavScenarioTest extends TestCase
|
|||
public function test_mav_can_write_in_its_category_but_publishing_needs_the_publish_right(): void
|
||||
{
|
||||
$this->actingAs($this->mav);
|
||||
$data = [
|
||||
'title' => 'Einladung zur Mitarbeiterversammlung',
|
||||
'category_id' => $this->mavCategory->id,
|
||||
'published_at' => now()->subMinute()->toIso8601String(),
|
||||
'is_featured' => true,
|
||||
'content' => json_encode(['blocks' => [['type' => 'text', 'data' => ['html' => '<p>Am Donnerstag …</p>']]]]),
|
||||
];
|
||||
|
||||
Livewire::test(CreateNewsPost::class)
|
||||
->fillForm([
|
||||
'title' => 'Einladung zur Mitarbeiterversammlung',
|
||||
'category_id' => $this->mavCategory->id,
|
||||
'published_at' => now()->subMinute()->format('Y-m-d H:i'),
|
||||
'is_featured' => true,
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
$this->post('/redaktion/neuigkeiten', [...$data, 'action' => 'publish'])->assertSessionHasErrors('action');
|
||||
$this->post('/redaktion/neuigkeiten', [...$data, 'action' => 'submit'])->assertSessionHasNoErrors();
|
||||
|
||||
$post = NewsPost::query()->sole();
|
||||
$this->assertNull($post->published_at, 'Ohne Veröffentlichungsrecht bleibt der Beitrag ein Entwurf.');
|
||||
$this->assertFalse($post->isPublished(), 'Ohne Veröffentlichungsrecht geht der Beitrag zur Freigabe.');
|
||||
$this->assertSame(NewsPost::PENDING, $post->status);
|
||||
$this->assertFalse($post->is_featured);
|
||||
$this->assertSame($this->mav->id, $post->author_id);
|
||||
}
|
||||
|
|
@ -83,14 +82,12 @@ class MavScenarioTest extends TestCase
|
|||
Role::query()->where('name', 'MAV')->sole()->grants()->create(['ability' => 'news.post.publish', 'resource_type' => 'news_category', 'resource_id' => $this->mavCategory->id]);
|
||||
$this->actingAs($this->mav->fresh());
|
||||
|
||||
Livewire::test(CreateNewsPost::class)
|
||||
->fillForm([
|
||||
'title' => 'Ergebnisse der MAV-Wahl',
|
||||
'category_id' => $this->mavCategory->id,
|
||||
'published_at' => now()->subMinute()->format('Y-m-d H:i'),
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
$this->post('/redaktion/neuigkeiten', [
|
||||
'title' => 'Ergebnisse der MAV-Wahl',
|
||||
'category_id' => $this->mavCategory->id,
|
||||
'content' => json_encode(['blocks' => []]),
|
||||
'action' => 'publish',
|
||||
])->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertTrue(NewsPost::query()->sole()->isPublished());
|
||||
}
|
||||
|
|
@ -99,24 +96,26 @@ class MavScenarioTest extends TestCase
|
|||
{
|
||||
$this->actingAs($this->mav);
|
||||
|
||||
Livewire::test(CreateNewsPost::class)
|
||||
->fillForm(['title' => 'Fremd', 'category_id' => $this->otherCategory->id])
|
||||
->call('create')
|
||||
->assertHasFormErrors(['category_id']);
|
||||
$this->post('/redaktion/neuigkeiten', ['title' => 'Fremd', 'category_id' => $this->otherCategory->id, 'action' => 'draft'])
|
||||
->assertSessionHasErrors('category_id');
|
||||
$this->assertSame(0, NewsPost::query()->count());
|
||||
|
||||
$foreign = NewsPost::factory()->create(['category_id' => $this->otherCategory->id]);
|
||||
$this->get("/admin/neuigkeiten/{$foreign->id}/bearbeiten")->assertNotFound();
|
||||
$this->get("/redaktion/neuigkeiten/{$foreign->id}")->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_editing_without_publish_right_does_not_change_publication(): void
|
||||
{
|
||||
$post = NewsPost::factory()->create(['category_id' => $this->mavCategory->id, 'published_at' => null]);
|
||||
$post = NewsPost::factory()->draft()->create(['category_id' => $this->mavCategory->id, 'author_id' => $this->mav->id]);
|
||||
$this->actingAs($this->mav);
|
||||
|
||||
Livewire::test(EditNewsPost::class, ['record' => $post->getRouteKey()])
|
||||
->fillForm(['title' => 'Überarbeitet', 'published_at' => now()->format('Y-m-d H:i')])
|
||||
->call('save')
|
||||
->assertHasNoFormErrors();
|
||||
$this->put("/redaktion/neuigkeiten/{$post->id}", [
|
||||
'title' => 'Überarbeitet',
|
||||
'category_id' => $this->mavCategory->id,
|
||||
'published_at' => now()->toIso8601String(),
|
||||
'action' => 'draft',
|
||||
])->assertSessionHasNoErrors();
|
||||
|
||||
$post->refresh();
|
||||
$this->assertSame('Überarbeitet', $post->title);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use App\Models\User;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\Pages\CreateEvent;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\CreateNewsPost;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Livewire\Livewire;
|
||||
|
|
@ -22,10 +21,15 @@ class ContentAdminTest extends TestCase
|
|||
$post = NewsPost::factory()->create();
|
||||
$event = Event::factory()->create();
|
||||
|
||||
foreach (['/admin/neuigkeiten', '/admin/neuigkeiten/neu', "/admin/neuigkeiten/{$post->id}/bearbeiten", '/admin/kategorien', '/admin/termine', '/admin/termine/neu', "/admin/termine/{$event->id}/bearbeiten"] as $url) {
|
||||
foreach (['/admin/neuigkeiten', '/admin/kategorien', '/admin/termine', '/admin/termine/neu', "/admin/termine/{$event->id}/bearbeiten"] as $url) {
|
||||
$this->actingAs($admin)->get($url)->assertOk();
|
||||
$this->actingAs(User::factory()->create())->get($url)->assertForbidden();
|
||||
}
|
||||
|
||||
// Beiträge schreibt man im Baukasten-Editor des Portals – das Backend leitet dorthin
|
||||
$this->actingAs($admin)->get('/admin/neuigkeiten/neu')->assertRedirect(route('news.editor.create'));
|
||||
$this->actingAs($admin)->get("/admin/neuigkeiten/{$post->id}/bearbeiten")->assertRedirect(route('news.editor.edit', $post));
|
||||
$this->actingAs(User::factory()->create())->get("/admin/neuigkeiten/{$post->id}/bearbeiten")->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_admin_can_write_a_post(): void
|
||||
|
|
@ -34,20 +38,28 @@ class ContentAdminTest extends TestCase
|
|||
$category = NewsCategory::factory()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
Livewire::test(CreateNewsPost::class)
|
||||
->fillForm([
|
||||
'title' => 'Neue Kantine eröffnet',
|
||||
'teaser' => 'Ab Montag gibt es frisches Essen im Erdgeschoss.',
|
||||
'category_id' => $category->id,
|
||||
'published_at' => now()->subMinute()->format('Y-m-d H:i'),
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
$this->post('/redaktion/neuigkeiten', [
|
||||
'title' => 'Neue Kantine eröffnet',
|
||||
'teaser' => 'Ab Montag gibt es frisches Essen im Erdgeschoss.',
|
||||
'category_id' => $category->id,
|
||||
'content' => json_encode(['blocks' => [
|
||||
['type' => 'heading', 'data' => ['text' => 'Was es gibt']],
|
||||
['type' => 'text', 'data' => ['html' => '<p>Suppe, Salat und <strong>zwei Hauptgerichte</strong>.</p><script>alert(1)</script>']],
|
||||
]]),
|
||||
'action' => 'publish',
|
||||
])->assertSessionHasNoErrors();
|
||||
|
||||
$post = NewsPost::query()->firstOrFail();
|
||||
$this->assertSame('neue-kantine-eroeffnet', $post->slug);
|
||||
$this->assertSame($admin->id, $post->author_id);
|
||||
$this->assertTrue($post->isPublished());
|
||||
$this->assertSame(['heading', 'text'], array_column($post->content['blocks'], 'type'));
|
||||
$this->assertStringNotContainsString('script', json_encode($post->content));
|
||||
$this->assertStringContainsString('zwei Hauptgerichte', $post->body, 'Text für Suche und Lesezeit');
|
||||
|
||||
$this->get("/neuigkeiten/{$post->slug}")->assertOk()->assertInertia(fn ($page) => $page
|
||||
->where('post.body_html', null)
|
||||
->where('content.blocks.1.data.html', fn ($html) => str_contains($html, 'zwei Hauptgerichte')));
|
||||
}
|
||||
|
||||
public function test_admin_can_create_an_event(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue