Startseite frei gestalten, Neuigkeiten-Block mit Kategorien-Filter (0.26.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m21s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m55s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 09:38:18 +00:00
parent 6290e09074
commit 2c96fcce1c
151 changed files with 1515 additions and 317 deletions

View file

@ -8,12 +8,14 @@ use App\Notifications\PortalNotification;
use App\Pagebuilder\Content;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Inertia\Testing\AssertableInertia as Assert;
use Inhaus\Plugins\Forms\Models\Form;
use Inhaus\Plugins\News\Models\NewsCategory;
use Inhaus\Plugins\News\Models\NewsPost;
use Inhaus\Plugins\Pages\Models\Page;
use Tests\TestCase;
/**
@ -169,7 +171,7 @@ class NewsWorkflowTest extends TestCase
NewsPost::factory()->draft()->create(['category_id' => $this->mavInfo->id, 'title' => 'Entwurf']);
$content = app(Content::class);
$rendered = $content->render($content->sanitize(['blocks' => [['type' => 'news.latest', 'data' => ['category' => 'mav-info', 'count' => 5]]]]), User::factory()->create());
$rendered = $content->render($content->sanitize(['blocks' => [['type' => 'news.latest', 'data' => ['filter' => 'include', 'categories' => ['mav-info'], 'count' => 5]]]]), User::factory()->create());
$this->assertSame(['Aus der MAV'], array_column($rendered['blocks'][0]['props']['posts'], 'title'));
$this->assertSame('/neuigkeiten?kategorie=mav-info', $rendered['blocks'][0]['props']['more_url']);
@ -204,4 +206,21 @@ class NewsWorkflowTest extends TestCase
$this->actingAs($this->editor)->put('/redaktion/neuigkeiten/'.$post->id, $this->payload(['action' => 'publish', 'form_id' => 99999]))->assertSessionHasErrors('form_id');
}
public function test_old_single_category_news_blocks_are_converted(): void
{
$page = Page::query()->create(['title' => 'Alt']);
DB::table('pages')->where('id', $page->id)->update(['content' => json_encode(['blocks' => [
['id' => 'blkcols1', 'type' => 'columns', 'data' => ['layout' => '1-1'], 'items' => [
['id' => 'itm1', 'blocks' => [['id' => 'blknews1', 'type' => 'news.latest', 'data' => ['title' => 'MAV', 'category' => 'mav-info', 'count' => 3, 'layout' => 'cards']]]],
['id' => 'itm2', 'blocks' => [['id' => 'blknews2', 'type' => 'news.latest', 'data' => ['title' => 'Alle', 'category' => '', 'count' => 3, 'layout' => 'list']]]],
]],
]])]);
(require base_path('plugins-core/news/database/migrations/2026_10_11_000002_convert_news_block_category_filter.php'))->up();
$items = $page->fresh()->content['blocks'][0]['items'];
$this->assertSame(['title' => 'MAV', 'count' => 3, 'layout' => 'cards', 'filter' => 'include', 'categories' => ['mav-info']], $items[0]['blocks'][0]['data']);
$this->assertSame('all', $items[1]['blocks'][0]['data']['filter']);
}
}