Lasse Präsentationsmedien ohne Inhaltsfassung zu.
CI Feature / test (push) Successful in 53s
Deploy Test / test (push) Successful in 48s
Deploy Test / deploy (push) Successful in 22s

Bilder, Filme und Hörstücke lassen sich zuordnen und für die Website freigeben, ohne eine fachliche Fassung anzulegen. Unterrichtsfilme behalten die Teaserfassung an ihrer bereitgestellten Fassung.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-19 08:20:35 +01:00
1 parent 5590225f4f
commit 7b325f0d66
25 files changed
+734 -93

No files matched your search

+105 -5
View File
@@ -17,6 +17,7 @@
use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PresentationAssignment;
use App\Domain\Catalog\PresentationMedia;
use App\Domain\Catalog\ReleaseStatus;
@@ -25,6 +26,7 @@
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Media\MediaRendition;
use App\Domain\Media\PresentationFile;
use App\Domain\Media\WebsiteMedia;
use App\Domain\Media\WebsiteRelease;
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
@@ -150,9 +152,24 @@ public function test_a_module_description_does_not_version_the_composition_or_cr
);
$this->assertSame($textsBefore, ContentElement::query()->where('output_class', 'text')->count());
$cover = $this->image('Modulbild');
app(PresentationMedia::class)->assign($module, 'titelbild', $cover->id, null, $this->editor());
$this->assertSame(1, $module->fresh()->versions()->count());
$cover = $this->pictureWithoutVersion('Modulbild ohne Fassung');
Livewire::test(EditExercise::class, ['record' => $module->getKey()])
->assertSet('teaser', 'Kurz in das Modul.')
->set('teaser', 'Geändertes Modul.')
->call('saveDisplay')
->assertSee('Die Fassung bleibt unverändert.')
->call('openPresentationPicker')
->set('pickerQuery', 'Modulbild ohne')
->assertSee('Modulbild ohne Fassung')
->call('assignFromPicker', 'medium:'.$cover->id);
$module->refresh();
$version->refresh();
$this->assertSame('Geändertes Modul.', $module->teaser);
$this->assertSame('Eine Grenze erkennen und sagen.', $version->learning_goal);
$this->assertSame(0, $cover->fresh()->versions()->count());
$this->assertSame(1, $module->versions()->count());
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $cover->id)->value('source_version_id'));
$this->assertSame(
1,
CompositionMember::query()->where('composition_version_id', $version->id)->count()
@@ -264,10 +281,36 @@ public function test_a_license_article_overrides_only_its_own_presentation(): vo
$this->assertSame($offers, Offer::query()->count());
$this->assertSame(1, $film->fresh()->versions()->count());
$cover = $this->image('Artikelbild');
app(PresentationMedia::class)->assign($article, 'titelbild', $cover->id, null, $keeper);
$cover = $this->pictureWithoutVersion('Artikelbild ohne Fassung');
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
->assertSet('summary', 'Eigene Artikelbeschreibung')
->set('descriptionText', 'Nur dieser Artikel')
->call('saveLicenseEditorial')
->set('presentationQuery', 'Artikelbild ohne')
->set('presentationRole', 'titelbild')
->set('presentationPick', 'medium:'.$cover->id)
->call('assignPickedPresentation')
->assertSee('Artikelbild ohne Fassung');
$overridden = app(EditorialProfileReader::class)->read($article->fresh(), 'artikel');
$this->assertSame('eigen', $overridden->origin('description'));
$this->assertSame('Nur dieser Artikel', $overridden->value('description'));
$this->assertSame('quelle', $overridden->origin('teaser'));
$this->assertSame('Teaser der Fassung', $overridden->value('teaser'));
$this->assertSame('Lang aus dem Film', $film->fresh()->description);
$this->assertSame(0, $cover->fresh()->versions()->count());
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
->set('summary', '')
->call('saveLicenseEditorial');
$restored = app(EditorialProfileReader::class)->read($article->fresh(), 'artikel');
$this->assertSame('quelle', $restored->origin('summary'));
$this->assertSame('Kurz aus dem Film', $restored->value('summary'));
$this->assertSame('eigen', $restored->origin('description'));
$this->assertSame($release->id, $article->fresh()->current_release_id);
$this->assertSame(1, ArticleRelease::query()->count());
$this->assertSame($offers, Offer::query()->count());
$this->assertSame(ReleaseStatus::Veroeffentlicht, $release->fresh()->status);
$ambiguous = $articles->create('UNDEUTIG');
$program = $content->createComposition('Zweite Wurzel', CompositionKind::Kurs);
@@ -285,6 +328,50 @@ public function test_a_license_article_overrides_only_its_own_presentation(): vo
$this->assertSame('leer', app(EditorialProfileReader::class)->read($ambiguous->fresh())->origin('summary'));
}
public function test_content_elements_do_not_offer_the_pillar_dimension_a_second_time(): void
{
$pillar = Pillar::query()->create(['name' => 'Nähe', 'slug' => 'naehe', 'sort_order' => 1]);
$dimension = EditorialDimension::query()->where('slug', 'saeule')->firstOrFail();
$value = EditorialDimensionValue::query()->create([
'editorial_dimension_id' => $dimension->id,
'slug' => 'pfeiler-'.$pillar->id,
'label' => 'Nähe als Dimension',
]);
$content = app(ContentService::class);
$film = $content->createElement('film', 'film', 'Film mit Säule');
$content->publishElementVersion($film, 'Film');
app(IdentityDimension::class)->assign($film, $value);
$kinder = $this->dimensionValue('zielgruppe', 'kinder');
$this->actingAs($this->editor(), 'staff');
$html = Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
->set('bereich', 'beschreibung')
->set('dimensionIds', [$kinder->id])
->call('saveEditorial')
->html();
$this->assertStringContainsString('Fachliche Säulen', $html);
$this->assertStringNotContainsString('>Fachliche Säule<', $html);
$assigned = IdentityDimensionValue::query()
->where('subject_type', $film->getMorphClass())
->where('subject_id', $film->id)
->pluck('editorial_dimension_value_id')
->all();
$this->assertContains($value->id, $assigned);
$this->assertContains($kinder->id, $assigned);
$module = $content->createComposition('Modul mit Säule');
$content->publishComposition($module, [[
'role' => 'Film',
'target' => $film->versions()->first(),
]]);
Livewire::test(EditExercise::class, ['record' => $module->getKey()])
->call('openModule')
->set('moduleTab', 'einordnung')
->assertSee('Nähe als Dimension')
->assertDontSee('Fachliche Säulen');
}
public function test_classification_is_filterable_and_does_not_change_use_or_release(): void
{
$content = app(ContentService::class);
@@ -453,6 +540,19 @@ public function test_a_kachel_variant_does_not_replace_the_central_teaser(): voi
$this->assertSame('Zentral', $program->fresh()->teaser);
}
private function pictureWithoutVersion(string $title): ContentElement
{
Storage::fake('cms_incoming');
$path = 'inhalte/'.md5($title).'.jpg';
Storage::disk('cms_incoming')->put($path, 'bild');
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
$element->display_title = $title;
$element->save();
app(PresentationFile::class)->store($element, $path);
return $element->fresh();
}
private function image(string $title): ContentElement
{
$content = app(ContentService::class);
+268
View File
@@ -0,0 +1,268 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\CompositionMember;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\PresentationAssignment;
use App\Domain\Catalog\PresentationMedia;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Cms\Widgets\WidgetRenderer;
use App\Domain\Entitlement\Grant;
use App\Domain\Media\PresentationFile;
use App\Domain\Media\WebsiteMedia;
use App\Domain\Media\WebsiteRelease;
use App\Filament\Resources\Courses\Pages\EditCourse;
use App\Filament\Support\EditorialCatalog;
use App\Filament\Support\MediumForm;
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use Tests\TestCase;
class PresentationMediaTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
Storage::fake('cms_incoming');
Storage::fake('media_derived');
Storage::fake('media_public');
Storage::fake('media_originals');
}
public function test_a_versionless_image_and_teaser_can_be_assigned_released_and_withdrawn(): void
{
$content = app(ContentService::class);
$program = $content->createComposition('Programm mit Teaser', CompositionKind::Kurs);
$program->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
$program->display_title = 'Name aus der Redaktion';
$program->teaser = 'Teaser aus der Redaktion';
$program->description = 'Interne Langfassung';
$program->save();
$version = $content->publishComposition($program, [[
'role' => 'Text',
'target' => $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Inhalt'),
]]);
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
$image = $this->store('bild', 'Pruefbild ohne Fassung', 'bild-bytes');
$teaser = $this->store('film', 'Teaser ohne Fassung', 'teaser-bytes');
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
$this->actingAs($editor, 'staff');
$found = app(EditorialCatalog::class)->presentationBrowse('ohne Fassung');
$targets = array_column($found['items'], 'target');
$this->assertContains('medium:'.$image->id, $targets);
$this->assertContains('medium:'.$teaser->id, $targets);
$didactic = app(EditorialCatalog::class)->browse('ohne Fassung', 'alle', '', $program->id);
$this->assertNotContains('medium:'.$image->id, array_column($didactic['items'], 'target'));
$this->assertNotContains('medium:'.$teaser->id, array_column($didactic['items'], 'target'));
Livewire::test(EditCourse::class, ['record' => $program->getKey()])
->call('openPresentationPicker')
->set('pickerQuery', 'Pruefbild ohne')
->set('presentationRole', 'titelbild')
->call('assignFromPicker', 'medium:'.$image->id)
->call('openPresentationPicker')
->set('pickerQuery', 'Teaser ohne')
->set('presentationRole', 'trailer')
->set('bindToVersion', false)
->call('assignFromPicker', 'medium:'.$teaser->id)
->assertSee('Pruefbild ohne Fassung')
->assertSee('Teaser ohne Fassung')
->assertSee('Eigenständiges Medium, ohne Bindung an eine Fassung.');
$this->assertSame(0, $image->fresh()->versions()->count());
$this->assertSame(0, $teaser->fresh()->versions()->count());
$this->assertSame(1, $program->fresh()->versions()->count());
$this->assertSame(0, Grant::query()->count());
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $image->id)->value('source_version_id'));
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $teaser->id)->value('source_version_id'));
$this->assertSame(1, CompositionMember::query()->where('composition_version_id', $version->id)->count());
app(WebsiteRelease::class)->release($image->fresh());
app(WebsiteRelease::class)->release($teaser->fresh());
$image->refresh();
$teaser->refresh();
$this->assertNotNull($image->website_released_at);
$this->assertNotNull($teaser->website_released_at);
$this->assertSame(0, $image->versions()->count());
$this->assertSame(0, $teaser->versions()->count());
$this->assertSame(0, Grant::query()->count());
Storage::disk('media_public')->assertExists($image->website_public_path);
Storage::disk('media_public')->assertExists($teaser->website_public_path);
$this->assertStringNotContainsString('originals', (string) $teaser->website_public_path);
$this->publish('/praesentation-ohne-fassung', [[
'layout' => 'u2_2',
'style' => [],
'slots' => [
$this->card('program_card', ['composition' => $program->id]),
$this->card('program_card', ['composition' => $program->id], ['heading' => 'Nur diese Karte']),
],
]]);
$this->get('/praesentation-ohne-fassung')->assertOk()
->assertSee('Name aus der Redaktion')
->assertSee('Teaser aus der Redaktion')
->assertSee('Nur diese Karte')
->assertSee('/website-medien/'.$image->id, false)
->assertDontSee('Interne Langfassung');
$film = app(WebsiteMedia::class)->present($teaser);
$this->assertNotNull($film);
$this->assertSame('film', $film->kind);
$this->get($film->url)->assertOk()->assertStreamedContent('teaser-bytes');
$program->teaser = 'Teaser nach der zentralen Änderung';
$program->save();
$this->app->forgetInstance(WebsiteImage::class);
$this->get('/praesentation-ohne-fassung')->assertOk()
->assertSee('Teaser nach der zentralen Änderung')
->assertSee('Nur diese Karte')
->assertDontSee('Teaser aus der Redaktion');
app(WebsiteRelease::class)->withdraw($image->fresh());
app(WebsiteRelease::class)->withdraw($teaser->fresh());
$this->app->forgetInstance(WebsiteImage::class);
$after = $this->get('/praesentation-ohne-fassung')->assertOk()->getContent();
$this->assertStringNotContainsString('/website-medien/'.$image->id, $after);
$this->assertStringContainsString('Teaser nach der zentralen Änderung', $after);
$this->assertStringContainsString('Nur diese Karte', $after);
$this->get(route('website.media', $teaser))->assertNotFound();
$this->get(route('website.media', $image))->assertNotFound();
Storage::disk('media_derived')->assertExists($image->thumbnail_path);
Storage::disk('media_derived')->assertExists($teaser->preview_path);
$this->assertSame(0, $teaser->fresh()->versions()->count());
$this->assertSame('Name aus der Redaktion', $program->fresh()->display_title);
}
public function test_creating_a_presentation_film_does_not_open_a_content_version(): void
{
Storage::disk('cms_incoming')->put('inhalte/teaser.mp4', 'teaser-bytes');
$editor = User::factory()->redakteur()->create();
$this->actingAs($editor, 'staff');
$element = MediumForm::create([
'working_title' => 'Marketingclip',
'shape' => 'film',
'incoming' => 'inhalte/teaser.mp4',
'without_version' => true,
'description' => 'Nur die Website',
], hold: false);
$this->assertSame(0, $element->versions()->count());
$this->assertSame('teaser/'.$element->id.'/datei.mp4', $element->preview_path);
$this->assertNull($element->website_released_at);
$this->assertSame(0, Grant::query()->count());
Storage::disk('media_derived')->assertExists($element->preview_path);
Storage::disk('media_originals')->assertDirectoryEmpty('/');
}
public function test_a_versionless_audio_preview_is_released_without_a_license(): void
{
$audio = $this->store('audio', 'Audiovorschau ohne Fassung', 'audio-bytes');
$this->assertNull(app(WebsiteMedia::class)->present($audio));
app(WebsiteRelease::class)->release($audio);
$audio->refresh();
$presentation = app(WebsiteMedia::class)->present($audio);
$this->assertNotNull($presentation);
$this->assertSame('audio', $presentation->kind);
$this->get($presentation->url)->assertOk()->assertStreamedContent('audio-bytes');
$this->assertSame(0, $audio->versions()->count());
$this->assertSame(0, Grant::query()->count());
app(WebsiteRelease::class)->withdraw($audio->fresh());
$this->assertNull(app(WebsiteMedia::class)->present($audio->fresh()));
$this->get(route('website.media', $audio))->assertNotFound();
Storage::disk('media_derived')->assertExists($audio->preview_path);
}
public function test_an_explicit_version_binding_stays_optional(): void
{
$content = app(ContentService::class);
$film = $content->createElement('film', 'film', 'Unterricht');
$version = $content->publishElementVersion($film, 'Fassung');
$clip = $this->store('film', 'Clip ohne Fassung', 'clip-bytes');
app(PresentationMedia::class)->assign($film, 'trailer', $clip->id, null);
$this->assertNull(PresentationAssignment::query()->value('source_version_id'));
app(PresentationMedia::class)->assign($film, 'trailer', $clip->id, $version->id);
$this->assertSame($version->id, PresentationAssignment::query()->value('source_version_id'));
$this->assertSame(0, $clip->fresh()->versions()->count());
$this->assertSame(1, $film->fresh()->versions()->count());
$this->assertSame(0, Grant::query()->count());
}
public function test_a_widget_with_nothing_but_a_missing_medium_is_omitted(): void
{
$image = $this->store('bild', 'Nur ein Bild', 'bild-bytes');
$html = app(WidgetRenderer::class)->renderAll([
['type' => 'heading', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['heading' => 'Die Überschrift bleibt'], 'refs' => []],
['type' => 'cards', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['items' => [
['title' => '', 'text' => null, 'url' => null, 'image' => $image->id],
]], 'refs' => []],
], RenderContext::publicPage())->toHtml();
$this->assertStringContainsString('Die Überschrift bleibt', $html);
$this->assertStringNotContainsString('widget-cards', $html);
$this->assertStringNotContainsString('<img', $html);
}
private function store(string $output, string $title, string $bytes): ContentElement
{
$extension = match ($output) {
'bild' => 'jpg',
'audio' => 'mp3',
default => 'mp4',
};
$path = 'inhalte/'.md5($title).'.'.$extension;
Storage::disk('cms_incoming')->put($path, $bytes);
$element = app(ContentService::class)->createElement($output, $output, $title);
$element->display_title = $title;
$element->save();
app(PresentationFile::class)->store($element, $path);
return $element->fresh();
}
/**
* @param list<array<string, mixed>> $sections
*/
private function publish(string $path, array $sections): void
{
$page = Page::query()->create(['path' => $path]);
$service = app(PageService::class);
$revision = $service->saveRevision($page, $sections, null, null, null);
$service->publish($page, $revision);
}
/**
* @param array<string, mixed> $refs
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function card(string $type, array $refs, array $data = []): array
{
return ['type' => $type, 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => $data, 'refs' => $refs];
}
}