Mache den Aufbau von Modulen und Programmen im Arbeitsplatz bedienbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
30833f62a1
commit
a7feef2cd2
15 files changed
+2068
-328
No files matched your search
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Pages\EditorialDesk;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
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')
|
||||
->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', 'Die neue Fassung ist übernommen. Die bisherige Fassung bleibt erhalten.');
|
||||
|
||||
$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);
|
||||
|
||||
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')
|
||||
->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_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();
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user