Biete an Medien- und Programmkarten an, alle Texte auszublenden
Neue Einstellung „Texte neben dem Bild“ (Darstellung): Ausblenden zeigt nur Bild oder Video, ohne Titel, Text, Art, Zusatzangaben, Aktion und Marke im Bild. Der Titel bleibt unsichtbar für Hilfstechnik, ein Trailer läuft weiter. Die Themenkarte hat die Einstellung nicht. Keine Migration. Außerdem steht in der Beschreibung der Trailer-Einstellung jetzt der Ton nach Bedienung. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc890d9fc7
commit
2ca7a8b268
6 files changed
+210
-9
No files matched your search
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Catalog\PresentationRole;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Medien- und Programmkarte ohne Texte: Die Einstellung „Texte neben dem Bild“ (show_body = no) zeigt nur Bild oder
|
||||
* Video, ohne Titel, Text, Art, Zusatzangaben und Aktion. Der Titel bleibt für Hilfstechnik unsichtbar erhalten, ein
|
||||
* Trailer läuft weiter.
|
||||
*/
|
||||
class CmsCardWithoutTextTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_the_default_still_shows_all_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$this->publish('/mit-text', $this->card($film, []));
|
||||
|
||||
$html = $this->card_html($this->get('/mit-text')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('Eine Pause, die stark macht', $html);
|
||||
$this->assertStringContainsString('KURZ-TEXT', $html);
|
||||
$this->assertStringContainsString('lf-pc__cta', $html);
|
||||
$this->assertStringContainsString('lf-pc__meta', $html);
|
||||
$this->assertStringNotContainsString('lf-pc--bare', $html);
|
||||
}
|
||||
|
||||
public function test_without_texts_only_the_picture_remains_and_the_title_stays_for_assistive_technology(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$this->publish('/ohne-text', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$html = $this->card_html($this->get('/ohne-text')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('lf-pc--bare', $html);
|
||||
$this->assertStringNotContainsString('KURZ-TEXT', $html);
|
||||
$this->assertStringNotContainsString('lf-pc__cta', $html, 'Keine Aktion.');
|
||||
$this->assertStringNotContainsString('lf-pc__meta', $html, 'Keine Zusatzangaben.');
|
||||
$this->assertStringNotContainsString('lf-pc__kind', $html, 'Keine Art.');
|
||||
$this->assertStringNotContainsString('lf-pc__badge', $html, 'Keine Marke im Bild.');
|
||||
$this->assertStringContainsString('class="lf-pc__title visually-hidden"', $html);
|
||||
$this->assertStringContainsString('Eine Pause, die stark macht', $html, 'Der Titel bleibt für Hilfstechnik erhalten.');
|
||||
}
|
||||
|
||||
public function test_the_trailer_still_plays_on_a_card_without_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
PresentationAssignment::query()->create([
|
||||
'subject_type' => $film->getMorphClass(),
|
||||
'subject_id' => $film->getKey(),
|
||||
'content_element_id' => $trailer->id,
|
||||
'presentation_role_id' => PresentationRole::query()->where('slug', 'trailer')->value('id'),
|
||||
'position' => 1,
|
||||
]);
|
||||
app(WebsiteRelease::class)->release($trailer->fresh());
|
||||
foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class] as $class) {
|
||||
$this->app->forgetInstance($class);
|
||||
}
|
||||
$this->publish('/ohne-text-trailer', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$html = $this->card_html($this->get('/ohne-text-trailer')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $html);
|
||||
$this->assertStringContainsString('aria-label="Trailer abspielen: Trailer Denkpause"', $html);
|
||||
$this->assertStringNotContainsString('KURZ-TEXT', $html);
|
||||
}
|
||||
|
||||
public function test_only_cards_with_a_picture_offer_the_choice_and_it_is_validated(): void
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('media_card')->settingOptions()['show_body']));
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('program_card')->settingOptions()['show_body']));
|
||||
$this->assertArrayNotHasKey('show_body', $registry->get('topic_card')->settingOptions(), 'Eine Themenkarte ohne Bild bliebe leer.');
|
||||
|
||||
$film = $this->publicFilm();
|
||||
|
||||
try {
|
||||
$registry->normalize($this->card($film, ['show_body' => 'vielleicht'])[0]['slots']);
|
||||
$this->fail('Eine unbekannte Wahl wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.settings.show_body', $exception->errors());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_preview_keeps_the_editorial_notes_on_a_card_without_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$revision = $this->publish('/ohne-text-vorschau', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('lf-pc--bare', $preview);
|
||||
$this->assertStringNotContainsString('lf-pc__cta', $preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $settings
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function card(ContentElement $film, array $settings): array
|
||||
{
|
||||
return [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['element' => $film->id]],
|
||||
]]];
|
||||
}
|
||||
|
||||
private function card_html(string $html): string
|
||||
{
|
||||
preg_match('#<article class="lf-pc .*?</article>#s', $html, $match);
|
||||
|
||||
return $match[0] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
private function publish(string $path, array $sections): PageRevision
|
||||
{
|
||||
$page = Page::query()->create(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, $sections, null, null, null);
|
||||
$service->publish($page, $revision);
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
private function publicFilm(): ContentElement
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'KURZ-TEXT']);
|
||||
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'unterrichtsfilm')->value('id')])->save();
|
||||
$version = $content->publishElementVersion($film, 'Film');
|
||||
$composition = $content->createComposition('Programm Denkpause');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->save();
|
||||
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||
|
||||
return $film->refresh();
|
||||
}
|
||||
|
||||
private function clip(string $title): ContentElement
|
||||
{
|
||||
$path = 'inhalte/'.md5($title).'.mp4';
|
||||
Storage::disk('cms_incoming')->put($path, '0123456789abcdefghij');
|
||||
$element = app(ContentService::class)->createElement('film', 'film', $title);
|
||||
$element->display_title = $title;
|
||||
$element->save();
|
||||
app(PresentationFile::class)->store($element, $path);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user