Struktur links mit Position, Ziehgriff, aufklappbarem Quelleninhalt und Auf/Ab für die ausgewählte Verwendung; rechts der Detailbereich mit „An dieser Stelle“ (Rolle, Hinweis, Fassung), „Quelle“ und „Inhaltsvorschau“. Didaktik und Katalogbild sowie Fassungen und Verwendung sind eigene Bereiche statt Dialog und Seitenspalte. Freigabe- und Textdialog nutzen den gemeinsamen Dialog. Entfernt verdeckte Speicherungen: Hinzufügen eines Bestandteils speichert den Entwurf nicht mehr nebenbei (Ausnahme: ausdrückliches „Zurück und einbinden“), der Textwortlaut wird an der Quelle gespeichert, ohne den Aufbau mitzuspeichern. Der Mediendialog „Angaben und Vorschaubild“ war ein zweiter Editor für Medientexte und weicht „Quelle bearbeiten“. Vorhandene Bilder als Katalogbild kommen über den gemeinsamen Picker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
860 lines
40 KiB
PHP
860 lines
40 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Catalog\Composition;
|
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Catalog\ContentElementVersion;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Domain\Catalog\ContentVersionStatus;
|
|
use App\Domain\Media\ThumbnailDeriver;
|
|
use App\Filament\Pages\EditorialDesk;
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use App\Filament\Resources\Courses\CourseResource;
|
|
use App\Filament\Resources\Courses\Pages\EditCourse;
|
|
use App\Filament\Resources\Exercises\ExerciseResource;
|
|
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
|
use App\Models\User;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class EditorialEditorTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
|
}
|
|
|
|
public function test_the_desk_finds_a_program_and_a_module_by_name(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$module = $content->publishComposition(
|
|
$content->createComposition('Modul Abstand', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
$content->publishComposition(
|
|
$content->createComposition('Programm Abstand', CompositionKind::Kurs),
|
|
[['role' => 'Modul', 'target' => $module]],
|
|
);
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditorialDesk::class)
|
|
->assertSee('Programm Abstand')
|
|
->assertSee('Modul Abstand')
|
|
->set('query', 'Programm')
|
|
->assertSee('Programm Abstand')
|
|
->assertDontSee('Modul Abstand')
|
|
->set('query', 'kein-treffer')
|
|
->assertSee('Nichts gefunden');
|
|
}
|
|
|
|
public function test_display_data_does_not_create_a_version_and_a_module_works_without_a_film(): void
|
|
{
|
|
$editor = $this->editor();
|
|
$module = app(ContentService::class)->createComposition('Ohne Film', CompositionKind::Uebung);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->assertSee('Ein Film ist nicht nötig')
|
|
->set('displayTitle', 'Sichtbar ohne Film')
|
|
->set('summary', 'Nur eine Beschreibung')
|
|
->call('saveDisplay')
|
|
->assertSet('feedback', 'Die Anzeige ist gespeichert. Die Fassung bleibt unverändert.')
|
|
->set('learningGoal', 'Den Abstand erklären')
|
|
->call('publishRevision')
|
|
->assertSet('feedback', 'Eine Fassung braucht mindestens einen Bestandteil. Anzeige und Kurzbeschreibung kannst du schon speichern.')
|
|
->set('newTextTitle', 'Hinweis ohne Film')
|
|
->set('newTextBody', 'Zuerst den Abstand ansprechen.')
|
|
->call('addText')
|
|
->set('releaseConsent', true)
|
|
->call('publishRevision');
|
|
|
|
$module->refresh();
|
|
|
|
$this->assertSame('Sichtbar ohne Film', $module->display_title);
|
|
$this->assertSame(1, $module->versions()->count());
|
|
$this->assertSame('Den Abstand erklären', $module->versions()->first()->learning_goal);
|
|
$this->assertSame(1, $module->versions()->first()->members()->count());
|
|
}
|
|
|
|
public function test_reordering_reuses_a_medium_and_keeps_the_released_version(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion(
|
|
$content->createElement('text', 'text', 'Trainerunterlage Abstand'),
|
|
'Im Kurs zuerst den Abstand ansprechen.',
|
|
);
|
|
$film = $content->publishElementVersion(
|
|
$content->createElement('film', 'film', 'Lara im Park'),
|
|
'Film',
|
|
);
|
|
$firstModule = $content->publishComposition(
|
|
$content->createComposition('Modul Abstand', CompositionKind::Uebung),
|
|
[
|
|
['role' => 'Unterlage', 'target' => $sheet],
|
|
['role' => 'Film', 'target' => $film],
|
|
],
|
|
null,
|
|
null,
|
|
['learning_goal' => 'Abstand halten', 'duration_minutes' => 15],
|
|
);
|
|
$secondModule = $content->publishComposition(
|
|
$content->createComposition('Modul Hilfe', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
$programVersion = $content->publishComposition(
|
|
$content->createComposition('Programm Abstand', CompositionKind::Kurs),
|
|
[
|
|
['role' => 'Modul', 'target' => $firstModule],
|
|
['role' => 'Modul', 'target' => $secondModule],
|
|
],
|
|
);
|
|
$editor = $this->editor();
|
|
app(CompositionDisplayRelease::class)->release($programVersion, $editor);
|
|
app(CompositionDisplayRelease::class)->release($firstModule, $editor);
|
|
|
|
$component = Livewire::actingAs($editor, 'staff')
|
|
->test(EditCourse::class, ['record' => $programVersion->composition_id])
|
|
->assertSee('Modul Abstand')
|
|
->assertSee('Modul Hilfe');
|
|
$members = $component->get('members');
|
|
$component->set('members', array_reverse($members))
|
|
->call('publishRevision')
|
|
->assertSet('feedback', 'Fassung 2 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.');
|
|
|
|
$versions = $programVersion->composition->versions()->with('members')->orderBy('number')->get();
|
|
|
|
$this->assertCount(2, $versions);
|
|
$this->assertSame($firstModule->id, $versions[0]->members[0]->nested_composition_version_id);
|
|
$this->assertSame($secondModule->id, $versions[1]->members[0]->nested_composition_version_id);
|
|
$this->assertTrue(app(CompositionDisplayRelease::class)->isReleased($versions[0]));
|
|
$this->assertFalse(app(CompositionDisplayRelease::class)->isReleased($versions[1]));
|
|
$this->assertSame($sheet->id, $firstModule->members()->first()->content_element_version_id);
|
|
$this->assertSame('Im Kurs zuerst den Abstand ansprechen.', $sheet->fresh()->body);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditCourse::class, ['record' => $programVersion->composition_id])
|
|
->call('releaseDisplay');
|
|
|
|
$this->assertTrue(app(CompositionDisplayRelease::class)->isReleased($versions[0]->fresh()));
|
|
$this->assertTrue(app(CompositionDisplayRelease::class)->isReleased($versions[1]->fresh()));
|
|
$this->assertSame(1, $film->element->versions()->count());
|
|
|
|
$this->actingAs($editor, 'staff')
|
|
->get(route('editorial.preview', ['composition' => $programVersion->composition, 'version' => $versions[1]]))
|
|
->assertOk()
|
|
->assertSee('Vorschau für die Redaktion')
|
|
->assertSee('Modul Hilfe')
|
|
->assertSee('Lara im Park')
|
|
->assertSee('Trainerunterlage Abstand');
|
|
}
|
|
|
|
public function test_a_new_module_returns_into_the_program(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$program = $content->publishComposition(
|
|
$content->createComposition('Programm Abstand', CompositionKind::Kurs),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
$editor = $this->editor();
|
|
$programUrl = CourseResource::getUrl('edit', ['record' => $program->composition]);
|
|
|
|
$created = Livewire::actingAs($editor, 'staff')
|
|
->test(EditCourse::class, ['record' => $program->composition_id])
|
|
->set('newModuleName', 'UX-Prüfung Modul')
|
|
->call('startModule');
|
|
$module = Composition::query()->where('designation', 'UX-Prüfung Modul')->firstOrFail();
|
|
|
|
$this->assertSame(CompositionKind::Uebung, $module->kind);
|
|
|
|
$this->actingAs($editor, 'staff')
|
|
->get(ExerciseResource::getUrl('edit', ['record' => $module]).'?zurueck='.urlencode('http://example.test/verwaltung/kurse/1'))
|
|
->assertOk()
|
|
->assertSee('Zurück und einbinden');
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->set('returnUrl', $programUrl)
|
|
->set('newTextTitle', 'UX-Prüfung Text')
|
|
->set('newTextBody', 'Nur für die Bedienprüfung.')
|
|
->call('addText')
|
|
->call('returnAndInclude')
|
|
->assertSet('releaseArmed', true)
|
|
->assertSee('Noch nicht freigegeben')
|
|
->set('releaseConsent', true)
|
|
->call('publishRevision')
|
|
->assertRedirect();
|
|
|
|
$version = $module->versions()->firstOrFail();
|
|
|
|
$this->actingAs($editor, 'staff')
|
|
->get($programUrl.'?uebernehmen=composition:'.$version->id)
|
|
->assertOk()
|
|
->assertSee('UX-Prüfung Modul')
|
|
->assertSee('ist in den Aufbau übernommen');
|
|
|
|
$this->assertSame(1, $program->composition->versions()->count());
|
|
$this->assertSame($sheet->id, $program->fresh()->members()->first()->content_element_version_id);
|
|
}
|
|
|
|
public function test_a_role_change_stays_on_the_selected_part_when_the_order_changes(): 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');
|
|
$program = $content->publishComposition(
|
|
$content->createComposition('Programm Abstand', CompositionKind::Kurs),
|
|
[
|
|
['role' => 'Unterlage', 'target' => $sheet],
|
|
['role' => 'Film', 'target' => $film],
|
|
],
|
|
);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditCourse::class, ['record' => $program->composition_id])
|
|
->call('selectPart', 1)
|
|
->set('roleDraft', 'Film zum Einstieg')
|
|
->assertSet('members.0.role', 'Unterlage')
|
|
->assertSet('members.1.role', 'Film zum Einstieg')
|
|
->call('movePart', 1, -1)
|
|
->call('publishRevision')
|
|
->assertSet('feedback', 'Fassung 2 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.');
|
|
|
|
$versions = $program->composition->versions()->with('members')->orderBy('number')->get();
|
|
|
|
$this->assertCount(2, $versions);
|
|
$this->assertSame('Unterlage', $versions[0]->members[0]->role);
|
|
$this->assertSame('Film', $versions[0]->members[1]->role);
|
|
$this->assertSame('Film zum Einstieg', $versions[1]->members[0]->role);
|
|
$this->assertSame($film->id, $versions[1]->members[0]->content_element_version_id);
|
|
$this->assertSame('Unterlage', $versions[1]->members[1]->role);
|
|
$this->assertSame($sheet->id, $versions[1]->members[1]->content_element_version_id);
|
|
}
|
|
|
|
public function test_saving_a_draft_ten_times_creates_one_version_only_when_released(): void
|
|
{
|
|
$editor = $this->editor();
|
|
$module = app(ContentService::class)->createComposition('Entwurf Modul', CompositionKind::Uebung);
|
|
$component = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->set('newTextTitle', 'Hinweis')
|
|
->set('newTextBody', 'Erst der Entwurf.')
|
|
->call('addText');
|
|
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
$component->set('learningGoal', 'Durchgang '.$i)->call('saveDraft');
|
|
}
|
|
|
|
$module->refresh();
|
|
$this->assertSame(0, $module->versions()->count());
|
|
$this->assertSame('Durchgang 10', $module->working_draft['learning_goal']);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->assertSet('learningGoal', 'Durchgang 10')
|
|
->set('releaseConsent', true)
|
|
->call('publishRevision')
|
|
->assertSet('feedback', 'Fassung 1 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.');
|
|
|
|
$module->refresh();
|
|
$this->assertSame(1, $module->versions()->count());
|
|
$this->assertSame('Durchgang 10', $module->versions()->first()->learning_goal);
|
|
$this->assertNull($module->working_draft);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->set('learningGoal', 'Nur Entwurf')
|
|
->call('saveDraft');
|
|
|
|
$module->refresh();
|
|
$this->assertSame(1, $module->versions()->count());
|
|
$this->assertSame('Durchgang 10', $module->versions()->first()->fresh()->learning_goal);
|
|
$this->assertSame('Nur Entwurf', $module->working_draft['learning_goal']);
|
|
}
|
|
|
|
public function test_the_picker_finds_a_film_by_title(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film');
|
|
$module = $content->createComposition('Picker Modul', CompositionKind::Uebung);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker')
|
|
->set('pickerQuery', 'Lara')
|
|
->assertSee('Lara im Park')
|
|
->assertSee('Neuen Text erstellen');
|
|
}
|
|
|
|
public function test_guests_cannot_open_the_trainer_preview(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Programm Abstand', CompositionKind::Kurs),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
|
|
$this->get(route('editorial.preview', ['composition' => $version->composition, 'version' => $version]))
|
|
->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('Aus Mitgliederbibliothek ausblenden')
|
|
->call('openModule')
|
|
->assertSee('Vorschlag aus dem Film Lara im Park')
|
|
->assertSee('Katalogbild')
|
|
->assertSee('Didaktik und Katalogbild')
|
|
->assertDontSee('Anzeige speichern')
|
|
->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])
|
|
->call('openModule')
|
|
->assertSet('aufbauTab', 'angaben')
|
|
->assertSee('Aus einem Film')
|
|
->assertSee('Bild aus dem Bestand wählen')
|
|
->assertSee('Hochladen')
|
|
->assertSee('Lara im Park')
|
|
->assertSee('Lara im Hof')
|
|
->assertDontSee('Anzeige speichern')
|
|
->assertDontSee('Titelbild speichern')
|
|
->assertSee('Vorschlag aus dem Film Lara im Park')
|
|
->call('adoptPicture', $first->element->id)
|
|
->assertDontSee('Vorschlag aus dem Film')
|
|
->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();
|
|
}
|
|
|
|
public function test_texts_save_in_the_redaktion_and_the_dialog_keeps_didactics_without_a_new_version(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Dialog Modul', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->assertDontSee('Anzeige speichern')
|
|
->call('openModule')
|
|
->assertSee('Didaktik')
|
|
->assertSee('Katalogbild')
|
|
->assertSee('Name, Texte, Präsentationsmedien und Einordnung bearbeitest du in der Redaktion.')
|
|
->set('learningGoal', 'Weg damit')
|
|
->call('discardDraft')
|
|
->assertSet('learningGoal', '');
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->call('openRedaktion')
|
|
->set('description', 'Ausführlicher Dialogtext')
|
|
->set('summary', 'Kurzer Dialogtext')
|
|
->call('saveRedaktion')
|
|
->assertSee('Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.');
|
|
|
|
$composition = $version->composition->fresh();
|
|
$this->assertSame(1, $composition->versions()->count());
|
|
$this->assertSame('Ausführlicher Dialogtext', $composition->description);
|
|
$this->assertNull($composition->working_draft);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->set('learningGoal', 'Nur im Entwurf')
|
|
->set('durationMinutes', '9')
|
|
->call('saveDraft');
|
|
|
|
$composition->refresh();
|
|
$this->assertSame(1, $composition->versions()->count());
|
|
$this->assertSame(ContentVersionStatus::Bereit, $composition->versions()->first()->status);
|
|
$this->assertSame('Nur im Entwurf', $composition->working_draft['learning_goal']);
|
|
$this->assertSame(9, $composition->working_draft['duration_minutes']);
|
|
}
|
|
|
|
public function test_the_picker_groups_versions_and_adopts_the_chosen_one(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$element = $content->createElement('film', 'film', 'Lara im Park');
|
|
$first = $content->publishElementVersion($element, 'Erste Stelle');
|
|
$second = $content->publishElementVersion($element, 'Zweite Stelle');
|
|
$module = $content->createComposition('Fassungswahl', CompositionKind::Uebung);
|
|
|
|
$component = Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker')
|
|
->set('pickerQuery', 'Lara')
|
|
->set('pickerSelected', 'element:'.$second->id);
|
|
|
|
$items = $component->instance()->pickerResult()['items'];
|
|
$this->assertCount(1, $items);
|
|
$this->assertSame('element:'.$second->id, $items[0]['target']);
|
|
|
|
$component
|
|
->assertSee('Fassung 1')
|
|
->assertSee('aktueller Stand')
|
|
->set('pickerSelected', 'element:'.$first->id)
|
|
->call('addPart', 'element:'.$first->id)
|
|
->assertSee('Gespeichert wird mit „Entwurf speichern“')
|
|
->call('saveDraft');
|
|
$module->refresh();
|
|
$this->assertSame(0, $module->versions()->count());
|
|
$this->assertSame('element:'.$first->id, $module->working_draft['members'][0]['target']);
|
|
}
|
|
|
|
public function test_the_picker_includes_draft_media(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$ready = $content->publishElementVersion($content->createElement('text', 'text', 'Fertiger Hinweis'), 'Text');
|
|
$onlyDraft = $content->draftElementVersion($content->createElement('film', 'film', 'Felix beim Onkel'), 'Szene');
|
|
$revised = $content->createElement('text', 'text', 'Hinweis mit Entwurf');
|
|
$content->publishElementVersion($revised, 'Alt');
|
|
$newerDraft = $content->draftElementVersion($revised, 'Neu');
|
|
$module = $content->createComposition('Auswahl', CompositionKind::Uebung);
|
|
|
|
$component = Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker');
|
|
|
|
$byTitle = [];
|
|
|
|
foreach ($component->instance()->pickerResult()['items'] as $item) {
|
|
$byTitle[$item['title']] = $item['target'];
|
|
}
|
|
|
|
$this->assertSame('element:'.$ready->id, $byTitle['Fertiger Hinweis']);
|
|
$this->assertSame('element:'.$onlyDraft->id, $byTitle['Felix beim Onkel']);
|
|
$this->assertSame('element:'.$newerDraft->id, $byTitle['Hinweis mit Entwurf']);
|
|
|
|
$component
|
|
->set('pickerSelected', 'element:'.$onlyDraft->id)
|
|
->assertSee('Felix beim Onkel')
|
|
->call('addPart', 'element:'.$onlyDraft->id)
|
|
->call('saveDraft');
|
|
|
|
$this->assertSame('element:'.$onlyDraft->id, $module->fresh()->working_draft['members'][0]['target']);
|
|
$this->assertSame(ContentVersionStatus::Entwurf, $onlyDraft->fresh()->status);
|
|
}
|
|
|
|
public function test_a_local_role_is_edited_in_place_and_saved_with_the_draft(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Rollendialog', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->assertSet('selected', 0)
|
|
->assertSee('An dieser Stelle')
|
|
->assertSee('Gilt nur hier. Die Quelle bleibt unverändert.')
|
|
->set('roleDraft', 'Einstieg')
|
|
->assertSee('Änderungen am Aufbau nicht gespeichert')
|
|
->call('saveDraft')
|
|
->assertSee('Es entsteht keine neue Fassung');
|
|
|
|
$composition = $version->composition->fresh();
|
|
$this->assertSame(1, $composition->versions()->count());
|
|
$this->assertSame('Unterlage', $composition->versions()->first()->members()->first()->role);
|
|
$this->assertSame('Einstieg', $composition->working_draft['members'][0]['role']);
|
|
}
|
|
|
|
public function test_a_missing_film_frame_does_not_create_a_version(): void
|
|
{
|
|
Storage::fake('media_derived');
|
|
$content = app(ContentService::class);
|
|
$element = $content->createElement('film', 'film', 'Lara im Park');
|
|
$film = $content->publishElementVersion($element, null, ['file' => 'inhalte/lara.mp4']);
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Rahmen Modul', CompositionKind::Uebung),
|
|
[['role' => 'Film', 'target' => $film]],
|
|
);
|
|
$editor = $this->editor();
|
|
|
|
$this->get(route('editorial.frame', ['version' => $film, 'sekunde' => '4.5']))
|
|
->assertRedirect();
|
|
$this->actingAs($editor, 'staff')
|
|
->get(route('editorial.frame', ['version' => $film, 'sekunde' => '4.5']))
|
|
->assertNotFound();
|
|
$this->actingAs($editor, 'staff')
|
|
->get(route('editorial.frame', ['version' => $film, 'sekunde' => 'nein']))
|
|
->assertNotFound();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->call('openModule')
|
|
->set('imageMode', 'film')
|
|
->set('frameVersionId', $film->id)
|
|
->set('frameSecond', '4.5')
|
|
->call('saveCatalogImage')
|
|
->assertSet('aufbauTab', 'angaben');
|
|
|
|
$composition = $version->composition->fresh();
|
|
$film->refresh();
|
|
$this->assertSame(1, $composition->versions()->count());
|
|
$this->assertNull($composition->thumbnail_path);
|
|
$this->assertNotNull($composition->thumbnail_error);
|
|
$this->assertSame('inhalte/lara.mp4', $film->metadata['file']);
|
|
Storage::disk('media_derived')->assertMissing('inhalte/lara.mp4');
|
|
}
|
|
|
|
public function test_a_placement_note_waits_for_release_and_keeps_the_old_version(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis');
|
|
$version = $content->publishComposition(
|
|
$content->createComposition('Stellenmodul', CompositionKind::Uebung),
|
|
[['role' => 'Unterlage', 'target' => $sheet]],
|
|
);
|
|
|
|
Livewire::actingAs($this->editor(), 'staff')
|
|
->test(EditExercise::class, ['record' => $version->composition_id])
|
|
->call('selectPart', 0)
|
|
->assertSee('Hinweis an dieser Stelle')
|
|
->set('noteDraft', 'Hier zuerst den Abstand ansprechen.')
|
|
->call('saveDraft')
|
|
->assertSee('Es entsteht keine neue Fassung')
|
|
->call('publishRevision');
|
|
|
|
$composition = $version->composition->fresh();
|
|
$this->assertSame(2, $composition->versions()->count());
|
|
$this->assertNull($version->fresh()->members()->first()->placement_note);
|
|
$released = $composition->versions()->where('number', 2)->first();
|
|
$this->assertSame('Hier zuerst den Abstand ansprechen.', $released->members()->first()->placement_note);
|
|
$this->assertSame(ContentVersionStatus::Bereit, $released->status);
|
|
}
|
|
|
|
public function test_a_module_text_stays_editable_until_it_is_released_and_used(): void
|
|
{
|
|
$editor = $this->editor();
|
|
$module = app(ContentService::class)->createComposition('Text im Modul', CompositionKind::Uebung);
|
|
$component = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->set('newTextTitle', 'Hinweis')
|
|
->set('newTextBody', 'Erster Wortlaut')
|
|
->call('addText')
|
|
->assertSee('Hinweis')
|
|
->call('saveDraft')
|
|
->call('selectPart', 0)
|
|
->set('detailTab', 'quelle')
|
|
->assertSee('dieselbe Fassung fort')
|
|
->set('partBody', 'Geänderter Wortlaut')
|
|
->call('saveSourceText')
|
|
->assertSee('derselben Fassung');
|
|
|
|
$element = ContentElement::query()->where('working_title', 'Hinweis')->firstOrFail();
|
|
$version = $element->versions()->sole();
|
|
|
|
$this->assertSame(ContentVersionStatus::Entwurf, $version->status);
|
|
$this->assertSame('Geänderter Wortlaut', $version->body);
|
|
$this->assertSame(1, $element->versions()->count());
|
|
|
|
$this->actingAs($editor, 'staff')
|
|
->get(ContentElementResource::getUrl('index'))
|
|
->assertOk()
|
|
->assertSee('Hinweis')
|
|
->assertSee('Entwurf');
|
|
|
|
$component->set('releaseConsent', true)->call('publishRevision');
|
|
$this->assertSame(ContentVersionStatus::Bereit, $version->fresh()->status);
|
|
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
|
|
|
|
$component
|
|
->call('selectPart', 0)
|
|
->set('detailTab', 'quelle')
|
|
->set('partBody', 'Nach der Freigabe')
|
|
->call('saveSourceText')
|
|
->assertSee('neuen Fassung')
|
|
->call('saveDraft');
|
|
|
|
$this->assertSame(2, $element->fresh()->versions()->count());
|
|
$this->assertSame('Geänderter Wortlaut', $version->fresh()->body);
|
|
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
|
|
$this->assertSame('element:'.$element->versions()->orderByDesc('number')->first()->id, $module->fresh()->working_draft['members'][0]['target']);
|
|
}
|
|
|
|
public function test_a_file_can_be_created_inside_the_module(): void
|
|
{
|
|
Storage::fake('cms_incoming');
|
|
Storage::fake('media_derived');
|
|
Storage::disk('cms_incoming')->put('inhalte/merkblatt.pdf', 'pdfbytes');
|
|
$image = imagecreatetruecolor(8, 8);
|
|
ob_start();
|
|
imagejpeg($image);
|
|
Storage::disk('cms_incoming')->put('vorschau/karte.jpg', (string) ob_get_clean());
|
|
imagedestroy($image);
|
|
$editor = $this->editor();
|
|
$module = app(ContentService::class)->createComposition('Datei im Modul', CompositionKind::Uebung);
|
|
|
|
$component = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker')
|
|
->assertSee('Bestandteil auswählen')
|
|
->assertSee('Neues Medium anlegen')
|
|
->mountAction('createMedium')
|
|
->assertSet('pickerOpen', false)
|
|
->assertMountedActionModalSee('Vorschaubild')
|
|
->fillForm([
|
|
'working_title' => 'Merkblatt',
|
|
'shape' => 'document',
|
|
'description' => 'Für die Gruppe',
|
|
'usage_note' => 'Vorher lesen',
|
|
'incoming' => ['inhalte/merkblatt.pdf'],
|
|
'thumbnail_upload' => ['vorschau/karte.jpg'],
|
|
])
|
|
->assertMountedActionModalSee('Datei wird hochgeladen')
|
|
->callMountedAction()
|
|
->assertSee('Merkblatt');
|
|
|
|
$element = ContentElement::query()->where('working_title', 'Merkblatt')->firstOrFail();
|
|
$version = $element->versions()->sole();
|
|
|
|
$this->assertSame('document', $element->output_class);
|
|
$this->assertSame('Für die Gruppe', $element->description);
|
|
$this->assertSame('Vorher lesen', $element->usage_note);
|
|
$this->assertSame(ContentVersionStatus::Entwurf, $version->status);
|
|
$this->assertSame('eigen', $element->fresh()->thumbnail_source);
|
|
app(ThumbnailDeriver::class)->forElement($element->fresh());
|
|
$this->assertSame('eigen', $element->fresh()->thumbnail_source);
|
|
$this->assertIsString($version->metadata['file'] ?? null);
|
|
Storage::disk('media_derived')->assertExists($version->metadata['file']);
|
|
|
|
// Angaben des Mediums bearbeitet seine eigene Redaktion; der Aufbau verweist nur darauf.
|
|
$component
|
|
->call('saveDraft')
|
|
->set('detailTab', 'quelle')
|
|
->assertSee('Quelle bearbeiten')
|
|
->assertSee(ContentElementResource::getUrl('view', ['record' => $element]), false);
|
|
|
|
$this->assertSame(1, $element->versions()->count());
|
|
|
|
$component->set('releaseConsent', true)->call('publishRevision');
|
|
$this->assertSame(ContentVersionStatus::Bereit, $version->fresh()->status);
|
|
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
|
|
}
|
|
|
|
public function test_release_reviews_the_structure_and_keeps_other_references(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film');
|
|
$guide = $content->draftElementVersion($content->createElement('text', 'text', 'Traineranleitung'), 'Zuerst vorlesen.');
|
|
$soonBlocked = $content->publishElementVersion($content->createElement('text', 'text', 'Alter Hinweis'), 'Alt');
|
|
$other = $content->publishComposition(
|
|
$content->createComposition('Anderes Modul', CompositionKind::Uebung),
|
|
[['role' => 'Film', 'target' => $film]],
|
|
);
|
|
$editor = $this->editor();
|
|
$module = $content->createComposition('Freigabe Modul', CompositionKind::Uebung);
|
|
|
|
$readyOnly = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('addPart', 'element:'.$film->id)
|
|
->call('armRelease')
|
|
->assertSee('Bereits freigegeben')
|
|
->assertSee('Lara im Park')
|
|
->assertSee('bleibt unverändert')
|
|
->assertSee('Keine Bestandteile warten')
|
|
->call('cancelRelease')
|
|
->assertSet('releaseArmed', false);
|
|
|
|
$this->assertSame(0, $module->fresh()->versions()->count());
|
|
|
|
$readyOnly
|
|
->call('armRelease')
|
|
->call('publishRevision')
|
|
->assertSee('Fassung 1 ist freigegeben')
|
|
->call('showAufbauTab', 'verlauf')
|
|
->assertSee('keinen offenen Entwurf')
|
|
->assertSee('In Mitgliederbibliothek anzeigen');
|
|
|
|
$this->assertSame($film->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
|
|
$this->assertSame($film->id, $other->fresh()->members()->first()->content_element_version_id);
|
|
$this->assertSame(1, $film->element->fresh()->versions()->count());
|
|
|
|
$withGuide = $content->createComposition('Mit Anleitung', CompositionKind::Uebung);
|
|
$guideEditor = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $withGuide->id])
|
|
->call('addPart', 'element:'.$guide->id)
|
|
->call('armRelease')
|
|
->assertSee('Traineranleitung')
|
|
->assertSee('Der Entwurf wird freigegeben')
|
|
->call('publishRevision')
|
|
->assertSee('ausdrücklicher Zustimmung');
|
|
|
|
$this->assertSame(ContentVersionStatus::Entwurf, $guide->fresh()->status);
|
|
$this->assertSame(0, $withGuide->fresh()->versions()->count());
|
|
|
|
$guideEditor
|
|
->set('releaseConsent', true)
|
|
->call('publishRevision')
|
|
->assertSee('Fassung 1 ist freigegeben');
|
|
|
|
$this->assertSame(ContentVersionStatus::Bereit, $guide->fresh()->status);
|
|
$this->assertSame($guide->id, $withGuide->fresh()->versions()->first()->members()->first()->content_element_version_id);
|
|
|
|
$child = $content->createComposition('Untermodul', CompositionKind::Uebung);
|
|
$child->working_draft = [
|
|
'learning_goal' => 'Grenze erkennen',
|
|
'duration_minutes' => 8,
|
|
'material_note' => null,
|
|
'revision_note' => null,
|
|
'members' => [['role' => 'Film', 'target' => 'element:'.$film->id, 'note' => '']],
|
|
];
|
|
$child->save();
|
|
$program = $content->createComposition('Freigabe Programm', CompositionKind::Kurs);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditCourse::class, ['record' => $program->id])
|
|
->call('openPicker')
|
|
->assertSee('Untermodul')
|
|
->set('pickerSelected', 'composition-draft:'.$child->id)
|
|
->assertSee('gemeinsame Freigabe')
|
|
->call('addPart', 'composition-draft:'.$child->id)
|
|
->call('armRelease')
|
|
->assertSee('Es entsteht Fassung 1')
|
|
->set('releaseConsent', true)
|
|
->call('publishRevision')
|
|
->assertSee('Fassung 1 ist freigegeben');
|
|
|
|
$childVersion = $child->fresh()->versions()->first();
|
|
$this->assertSame(ContentVersionStatus::Bereit, $childVersion->status);
|
|
$this->assertSame($film->id, $childVersion->members()->first()->content_element_version_id);
|
|
$this->assertSame($childVersion->id, $program->fresh()->versions()->first()->members()->first()->nested_composition_version_id);
|
|
$this->assertSame(1, $other->composition->fresh()->versions()->count());
|
|
$this->assertSame($film->id, $other->fresh()->members()->first()->content_element_version_id);
|
|
|
|
$held = $content->createComposition('Behält den Hinweis', CompositionKind::Uebung);
|
|
$content->publishComposition($held, [['role' => 'Hinweis', 'target' => $soonBlocked]]);
|
|
|
|
$broken = $content->createComposition('Mit Fehler', CompositionKind::Uebung);
|
|
$brokenEditor = Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $broken->id])
|
|
->call('addPart', 'element:'.$soonBlocked->id)
|
|
->call('saveDraft');
|
|
$content->block($soonBlocked, 'Nicht mehr verwenden');
|
|
$brokenEditor
|
|
->call('armRelease')
|
|
->assertSee('deaktiviert')
|
|
->assertSee('content-elements/'.$soonBlocked->content_element_id)
|
|
->call('publishRevision')
|
|
->assertSet('releaseArmed', true);
|
|
|
|
$this->assertSame(0, $broken->fresh()->versions()->count());
|
|
$this->assertSame(ContentVersionStatus::Gesperrt, $soonBlocked->fresh()->status);
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $broken->id])
|
|
->assertSee('Alter Hinweis')
|
|
->assertSee('deaktiviert');
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $held->id])
|
|
->assertSee('Alter Hinweis')
|
|
->assertSee('deaktiviert')
|
|
->set('learningGoal', 'Der Hinweis bleibt sichtbar')
|
|
->call('armRelease')
|
|
->assertSee('Diese Fassung ist deaktiviert')
|
|
->assertSee('content-elements/'.$soonBlocked->content_element_id);
|
|
$this->assertSame(1, $other->composition->fresh()->versions()->count());
|
|
}
|
|
|
|
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();
|
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
return $editor;
|
|
}
|
|
}
|