Wähle das Vorschaubild am Medium und nutze es als Standard in der Anzeige und in Modulen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f86032cb5f
commit
8e77defaca
18 files changed
+664
-26
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
@@ -312,4 +313,103 @@ public function test_a_frame_uses_the_small_film_rendition_when_it_exists(): voi
|
||||
app(ThumbnailDeriver::class)->frameInput($version),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_a_chosen_film_frame_becomes_the_medium_preview_without_a_new_version(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('cms_incoming');
|
||||
$image = imagecreatetruecolor(4, 4);
|
||||
ob_start();
|
||||
imagejpeg($image);
|
||||
$jpeg = ob_get_clean();
|
||||
imagedestroy($image);
|
||||
$this->app->bind(ThumbnailDeriver::class, fn () => new class($jpeg) extends ThumbnailDeriver
|
||||
{
|
||||
public function __construct(private string $jpeg) {}
|
||||
|
||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||
{
|
||||
return $this->jpeg;
|
||||
}
|
||||
});
|
||||
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', 'Hofszene');
|
||||
$version = $content->publishElementVersion($element, 'Film', ['file' => 'inhalte/hof.mp4']);
|
||||
$hash = $version->content_hash;
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->assertSee('Diese Stelle übernehmen')
|
||||
->call('adoptFrame')
|
||||
->assertSet('pictureFeedback', 'Wähle zuerst eine Zeitposition.')
|
||||
->set('frameSecond', '12.5')
|
||||
->call('adoptFrame')
|
||||
->assertSet('pictureFeedback', 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.');
|
||||
|
||||
$element->refresh();
|
||||
$version->refresh();
|
||||
$this->assertSame(1, $element->versions()->count());
|
||||
$this->assertSame($hash, $version->content_hash);
|
||||
$this->assertSame('vorschau/element-'.$element->id.'.jpg', $element->thumbnail_path);
|
||||
$this->assertSame('frame:'.$version->id.'@12.5', $element->thumbnail_source);
|
||||
Storage::disk('media_derived')->assertExists($element->thumbnail_path);
|
||||
$this->get('/medien/'.$element->thumbnail_path)->assertNotFound();
|
||||
$this->actingAs($editor, 'staff')
|
||||
->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id]))
|
||||
->assertOk();
|
||||
|
||||
$module = $content->publishComposition(
|
||||
$content->createComposition('Modul mit Hofszene', CompositionKind::Uebung),
|
||||
[['role' => 'Film', 'target' => $version]],
|
||||
);
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(EditExercise::class, ['record' => $module->composition_id])
|
||||
->assertSee('Vorschlag aus dem Film Hofszene');
|
||||
}
|
||||
|
||||
public function test_an_uploaded_preview_and_an_image_file_stay_on_the_medium(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('cms_incoming');
|
||||
$image = imagecreatetruecolor(8, 8);
|
||||
ob_start();
|
||||
imagepng($image);
|
||||
$png = ob_get_clean();
|
||||
imagedestroy($image);
|
||||
Storage::disk('cms_incoming')->put('vorschau/karte.png', $png);
|
||||
Storage::disk('media_derived')->put('inhalte/bild.png', $png);
|
||||
|
||||
$content = app(ContentService::class);
|
||||
$text = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
||||
$picture = $content->publishElementVersion(
|
||||
$content->createElement('bild', 'bild', 'Kartenbild'),
|
||||
null,
|
||||
['file' => 'inhalte/bild.png'],
|
||||
);
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $text->element->getKey()])
|
||||
->call('savePreviewImage', 'vorschau/karte.png')
|
||||
->assertSet('pictureFeedback', 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.');
|
||||
|
||||
$text->element->refresh();
|
||||
$this->assertSame(1, $text->element->versions()->count());
|
||||
$this->assertSame('eigen', $text->element->thumbnail_source);
|
||||
$this->assertSame('vorschau/element-'.$text->element->id.'.jpg', $text->element->thumbnail_path);
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $picture->element->getKey()])
|
||||
->call('useOwnImage')
|
||||
->assertSet('pictureFeedback', 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.');
|
||||
|
||||
$picture->element->refresh();
|
||||
$this->assertSame(1, $picture->element->versions()->count());
|
||||
$this->assertSame('datei', $picture->element->thumbnail_source);
|
||||
Storage::disk('media_derived')->assertExists($picture->element->thumbnail_path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user