Files
laraundfelix/tests/Feature/VideoPlayButtonTest.php
T
LarsandClaude Sonnet 5.5 bd91104970
Deploy Test / test (push) Successful in 6m38s
CI Feature / test (push) Successful in 6m4s
Deploy Test / deploy (push) Successful in 43s
Setze die Abspiel-Schaltfläche groß und mittig auf das Vorschaubild
Einstieg (Teaser) und Premium-Karten (Medien-, Programm-, Modul-, Bild-und-Text-Karte) gestalten sie gleich: großer Kreis, halbtransparent, mittig auf dem Bild; läuft der Clip, wird sie zur kleinen Anhalten-Schaltfläche in der Ecke. Skripte, Beschriftungen und Tastaturbedienung bleiben unverändert.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 16:48:23 +01:00

87 lines
4.6 KiB
PHP

<?php
namespace Tests\Feature;
use Tests\TestCase;
/**
* Abspiel-Schaltfläche der Video-Bausteine (Einstieg und Premium-Karten): Solange der Clip nicht läuft, sitzt sie groß,
* halbtransparent und mittig auf dem Vorschaubild; läuft er, wird sie klein und wandert in die Ecke. Die Gestaltung ist
* CSS; geprüft wird hier, dass beide Bausteine sie gleich führen und die Bedienung (Schaltfläche, Beschriftung) bleibt.
*/
class VideoPlayButtonTest extends TestCase
{
private function css(string $file): string
{
return (string) file_get_contents(resource_path('css/components/'.$file));
}
/** Regelblock zu einem Selektor, ohne Kommentare. */
private function rule(string $css, string $selector): string
{
$css = (string) preg_replace('~/\*.*?\*/~s', '', $css);
$this->assertSame(1, preg_match('~(?:^|\})\s*'.preg_quote($selector, '~').'\s*\{([^}]*)\}~', $css, $match), $selector.' fehlt.');
return $match[1];
}
public function test_the_idle_button_is_centered_large_and_translucent_on_the_hero(): void
{
$rule = $this->rule($this->css('lf-hero.css'), '.lf-hero__video-toggle');
$this->assertStringContainsString('translate(-50%, -50%)', $rule);
$this->assertStringContainsString('inset-block-start: 50%', $rule);
$this->assertMatchesRegularExpression('/border-radius:\s*50%/', $rule);
$this->assertMatchesRegularExpression('/inline-size:\s*clamp\(64px/', $rule, 'Mindestens 64 px, damit sie gut erkennbar ist.');
$this->assertMatchesRegularExpression('/background:\s*rgb\(3 37 81 \/ \d+%\)/', $rule);
$this->assertStringNotContainsString('86%', $rule, 'Halbtransparent, nicht deckend.');
}
public function test_the_idle_button_is_centered_large_and_translucent_on_the_cards(): void
{
$rule = $this->rule($this->css('lf-premium-card.css'), '.lf-pc__clip-toggle');
$this->assertStringContainsString('translate(-50%, -50%)', $rule);
$this->assertMatchesRegularExpression('/inset:\s*50% auto auto 50%/', $rule);
$this->assertMatchesRegularExpression('/border-radius:\s*50%/', $rule);
$this->assertMatchesRegularExpression('/inline-size:\s*clamp\(48px/', $rule);
$this->assertMatchesRegularExpression('/background:\s*rgb\(3 37 81 \/ \d+%\)/', $rule);
}
public function test_the_running_button_moves_to_the_corner_in_both_blocks(): void
{
$hero = $this->rule($this->css('lf-hero.css'), '.lf-hero__video-toggle[aria-pressed="true"]');
$card = $this->rule($this->css('lf-premium-card.css'), '.lf-pc__clip-toggle[aria-pressed="true"]');
$this->assertStringContainsString('transform: none', $hero);
$this->assertStringContainsString('inset-inline-end: 12px', $hero);
$this->assertStringContainsString('min-block-size: 44px', $hero, 'Trefferfläche mindestens 44 px.');
$this->assertStringContainsString('transform: none', $card);
$this->assertStringContainsString('inset: 8px 8px auto auto', $card);
}
public function test_the_narrow_hero_centers_the_button_on_the_image_above_the_text(): void
{
$css = $this->css('lf-hero.css');
$this->assertStringContainsString('.lf-hero__video-toggle:not([aria-pressed="true"]) { inset-block-start: calc(100cqi * 9 / 32); inset-inline-start: 50%;', $css);
}
public function test_both_buttons_stay_real_buttons_with_a_label_and_a_visible_focus(): void
{
$hero = (string) file_get_contents(resource_path('views/widgets/hero.blade.php'));
$clip = (string) file_get_contents(resource_path('views/widgets/partials/card-clip.blade.php'));
$this->assertStringContainsString('<button type="button" class="lf-hero__video-toggle" aria-pressed="false" data-hero-toggle aria-label="Video abspielen:', $hero);
$this->assertStringContainsString('<button type="button" class="lf-pc__clip-toggle" aria-pressed="false" data-clip-toggle aria-label="Trailer abspielen:', $clip);
$this->assertStringContainsString('.lf-hero__video-toggle:focus-visible', $this->css('lf-hero.css'));
$this->assertStringContainsString('.lf-pc__clip-toggle:focus-visible', $this->css('lf-premium-card.css'));
}
public function test_reduced_motion_removes_the_button_animation(): void
{
$this->assertMatchesRegularExpression('/prefers-reduced-motion[^{]*\{[^@]*\.lf-hero__video-toggle \{ transition: none; \}/s', $this->css('lf-hero.css'));
$this->assertMatchesRegularExpression('/prefers-reduced-motion[^{]*\{[^@]*\.lf-pc__clip-toggle \{ transition: none; \}/s', $this->css('lf-premium-card.css'));
}
}