film(); $mine = $this->picture('Meine Galerie'); $theirs = $this->picture('Fremde Galerie'); $page = Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien'); app(PresentationMedia::class)->assign($film, 'galerie', $theirs->id, null); $page->call('openPresentationPicker', 'galerie') ->call('assignFromPicker', 'medium:'.$mine->id) ->call('saveRedaktion'); $this->assertEqualsCanonicalizing([$theirs->id, $mine->id], $this->order($film, 'galerie')); } public function test_adding_to_an_occupied_single_role_is_an_exchange(): void { $film = $this->film(); $old = $this->picture('Altes Titelbild'); $new = $this->picture('Neues Titelbild'); app(PresentationMedia::class)->assign($film, 'titelbild', $old->id, null); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->call('openPresentationPicker', 'titelbild') ->assertSee('Wird ersetzt') ->assertSee('Diese Rolle hat nur ein Medium.') ->call('markPicker', 'medium:'.$new->id, true) ->assertSee('Austauschen') ->call('confirmPicker') ->assertSee('„Neues Titelbild“ ersetzt „Altes Titelbild“ an derselben Stelle') ->call('saveRedaktion'); $this->assertSame([$new->id], $this->order($film, 'titelbild')); $this->assertNotNull($old->fresh()); } public function test_a_stock_image_can_become_the_preview_image_through_the_shared_picker(): void { $film = $this->film(); $image = $this->picture('Szenenbild'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openThumbnailPicker') ->assertSee('Vorschaubild aus dem Bestand') ->assertSee('Szenenbild') ->call('markPicker', 'medium:'.$image->id, true) ->assertSee('Als Vorschaubild übernehmen') ->call('confirmPicker') ->assertSet('pickerOpen', false) ->assertSet('pictureFeedback', 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.'); $this->assertSame($image->thumbnail_path, $film->fresh()->thumbnail_path); $this->assertSame(1, $film->fresh()->versions()->count()); } public function test_confirmations_use_the_shared_dialog_and_only_known_actions(): void { $film = $this->film(); $film->teaser = 'Gespeichert'; $film->save(); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion') ->set('teaser', 'Offen') ->call('askConfirmation', 'discardRedaktion') ->assertSee('Änderungen der Redaktion verwerfen?') ->call('cancelConfirmation') ->assertSet('teaser', 'Offen') ->call('askConfirmation', 'discardRedaktion') ->call('confirmConfirmation') ->assertSet('teaser', 'Gespeichert') ->call('askConfirmation', 'saveRedaktionTexte') ->assertSet('bestaetigung', null); } public function test_only_editors_change_the_redaktion_and_the_address_does_not_bypass_it(): void { $film = $this->film(); $keeper = User::factory()->katalogverwalter()->create(); $keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); Livewire::actingAs($keeper, 'staff') ->withQueryParams(['redaktion' => '1']) ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->assertSet('redaktionOpen', false) ->assertDontSee('Redaktion bearbeiten') ->call('saveRedaktion') ->assertForbidden(); foreach (['removePresentation' => ['a1'], 'confirmPicker' => [], 'openPresentationPicker' => []] as $method => $arguments) { Livewire::actingAs($keeper, 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->set('pickerMarked', ['medium:1' => 'x']) ->call($method, ...$arguments) ->assertForbidden(); } $this->assertSame(0, PresentationAssignment::query()->count()); } public function test_the_license_article_needs_the_catalog_role_and_offers_no_global_release_there(): void { $content = app(ContentService::class); $film = $this->film(); $version = $film->versions()->first(); $articles = app(ArticleService::class); $article = $articles->create('LARA-PARK', 'Alltag'); $articles->publishRelease($article, $version, 'Derselbe Unterrichtsfilm'); $image = $this->picture('Artikelbild'); app(PresentationMedia::class)->assign($article, 'titelbild', $image->id, null); $this->actingAs($this->editor(), 'staff') ->get(LicenseArticleResource::getUrl('view', ['record' => $article])) ->assertForbidden(); $keeper = User::factory()->katalogverwalter()->create(); $keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); Livewire::actingAs($keeper, 'staff') ->test(ViewLicenseArticle::class, ['record' => $article->getKey()]) ->call('openRedaktion', 'medien') ->assertSee('Artikelbild') ->assertSee('Medium öffnen') ->assertDontSee('Für die Website freigeben') ->assertDontSee('Website-Freigabe zurücknehmen'); } public function test_aufbau_keeps_local_inputs_while_switching_and_saves_only_with_the_draft(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis'); $film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film'); $extra = $content->publishElementVersion($content->createElement('bild', 'bild', 'Szenenbild'), null, ['file' => 'inhalte/szene.jpg']); $version = $content->publishComposition( $content->createComposition('Wechsel', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $sheet], ['role' => 'Film', 'target' => $film]], ); $page = Livewire::actingAs($this->editor(), 'staff') ->test(EditExercise::class, ['record' => $version->composition_id]) ->assertSet('selected', 0) ->assertSee('Position 1 von 2') ->set('roleDraft', 'Einstieg') ->set('noteDraft', 'Zuerst besprechen') ->call('selectPart', 1) ->assertSet('roleDraft', 'Film') ->call('selectPart', 0) ->assertSet('roleDraft', 'Einstieg') ->assertSet('noteDraft', 'Zuerst besprechen') ->call('addPart', 'element:'.$extra->id) ->assertSet('selected', 2) ->assertSee('Änderungen am Aufbau nicht gespeichert'); $this->assertNull($version->composition->fresh()->working_draft); $page->call('askConfirmation', 'removePart', 2) ->assertSee('„Szenenbild“ aus diesem Aufbau entfernen?') ->call('confirmConfirmation') ->assertSee('Das Quellobjekt bleibt im Bestand') ->call('saveDraft'); $draft = $version->composition->fresh()->working_draft; $this->assertSame(['Einstieg', 'Film'], array_column($draft['members'], 'role')); $this->assertSame('Zuerst besprechen', $draft['members'][0]['note']); $this->assertNotNull($extra->fresh()); $this->assertSame(1, $version->composition->fresh()->versions()->count()); } public function test_a_referenced_module_shows_its_source_content_read_only(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Trainerunterlage Abstand'), 'Hinweis'); $module = $content->publishComposition($content->createComposition('Modul Abstand', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $sheet]]); $program = $content->publishComposition($content->createComposition('Programm Abstand', CompositionKind::Kurs), [['role' => 'Einstieg', 'target' => $module]]); Livewire::actingAs($this->editor(), 'staff') ->test(EditCourse::class, ['record' => $program->composition_id]) ->assertDontSee('Inhalt der Quelle') ->call('toggleExpanded', 0) ->assertSee('Inhalt der Quelle') ->assertSee('Nur zur Ansicht') ->assertSee('Trainerunterlage Abstand') ->set('detailTab', 'quelle') ->assertSee('Quelle bearbeiten'); } public function test_the_library_note_names_the_version_members_actually_see(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'A'); $other = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt zwei'), 'B'); $module = $content->createComposition('Sichtbar', CompositionKind::Uebung); $first = $content->publishComposition($module, [['role' => 'Unterlage', 'target' => $sheet]]); $editor = $this->editor(); app(CompositionDisplayRelease::class)->release($first, $editor); $content->publishComposition($module->fresh(), [['role' => 'Unterlage', 'target' => $other]]); Livewire::actingAs($editor, 'staff') ->test(EditExercise::class, ['record' => $module->id]) ->call('showAufbauTab', 'verlauf') ->assertSee('In der Mitgliederbibliothek ist Fassung 1 sichtbar, die neuere Fassung 2 noch nicht.') ->assertDontSee('noch keine Fassung sichtbar'); $labels = array_column(app(EditorialCatalog::class)->statusChips($module->fresh(), false), 'label'); $this->assertContains('Bibliothek zeigt Fassung 1', $labels); $this->assertNotContains('In der Mitgliederbibliothek', $labels); } public function test_an_expanded_module_stays_expanded_when_it_moves(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Unterlage A'), 'A'); $other = $content->publishElementVersion($content->createElement('text', 'text', 'Unterlage B'), 'B'); $first = $content->publishComposition($content->createComposition('Erstes Modul', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $sheet]]); $second = $content->publishComposition($content->createComposition('Zweites Modul', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $other]]); $program = $content->publishComposition($content->createComposition('Programm', CompositionKind::Kurs), [['role' => 'Modul', 'target' => $first], ['role' => 'Modul', 'target' => $second]]); Livewire::actingAs($this->editor(), 'staff') ->test(EditCourse::class, ['record' => $program->composition_id]) ->call('toggleExpanded', 0) ->assertSee('Unterlage A') ->call('movePart', 0, 1) ->assertSee('Unterlage A') ->assertDontSee('Unterlage B'); } public function test_creating_a_medium_from_the_picker_closes_the_picker_first(): void { $module = app(ContentService::class)->createComposition('Neues Medium', CompositionKind::Uebung); Livewire::actingAs($this->editor(), 'staff') ->test(EditExercise::class, ['record' => $module->id]) ->call('openPicker') ->assertSee('Neues Medium anlegen') ->call('startCreateMedium') ->assertSet('pickerOpen', false) ->assertDontSee('Bestandteil auswählen'); } public function test_redaktion_return_keeps_open_composition_inputs_and_saves_only_editorial_text(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis'); $version = $content->publishComposition( $content->createComposition('Rueckweg', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $sheet]], ); $editor = $this->editor(); Livewire::actingAs($editor, 'staff') ->test(EditExercise::class, ['record' => $version->composition_id]) ->call('openPart', 0) ->set('roleDraft', 'Einstieg') ->set('learningGoal', 'Grenze erkennen') ->call('openRedaktion') ->assertSet('redaktionOpen', true) ->assertSee('Redaktion speichern') ->assertSee('Zurück zum Aufbau') ->assertSee('Präsentationsmedien') ->assertDontSee('In Mitgliederbibliothek anzeigen') ->assertDontSee('Vorschau für Trainer') ->assertSet('roleDraft', 'Einstieg') ->assertSet('learningGoal', 'Grenze erkennen') ->set('teaser', 'Kurzer Teaser im Manager') ->assertSee('Änderungen nicht gespeichert') ->call('closeRedaktion') ->assertSet('redaktionOpen', false) ->assertSee('Die Redaktion hat ungespeicherte Änderungen.') ->assertSet('teaser', 'Kurzer Teaser im Manager') ->assertSet('roleDraft', 'Einstieg') ->assertSet('learningGoal', 'Grenze erkennen') ->call('saveRedaktion') ->assertSee('Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.') ->assertSet('learningGoal', 'Grenze erkennen'); $composition = $version->composition->fresh(); $this->assertSame('Kurzer Teaser im Manager', $composition->teaser); $this->assertSame(1, $composition->versions()->count()); $this->assertNull($composition->versions()->first()->learning_goal); $this->assertSame('Unterlage', $composition->versions()->first()->members()->first()->role); } public function test_didactic_dialog_and_draft_discard_do_not_touch_open_redaktion_inputs(): void { $content = app(ContentService::class); $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis'); $version = $content->publishComposition( $content->createComposition('Verdeckt', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $sheet]], ); $page = Livewire::actingAs($this->editor(), 'staff') ->test(EditExercise::class, ['record' => $version->composition_id]) ->call('openRedaktion') ->set('teaser', 'Noch nicht gespeichert') ->call('closeRedaktion') ->call('openModule') ->set('durationMinutes', '20') ->call('saveDraft') ->call('saveCatalogImage') ->assertSet('teaser', 'Noch nicht gespeichert'); $this->assertNull($version->composition->fresh()->teaser); $page->call('discardDraft') ->assertSet('teaser', 'Noch nicht gespeichert'); $this->assertNull($version->composition->fresh()->teaser); } public function test_media_redaktion_return_keeps_the_open_version_text(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); $editor = $this->editor(); Livewire::actingAs($editor, 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->set('bereich', 'inhalt') ->set('bodyDraft', 'Offener Lehrtext') ->set('thumbnailAlt', 'Offener Alternativtext') ->call('openRedaktion') ->assertSee('Zurück zur Medienbearbeitung') ->set('teaser', 'Neuer Teaser') ->call('closeRedaktion') ->assertSet('redaktionOpen', false) ->assertSet('bereich', 'inhalt') ->assertSet('bodyDraft', 'Offener Lehrtext') ->assertSet('thumbnailAlt', 'Offener Alternativtext') ->assertSet('teaser', 'Neuer Teaser') ->call('openRedaktion') ->assertSet('teaser', 'Neuer Teaser') ->call('saveRedaktion') ->call('closeRedaktion') ->assertSet('thumbnailAlt', 'Offener Alternativtext'); $film->refresh(); $this->assertSame('Neuer Teaser', $film->teaser); $this->assertNull($film->thumbnail_alt); } public function test_the_redaktion_state_lives_in_the_address_for_browser_back(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); Livewire::actingAs($this->editor(), 'staff') ->withQueryParams(['redaktion' => '1']) ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->assertSet('redaktionOpen', true) ->assertSee('Zurück zur Medienbearbeitung') ->set('teaser', 'Offen beim Zurückblättern') ->set('redaktionOpen', false) ->assertDontSee('Zurück zur Medienbearbeitung') ->assertSee('Redaktion mit ungespeicherten Änderungen') ->assertSet('teaser', 'Offen beim Zurückblättern'); $this->assertNull($film->fresh()->teaser); } public function test_website_release_does_not_save_open_redaktion_inputs(): void { $content = app(ContentService::class); $image = $content->createElement('bild', 'bild', 'Szenenbild'); $editor = $this->editor(); Livewire::actingAs($editor, 'staff') ->test(ViewContentElement::class, ['record' => $image->getKey()]) ->call('openRedaktion') ->set('websiteCredit', 'Offene Quellenzeile') ->set('teaser', 'Offener Teaser') ->call('closeRedaktion') ->set('bereich', 'website') ->call('releaseForWebsite') ->assertSet('websiteCredit', 'Offene Quellenzeile') ->assertSet('teaser', 'Offener Teaser'); $image->refresh(); $this->assertNull($image->website_credit); $this->assertNull($image->teaser); } public function test_presentation_changes_are_staged_until_redaktion_is_saved(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); $first = $this->picture('Galerie eins'); $second = $this->picture('Galerie zwei'); $page = Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->call('openPresentationPicker', 'galerie') ->call('markPicker', 'medium:'.$first->id, true) ->call('markPicker', 'medium:'.$second->id, true) ->set('pickerQuery', 'etwas ganz anderes') ->assertSet('pickerMarked', ['medium:'.$first->id => 'Galerie eins', 'medium:'.$second->id => 'Galerie zwei']) ->assertSee('2 Medien übernehmen') ->call('confirmPicker') ->assertSet('pickerOpen', false) ->assertSee('Neu zugeordnet') ->assertSee('Änderungen nicht gespeichert'); $this->assertSame(0, PresentationAssignment::query()->where('subject_id', $film->id)->count()); $page->call('saveRedaktion')->assertSee('Alle Änderungen gespeichert'); $this->assertSame([$first->id, $second->id], $this->order($film, 'galerie')); } public function test_cancelling_the_picker_keeps_the_existing_assignment(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); $cover = $this->picture('Titel alt'); $other = $this->picture('Titel neu'); app(PresentationMedia::class)->assign($film, 'titelbild', $cover->id, null); $key = 'a'.PresentationAssignment::query()->value('id'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->call('beginExchange', $key) ->call('markPicker', 'medium:'.$other->id, true) ->call('closePicker') ->assertSee('Die vorhandene Zuordnung bleibt unverändert.') ->assertSee('Alle Änderungen gespeichert'); $this->assertSame([$cover->id], $this->order($film, 'titelbild')); } public function test_exchange_keeps_the_position_and_reordering_stays_within_its_role(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); $one = $this->picture('Bild eins'); $two = $this->picture('Bild zwei'); $three = $this->picture('Bild drei'); $replacement = $this->picture('Bild neu'); $cover = $this->picture('Titel'); $media = app(PresentationMedia::class); $media->assign($film, 'titelbild', $cover->id, null); foreach ([$one, $two, $three] as $image) { $media->assign($film, 'galerie', $image->id, null); } $keyOf = fn (ContentElement $image): string => 'a'.PresentationAssignment::query()->where('content_element_id', $image->id)->value('id'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->call('beginExchange', $keyOf($two)) ->call('markPicker', 'medium:'.$replacement->id, true) ->assertSee('Austauschen') ->call('confirmPicker') ->assertSee('ersetzt „Bild zwei“ an derselben Stelle') ->call('movePresentation', $keyOf($three), -1) ->call('movePresentation', $keyOf($one), -1) ->call('saveRedaktion'); $this->assertSame([$one->id, $three->id, $replacement->id], $this->order($film, 'galerie')); $this->assertSame([$cover->id], $this->order($film, 'titelbild')); $this->assertNotNull($two->fresh(), 'Entfernen einer Zuordnung löscht das Medium nicht.'); } public function test_removing_an_assignment_keeps_the_medium_and_its_website_release(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); $image = $this->picture('Freigegebenes Bild'); $image->website_released_at = now(); $image->save(); app(PresentationMedia::class)->assign($film, 'titelbild', $image->id, null); $key = 'a'.PresentationAssignment::query()->value('id'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->call('removePresentation', $key) ->assertSee('Änderungen nicht gespeichert') ->call('saveRedaktion'); $this->assertSame(0, PresentationAssignment::query()->where('subject_id', $film->id)->count()); $this->assertNotNull($image->fresh()); $this->assertNotNull($image->fresh()->website_released_at); } public function test_discarding_the_redaktion_restores_saved_values_only(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $film->teaser = 'Gespeichert'; $film->save(); $content->publishElementVersion($film, 'Filmfassung'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->set('bodyDraft', 'Offener Lehrtext') ->call('openRedaktion') ->set('teaser', 'Verworfen') ->set('variantBody', 'Nur für die Kachel') ->call('saveVariant') ->call('discardRedaktion') ->assertSet('teaser', 'Gespeichert') ->assertSet('bodyDraft', 'Offener Lehrtext') ->assertSee('Alle Änderungen gespeichert'); $this->assertSame(0, EditorialTextVariant::query()->count()); } public function test_a_missing_working_title_is_shown_at_the_field_and_nothing_is_saved(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->call('openRedaktion', 'medien') ->set('workingTitle', '') ->set('teaser', 'Bleibt offen') ->call('saveRedaktion') ->assertSet('redaktionTab', 'texte') ->assertSet('redaktionFehlerFeld', 'workingTitle') ->assertSee('Der Arbeitstitel fehlt.') ->assertSet('teaser', 'Bleibt offen'); $this->assertNull($film->fresh()->teaser); $this->assertSame('Lara im Park', $film->fresh()->working_title); } private function film(): ContentElement { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $content->publishElementVersion($film, 'Filmfassung'); return $film->fresh(); } private function picture(string $title): ContentElement { $image = app(ContentService::class)->createElement('bild', 'bild', $title); $image->thumbnail_path = 'vorschau/'.md5($title).'.jpg'; $image->save(); return $image; } /** * @return list */ private function order(ContentElement $subject, string $role): array { return PresentationAssignment::query() ->where('subject_type', $subject->getMorphClass()) ->where('subject_id', $subject->id) ->whereHas('role', fn ($query) => $query->where('slug', $role)) ->orderBy('position') ->pluck('content_element_id') ->map(fn ($id): int => (int) $id) ->all(); } public function test_switching_versions_keeps_an_unsaved_text_until_the_editor_confirms(): void { $content = app(ContentService::class); $text = $content->createElement('text', 'text', 'Trainerunterlage'); $first = $content->publishElementVersion($text, 'Erster Wortlaut'); $second = $content->draftElementVersion($text, 'Zweiter Wortlaut'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $text->getKey()]) ->assertSet('bodyDraft', 'Erster Wortlaut') ->set('bodyDraft', 'Offener Wortlaut') ->assertSee('Text der Fassung nicht gespeichert') ->call('showVersion', $second->id) ->assertSet('bodyDraft', 'Offener Wortlaut') ->assertSee('Ungespeicherten Text verwerfen?') ->call('cancelConfirmation') ->assertSet('bodyDraft', 'Offener Wortlaut') ->call('showVersion', $second->id) ->call('confirmConfirmation') ->assertSet('fassung', $second->id) ->assertSet('bodyDraft', 'Zweiter Wortlaut') ->assertDontSee('Text der Fassung nicht gespeichert'); $this->assertSame('Erster Wortlaut', $first->fresh()->body); } public function test_saving_a_released_text_selects_the_new_version(): void { $content = app(ContentService::class); $text = $content->createElement('text', 'text', 'Trainerunterlage'); $first = $content->publishElementVersion($text, 'Erster Wortlaut'); $content->publishElementVersion($text, 'Zweiter Wortlaut'); $content->publishComposition($content->createComposition('Modul mit Unterlage', CompositionKind::Uebung), [['role' => 'Unterlage', 'target' => $first]]); $component = Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $text->getKey()]) ->call('showVersion', $first->id) ->assertSet('bodyDraft', 'Erster Wortlaut') ->set('bodyDraft', 'Dritter Wortlaut') ->assertSee('Fassung 1 ist freigegeben und wird verwendet.') ->assertSee('Eingebunden in') ->assertSee('Modul mit Unterlage') ->call('saveShownText') ->assertSee('Fassung 3 ist angelegt. Fassung 1 bleibt erhalten.'); $third = $text->versions()->where('number', 3)->firstOrFail(); $component->assertSet('fassung', $third->id)->assertSet('bodyDraft', 'Dritter Wortlaut'); $this->assertSame('Erster Wortlaut', $first->fresh()->body); } public function test_media_versions_are_listed_left_and_the_chosen_one_is_shown_right(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $first = $content->publishElementVersion($film, 'Erste Filmfassung'); $second = $content->publishElementVersion($film, 'Zweite Filmfassung'); $content->block($first, 'Alter Schnitt'); $draft = $content->draftElementVersion($film, 'Dritte Filmfassung'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->assertSee('Inhalt und Fassungen') ->assertSeeText('Fassungen · 3') ->assertSee('Fassung 2, Freigegeben') ->call('showVersion', $draft->id) ->assertSet('fassung', $draft->id) ->assertSee('Entwurf, noch nicht freigegeben') ->assertSee('Diese Fassung freigeben') ->mountAction('releaseVersion', ['version' => $draft->id]) ->tap(fn ($component) => $this->assertSame('Fassung 3 freigeben', $component->instance()->getMountedAction()->getModalHeading())) ->unmountAction() ->mountAction('deactivate', ['version' => $second->id]) ->tap(fn ($component) => $this->assertSame('Fassung 2 deaktivieren', $component->instance()->getMountedAction()->getModalHeading())) ->unmountAction() ->call('showVersion', $first->id) ->assertSee('Begründung: Alter Schnitt') ->assertDontSee('Diese Fassung freigeben'); } public function test_releasing_another_version_does_not_move_the_shown_text_onto_it(): void { $content = app(ContentService::class); $text = $content->createElement('text', 'text', 'Trainerunterlage'); $first = $content->publishElementVersion($text, 'Erster Wortlaut'); $draft = $content->draftElementVersion($text, 'Zweiter Wortlaut'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $text->getKey()]) ->assertSet('bodyDraft', 'Erster Wortlaut') ->callAction('releaseVersion', [], ['version' => $draft->id]) ->assertSet('fassung', $first->id) ->assertSet('bodyDraft', 'Erster Wortlaut') ->assertDontSee('Text der Fassung nicht gespeichert'); $this->assertSame('Zweiter Wortlaut', $draft->fresh()->body); } public function test_a_foreign_version_in_the_address_still_pins_the_shown_version(): void { $content = app(ContentService::class); $text = $content->createElement('text', 'text', 'Trainerunterlage'); $first = $content->publishElementVersion($text, 'Erster Wortlaut'); $draft = $content->draftElementVersion($text, 'Zweiter Wortlaut'); $foreign = $content->publishElementVersion($content->createElement('text', 'text', 'Anderes Blatt'), 'Fremd'); Livewire::withQueryParams(['fassung' => $foreign->id]) ->actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $text->getKey()]) ->assertSet('fassung', $first->id) ->assertSet('bodyDraft', 'Erster Wortlaut') ->callAction('releaseVersion', [], ['version' => $draft->id]) ->assertSet('fassung', $first->id) ->assertSet('bodyDraft', 'Erster Wortlaut') ->assertDontSee('Text der Fassung nicht gespeichert'); } public function test_a_new_version_from_the_dialog_is_shown_with_its_own_text(): void { $content = app(ContentService::class); $text = $content->createElement('text', 'text', 'Trainerunterlage'); $content->publishElementVersion($text, 'Erster Wortlaut'); $component = Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $text->getKey()]) ->callAction('revise', ['body' => 'Neuer Wortlaut', 'change_note' => 'Neu']) ->assertHasNoFormErrors(); $second = $text->versions()->where('number', 2)->firstOrFail(); $component->assertSet('fassung', $second->id) ->assertSet('bodyDraft', 'Neuer Wortlaut') ->assertDontSee('Text der Fassung nicht gespeichert'); } public function test_the_frame_slider_starts_at_the_current_preview_frame(): void { $content = app(ContentService::class); $film = $content->createElement('film', 'film', 'Lara im Park'); $version = $content->publishElementVersion($film, 'Filmfassung'); $film->forceFill(['thumbnail_source' => 'frame:'.$version->id.'@41.5'])->save(); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $film->getKey()]) ->set('bereich', 'vorschaubild') ->assertSee('Vorschaubild aus dem Film bei 41.5 Sekunden.') ->assertSee('{ second: "41.5" }') ->set('frameSecond', '12') ->assertSee('{ second: "12" }'); } public function test_the_old_versions_area_opens_the_combined_register(): void { $content = app(ContentService::class); $version = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'A'); $editor = $this->editor(); Livewire::actingAs($editor, 'staff') ->test(ViewContentElement::class, ['record' => $version->content_element_id]) ->set('bereich', 'fassungen') ->assertSet('bereich', 'inhalt') ->set('bereich', 'vorschaubild') ->assertSee('Bild aus dem Bestand wählen') ->assertSee('Alternativtext'); $this->actingAs($editor, 'staff') ->get(ViewContentElement::getUrl(['record' => $version->content_element_id]).'?bereich=fassungen&fassung='.$version->id) ->assertOk() ->assertSee('Inhalt und Fassungen'); } public function test_a_medium_without_versions_offers_the_first_version_instead_of_an_empty_list(): void { $image = app(ContentService::class)->createElement('bild', 'bild', 'Szenenbild'); Livewire::actingAs($this->editor(), 'staff') ->test(ViewContentElement::class, ['record' => $image->getKey()]) ->assertSee('Noch keine Inhaltsfassung') ->assertSee('Erste Fassung anlegen') ->assertDontSeeText('Fassungen · 0'); } private function editor(): User { $editor = User::factory()->redakteur()->create(); $editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); return $editor; } }