Texte, Medienzuordnung und Einordnung teilen sich einen Arbeitsplatz. Fassungen, Rechte und das Datenmodell bleiben unverändert.
122 lines
4.7 KiB
PHP
122 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
|
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 VerwaltungArbeitsplatzTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
|
}
|
|
|
|
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)
|
|
->assertSet('partOpen', false)
|
|
->assertSet('roleDraft', 'Einstieg')
|
|
->assertSet('learningGoal', 'Grenze erkennen')
|
|
->set('teaser', 'Kurzer Teaser im Manager')
|
|
->call('closeRedaktion')
|
|
->assertSet('redaktionOpen', false)
|
|
->assertSet('teaser', 'Kurzer Teaser im Manager')
|
|
->assertSet('roleDraft', 'Einstieg')
|
|
->assertSet('learningGoal', 'Grenze erkennen')
|
|
->call('saveRedaktion')
|
|
->assertSee('Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.');
|
|
|
|
$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_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')
|
|
->call('openRedaktion')
|
|
->assertSee('Zurück zur Medienbearbeitung')
|
|
->set('teaser', 'Neuer Teaser')
|
|
->call('closeRedaktion')
|
|
->assertSet('redaktionOpen', false)
|
|
->assertSet('bereich', 'inhalt')
|
|
->assertSet('bodyDraft', 'Offener Lehrtext')
|
|
->assertSet('teaser', 'Neuer Teaser');
|
|
|
|
$this->assertNull($film->fresh()->teaser);
|
|
}
|
|
|
|
public function test_picker_mark_survives_search_and_cancel_does_not_apply_it(): void
|
|
{
|
|
$content = app(ContentService::class);
|
|
$module = $content->createComposition('Picker', CompositionKind::Uebung);
|
|
$editor = $this->editor();
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(EditExercise::class, ['record' => $module->id])
|
|
->call('openPicker')
|
|
->set('pickerSelected', 'element:9')
|
|
->set('pickerQuery', 'nichts-davon')
|
|
->assertSet('pickerSelected', 'element:9')
|
|
->call('closePicker')
|
|
->assertSet('pickerOpen', false)
|
|
->assertSet('pickerSelected', '');
|
|
|
|
$film = $content->createElement('film', 'film', 'Lara im Park');
|
|
$content->publishElementVersion($film, 'Filmfassung');
|
|
|
|
Livewire::actingAs($editor, 'staff')
|
|
->test(ViewContentElement::class, ['record' => $film->getKey()])
|
|
->set('presentationPick', 'medium:4')
|
|
->set('presentationQuery', 'andere-suche')
|
|
->assertSet('presentationPick', 'medium:4')
|
|
->call('cancelPresentationPick')
|
|
->assertSet('presentationPick', '')
|
|
->assertSee('Die vorhandene Zuordnung bleibt unverändert.');
|
|
}
|
|
|
|
private function editor(): User
|
|
{
|
|
$editor = User::factory()->redakteur()->create();
|
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
|
|
return $editor;
|
|
}
|
|
}
|