Stelle die Kataloglisten und das Angebot auf die gemeinsamen Muster um.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s

- Lizenzartikel, Pakete, Rechteprofile und Angebote nutzen die gemeinsame
  Bestandsliste (ListsCatalog): Suche, Zustandsfilter, lesbare Zustände aus
  vorhandenen Daten statt „Aktueller Stand: 1“ oder „Fassungen: aktiv“
  (Stand veröffentlicht/in Arbeit/gesperrt, in aktivem Angebot, Fassung aktiv
  mit Vergabe und Preis, Bestandteile, Zweck und Fähigkeiten). Lizenzartikel
  zeigen ihr Titelbild.
- Anlegedialoge benennen Zweck und Bestätigung und öffnen danach den neuen
  Eintrag, statt in der Liste stehen zu bleiben.
- Angebot im gemeinsamen Rahmen (Kopf, Positionen, aufgelöster
  Leistungsumfang, Fassungsverlauf). Eine Maske für Anlegen und Ändern
  (FACH-20): „Fassung aktivieren“ bzw. „Geänderte Fassung aktivieren“, bei einer
  Änderung mit der aktiven Fassung vorbelegt (FACH-08). Wirkung unverändert
  OfferService::activate: die bisherige Fassung wird beendet und bleibt
  gespeichert. „Als Vorlage verwenden“ (FACH-09) bleibt offen (OFF-04).
- Entfernt: editorial/catalog-card (ersetzt).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-20 08:29:28 +01:00
1 parent 532979aa86
commit 660b50f418
10 files changed
+828 -80

No files matched your search

+134
View File
@@ -2,14 +2,25 @@
namespace Tests\Feature;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\BundleService;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferService;
use App\Filament\Pages\EditorialDesk;
use App\Filament\Resources\Bundles\Pages\ListBundles;
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
use App\Filament\Resources\Courses\Pages\ListCourses;
use App\Filament\Resources\Exercises\ExerciseResource;
use App\Filament\Resources\Exercises\Pages\ListExercises;
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
use App\Filament\Resources\Offers\OfferResource;
use App\Filament\Resources\Offers\Pages\ListOffers;
use App\Filament\Resources\Offers\Pages\ViewOffer;
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
use App\Filament\Support\Bestand;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -140,6 +151,129 @@ public function test_only_editors_reach_the_composition_lists(): void
$this->actingAs($keeper, 'staff')->get(EditorialDesk::getUrl())->assertForbidden();
}
public function test_catalog_lists_show_readable_states_and_filter_them(): void
{
$content = app(ContentService::class);
$articles = app(ArticleService::class);
$offers = app(OfferService::class);
$sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Merkblatt Alltag'), 'Hinweis');
$released = $articles->create('demo-merkblatt', 'Erprobung');
$articles->publishRelease($released, $sheet, 'Eigenständiges Merkblatt.');
$articles->create('demo-leer', 'Erprobung');
$bundle = app(BundleService::class)->create('Demo Basis');
app(BundleService::class)->publish($bundle, [$released->fresh()]);
$rights = $offers->createRightsProfile('Erprobung lesen', 'ehrenamtlich', ['pdf' => ['ansehen', 'laden']]);
$offer = $offers->create('Kostenloses Merkblatt');
$offers->activate($offer, [['target' => $released->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
$offers->create('Noch leer');
$keeper = $this->keeper();
Livewire::actingAs($keeper, 'staff')
->test(ListLicenseArticles::class)
->assertSee('demo-merkblatt')
->assertSee('Stand 1 veröffentlicht')
->assertSee('In einem aktiven Angebot')
->assertSee('Noch kein Stand')
->assertSeeHtml('wire:partial="action-modals"')
->set('zustand', 'ohne')
->assertSee('Zustand: Noch ohne Stand')
->assertSee('demo-leer')
->assertDontSee('demo-merkblatt')
->set('suche', 'merkblatt')
->assertSee('Nichts gefunden');
Livewire::actingAs($keeper, 'staff')
->test(ListOffers::class)
->assertSee('Fassung 1 aktiv')
->assertSee('Auf Abruf')
->assertSee('Lizenzartikel demo-merkblatt · Erprobung lesen')
->assertSee('Keine aktive Fassung')
->assertDontSee('>aktiv<', false);
Livewire::actingAs($keeper, 'staff')
->test(ListBundles::class)
->assertSee('Demo Basis')
->assertSee('Fassung 1 veröffentlicht')
->assertSee('1 Bestandteil');
Livewire::actingAs($keeper, 'staff')
->test(ListRightsProfiles::class)
->assertSee('Erprobung lesen')
->assertSee('PDF ansehen, PDF herunterladen')
->assertSee('Ehrenamtlich');
}
public function test_creating_a_catalog_object_opens_it_and_editors_without_the_keeper_role_stay_out(): void
{
$keeper = $this->keeper();
Livewire::actingAs($keeper, 'staff')
->test(ListLicenseArticles::class)
->callAction('create', ['code' => 'neuer-artikel', 'product_line' => 'Erprobung'])
->assertRedirect(LicenseArticleResource::getUrl('view', ['record' => LicenseArticle::query()->where('code', 'neuer-artikel')->firstOrFail()]));
Livewire::actingAs($keeper, 'staff')
->test(ListOffers::class)
->callAction('create', ['name' => 'Neues Angebot'])
->assertRedirectContains('/verwaltung/offers/');
$this->actingAs($this->editor(), 'staff')->get(OfferResource::getUrl('index'))->assertForbidden();
$this->actingAs($this->editor(), 'staff')->get(LicenseArticleResource::getUrl('index'))->assertForbidden();
}
public function test_one_offer_mask_activates_the_first_version_and_is_prefilled_for_a_change(): void
{
$content = app(ContentService::class);
$articles = app(ArticleService::class);
$offers = app(OfferService::class);
$sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Merkblatt'), 'Hinweis');
$article = $articles->create('demo-merkblatt', 'Erprobung');
$articles->publishRelease($article, $sheet, 'Eigenständig.');
$rights = $offers->createRightsProfile('Lesen', 'ehrenamtlich', ['pdf' => ['ansehen']]);
$offer = $offers->create('Merkblatt kostenlos');
$keeper = $this->keeper();
$component = Livewire::actingAs($keeper, 'staff')
->test(ViewOffer::class, ['record' => $offer->getKey()])
->assertSee('Noch keine aktive Fassung')
->assertSee('Fassung aktivieren')
->mountAction('activate');
$this->assertSame('Erste Fassung aktivieren', $component->instance()->getMountedAction()->getModalHeading());
$component
->fillForm(['grant_kind' => 'auf_abruf', 'lines' => [['kind' => 'article', 'article_id' => $article->id, 'rights_id' => $rights->id]]])
->callMountedAction()
->assertHasNoFormErrors()
->assertSee('Fassung 1 aktiv · Auf Abruf')
->assertSee('Lizenzartikel demo-merkblatt');
$component = Livewire::actingAs($keeper, 'staff')
->test(ViewOffer::class, ['record' => $offer->getKey()])
->assertSee('Geänderte Fassung aktivieren')
->mountAction('activate');
$this->assertSame('Angebot ändern: Fassung 2 aktivieren', $component->instance()->getMountedAction()->getModalHeading());
$data = $component->get('mountedActions.0.data');
$this->assertSame('auf_abruf', $data['grant_kind']);
$this->assertSame((string) $article->id, (string) array_values($data['lines'])[0]['article_id']);
$this->assertSame((string) $rights->id, (string) array_values($data['lines'])[0]['rights_id']);
$component->fillForm(['grant_kind' => 'kauf', 'price_cents' => 500])
->callMountedAction()
->assertHasNoFormErrors()
->assertSee('Fassung 2 aktiv · Kauf · 5,00 €')
->assertSee('Beendet');
$statuses = $offer->versions()->orderBy('number')->pluck('status')->map(fn ($status) => $status instanceof \BackedEnum ? $status->value : $status)->all();
$this->assertSame(['beendet', 'aktiv'], $statuses);
}
private function keeper(): User
{
$keeper = User::factory()->katalogverwalter()->create();
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $keeper;
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();