Pflege Anzeigedaten ohne neue Fassung und zeige sie in den echten Karten.
Der Medieneditor trennt Beschreibung, Inhalt, Fassungen und Verwendung. Der vorhandene Picker filtert nach Zusammenhang und lässt Entwürfe für die gemeinsame Freigabe sichtbar. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3e56314cf9
commit
d37a7093dd
13 files changed
+827
-54
No files matched your search
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MediaEditorTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
public function test_editorial_text_is_saved_without_a_new_version_and_previewed_on_the_real_cards(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', 'Lara im Park');
|
||||
$version = $content->publishElementVersion($element, 'Film');
|
||||
$editor = $this->editor();
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'beschreibung')
|
||||
->set('displayTitle', 'Lara im Park, neu')
|
||||
->set('summary', 'Ein kurzer Teaser für die Karte')
|
||||
->set('descriptionText', 'Ausführliche Beschreibung nur in der Verwaltung')
|
||||
->call('saveEditorial')
|
||||
->assertSee('Gespeichert. Es gibt keine neue Fassung.')
|
||||
->assertSee('Ein kurzer Teaser für die Karte')
|
||||
->assertSee('lf-pc');
|
||||
|
||||
$element->refresh();
|
||||
$this->assertSame(1, $element->versions()->count());
|
||||
$this->assertSame($version->id, $element->versions()->first()->id);
|
||||
$this->assertSame('Lara im Park, neu', $element->display_title);
|
||||
$this->assertSame('Ein kurzer Teaser für die Karte', $element->summary);
|
||||
$this->assertTrue(
|
||||
IdentityChange::query()->where('subject_id', $element->id)->where('field', 'summary')->exists()
|
||||
);
|
||||
|
||||
$draft = app(PublicMaterialReader::class)->subject($element->id, true, [
|
||||
'summary' => 'Noch nicht gespeichert',
|
||||
]);
|
||||
$this->assertSame('Noch nicht gespeichert', $draft->summary);
|
||||
$this->assertSame('Ein kurzer Teaser für die Karte', $element->fresh()->summary);
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'vorschau')
|
||||
->set('summary', 'Noch nicht gespeichert')
|
||||
->set('previewSurface', 'bibliothek')
|
||||
->assertSee('media-card')
|
||||
->assertSee('Noch nicht gespeichert');
|
||||
}
|
||||
|
||||
public function test_the_picker_keeps_drafts_for_modules_and_limits_images_and_website_choices(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film');
|
||||
$draft = $content->draftElementVersion($content->createElement('text', 'text', 'Offener Entwurf'), 'Text');
|
||||
$image = $content->createElement('bild', 'bild', 'Szenenbild');
|
||||
$image->thumbnail_path = 'vorschau/szenenbild.jpg';
|
||||
$image->save();
|
||||
$content->publishElementVersion($image, null, ['file' => 'inhalte/szenenbild.jpg']);
|
||||
$module = $content->createComposition('Abstand', CompositionKind::Uebung);
|
||||
$editor = $this->editor();
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
$modulePicker = Livewire::test(EditExercise::class, ['record' => $module->id])
|
||||
->call('openPicker')
|
||||
->set('pickerQuery', 'Offener');
|
||||
$titles = array_column($modulePicker->instance()->pickerResult()['items'], 'title');
|
||||
$this->assertContains('Offener Entwurf', $titles);
|
||||
$modulePicker->assertSee('Entwürfe bleiben sichtbar');
|
||||
|
||||
$page = Livewire::test(ViewContentElement::class, ['record' => $film->element->getKey()])
|
||||
->set('bereich', 'auswahl')
|
||||
->set('pickerContext', 'bild');
|
||||
$imageTitles = array_column($page->instance()->selection()['items'], 'title');
|
||||
$this->assertContains('Szenenbild', $imageTitles);
|
||||
$this->assertNotContains('Lara im Park', $imageTitles);
|
||||
$page->assertSee('Nur Bilder');
|
||||
|
||||
$page->set('pickerContext', 'website');
|
||||
$websiteTitles = array_column($page->instance()->selection()['items'], 'title');
|
||||
$this->assertContains('Offener Entwurf', $websiteTitles);
|
||||
$this->assertNotContains('Abstand', $websiteTitles);
|
||||
$page->assertSee('veröffentlicht nichts');
|
||||
|
||||
$target = null;
|
||||
foreach ($page->instance()->selection()['items'] as $item) {
|
||||
if ($item['title'] === 'Szenenbild') {
|
||||
$target = $item['target'];
|
||||
}
|
||||
}
|
||||
$page->set('pickerContext', 'bild')
|
||||
->set('pickerSelected', $target)
|
||||
->call('adoptLibraryImage')
|
||||
->assertSee('keine neue Fassung');
|
||||
|
||||
$film->element->refresh();
|
||||
$this->assertSame('vorschau/szenenbild.jpg', $film->element->thumbnail_path);
|
||||
$this->assertSame(1, $film->element->versions()->count());
|
||||
$this->assertSame($draft->id, $draft->fresh()->id);
|
||||
}
|
||||
|
||||
public function test_browsing_images_does_not_return_films(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$content->publishElementVersion($content->createElement('film', 'film', 'Nur ein Film'), 'Film');
|
||||
$content->publishElementVersion($content->createElement('bild', 'bild', 'Nur ein Bild'), null, ['file' => 'inhalte/bild.jpg']);
|
||||
|
||||
$titles = array_column(
|
||||
app(EditorialCatalog::class)->browse('', 'bild', '', 0)['items'],
|
||||
'title',
|
||||
);
|
||||
|
||||
$this->assertSame(['Nur ein Bild'], $titles);
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user