Zeige Katalogkarten, Titelbilder und klare Freigabestatus im Arbeitsplatz.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
053a361801
commit
9195cdcd15
15 files changed
+795
-59
No files matched your search
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Pages\EditorialDesk;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
@@ -14,6 +15,7 @@
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -299,6 +301,98 @@ public function test_guests_cannot_open_the_trainer_preview(): void
|
||||
->assertRedirect();
|
||||
}
|
||||
|
||||
public function test_catalog_cards_show_text_status_and_a_single_film_suggestion(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
$content = app(ContentService::class);
|
||||
$film = $this->filmWithPicture($content, 'Lara im Park');
|
||||
$withFilm = $content->publishComposition(
|
||||
$content->createComposition('Modul mit Film', CompositionKind::Uebung),
|
||||
[['role' => 'Film', 'target' => $film]],
|
||||
);
|
||||
$withFilm->composition->summary = 'Kinder erkennen eine Grenze, bevor sie jemanden um Hilfe bitten.';
|
||||
$withFilm->composition->save();
|
||||
$plain = $content->createComposition('Modul ohne Bild', CompositionKind::Uebung);
|
||||
$plain->summary = str_repeat('Ausführliche Kartenbeschreibung. ', 12);
|
||||
$plain->save();
|
||||
$editor = $this->editor();
|
||||
app(CompositionDisplayRelease::class)->release($withFilm, $editor);
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(EditorialDesk::class)
|
||||
->assertSee('Kinder erkennen eine Grenze')
|
||||
->assertSee('Vorschlag aus dem Film Lara im Park')
|
||||
->assertSee('In der Mitgliederbibliothek')
|
||||
->assertSee('Kein Titelbild')
|
||||
->assertSee('Ausführliche Kartenbeschreibung')
|
||||
->assertSee('Nicht auf der Website')
|
||||
->assertSee('Kein aktives Angebot')
|
||||
->assertDontSee('Zur Anzeige freigeben')
|
||||
->set('visibility', 'entwurf')
|
||||
->assertSee('Modul ohne Bild')
|
||||
->assertDontSee('Modul mit Film');
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(EditExercise::class, ['record' => $withFilm->composition_id])
|
||||
->assertSee('In Mitgliederbibliothek anzeigen')
|
||||
->assertSee('Vorschlag aus dem Film Lara im Park')
|
||||
->assertSee('Katalogvorschau')
|
||||
->assertDontSee('Zur Anzeige freigeben');
|
||||
}
|
||||
|
||||
public function test_a_chosen_picture_and_description_do_not_create_a_version(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
$content = app(ContentService::class);
|
||||
$first = $this->filmWithPicture($content, 'Lara im Park');
|
||||
$second = $this->filmWithPicture($content, 'Lara im Hof');
|
||||
$version = $content->publishComposition(
|
||||
$content->createComposition('Modul mit zwei Filmen', CompositionKind::Uebung),
|
||||
[
|
||||
['role' => 'Film', 'target' => $first],
|
||||
['role' => 'Weiterer Film', 'target' => $second],
|
||||
],
|
||||
);
|
||||
$editor = $this->editor();
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(EditExercise::class, ['record' => $version->composition_id])
|
||||
->assertSee('Lara im Park als Titelbild')
|
||||
->assertSee('Lara im Hof als Titelbild')
|
||||
->assertDontSee('Vorschlag aus dem Film')
|
||||
->call('adoptPicture', $first->element->id)
|
||||
->assertSet('feedback', 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.')
|
||||
->set('description', 'Eine fachliche Beschreibung für die Bibliothek.')
|
||||
->set('summary', 'Kurzer Kartentext')
|
||||
->call('saveDisplay')
|
||||
->assertSet('feedback', 'Die Anzeige ist gespeichert. Die Fassung bleibt unverändert.');
|
||||
|
||||
$composition = $version->composition->fresh();
|
||||
|
||||
$this->assertSame(1, $composition->versions()->count());
|
||||
$this->assertSame('vorschau/komposition-'.$composition->id.'.jpg', $composition->thumbnail_path);
|
||||
$this->assertSame('element:'.$first->element->id, $composition->thumbnail_source);
|
||||
$this->assertSame('Eine fachliche Beschreibung für die Bibliothek.', $composition->description);
|
||||
Storage::disk('media_derived')->assertExists($composition->thumbnail_path);
|
||||
$this->get('/medien/'.$composition->thumbnail_path)->assertNotFound();
|
||||
}
|
||||
|
||||
private function filmWithPicture(ContentService $content, string $title): ContentElementVersion
|
||||
{
|
||||
$element = $content->createElement('film', 'film', $title);
|
||||
$version = $content->publishElementVersion($element, 'Film');
|
||||
$element->thumbnail_path = 'vorschau/element-'.$element->id.'.jpg';
|
||||
$element->thumbnail_alt = $title;
|
||||
$element->save();
|
||||
$image = imagecreatetruecolor(8, 8);
|
||||
ob_start();
|
||||
imagepng($image);
|
||||
Storage::disk('media_derived')->put($element->thumbnail_path, ob_get_clean());
|
||||
imagedestroy($image);
|
||||
|
||||
return $version->fresh();
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
|
||||
Reference in new issue
Block a user