Halte ungenutzte Medien bearbeitbar und lege Dateien direkt im Modul an.
Deploy Test / test (push) Successful in 26s
Deploy Test / deploy (push) Successful in 30s

Eine Fassung wird erst unveränderlich, wenn sie freigegeben und verwendet wird. Das Auge am Listeneintrag öffnet die Vorschau.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-17 10:34:42 +01:00
1 parent 1fb48783bf
commit c73207f2c3
11 files changed
+547 -25

No files matched your search

+75
View File
@@ -5,10 +5,12 @@
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\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;
@@ -16,6 +18,7 @@
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use Tests\TestCase;
@@ -553,6 +556,78 @@ public function test_a_placement_note_waits_for_release_and_keeps_the_old_versio
$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('Vorschau: Hinweis')
->assertSee('das Auge öffnet eine Vorschau')
->assertDontSee('Das Stiftsymbol öffnet die Bearbeitung')
->call('openPart', 0)
->assertSee('dieselbe Fassung fort')
->set('partBody', 'Geänderter Wortlaut')
->call('savePart')
->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->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('openPart', 0)
->set('partBody', 'Nach der Freigabe')
->call('savePart')
->assertSee('neuen Fassung');
$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');
$editor = $this->editor();
$module = app(ContentService::class)->createComposition('Datei im Modul', CompositionKind::Uebung);
Livewire::actingAs($editor, 'staff')
->test(EditExercise::class, ['record' => $module->id])
->set('newFileTitle', 'Merkblatt')
->set('incomingFile', UploadedFile::fake()->create('merkblatt.pdf', 12, 'application/pdf'))
->call('addFile')
->assertSee('Merkblatt')
->call('publishRevision');
$element = ContentElement::query()->where('working_title', 'Merkblatt')->firstOrFail();
$version = $element->versions()->sole();
$this->assertSame('document', $element->output_class);
$this->assertSame(ContentVersionStatus::Bereit, $version->status);
$this->assertIsString($version->metadata['file'] ?? null);
Storage::disk('media_derived')->assertExists($version->metadata['file']);
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
}
private function filmWithPicture(ContentService $content, string $title): ContentElementVersion
{
$element = $content->createElement('film', 'film', $title);