Führe Artikel, Paket und Angebot mit sichtbaren Voraussetzungen bis zum kaufbaren Angebot
CI Feature / test (push) Successful in 1m42s
CI Feature / test (push) Successful in 1m42s
Abnahmebefund Etappe 1: Nach dem Anlegen mit einem Namen fand die Verwaltung keinen Weg, Inhalte festzulegen und Artikel, Paket, Preis und Rechte zu einem kaufbaren Angebot zu verbinden. - Gemeinsamer Baustein „Bis zur Veröffentlichung“ (PublicationReadiness, voraussetzungen.blade) auf Lizenzartikel, Paket und Angebot: erledigte und offene Schritte mit Weg dorthin, Zustand als Text und Symbol. - Artikel: „Inhalt festlegen“ als Hauptaktion im Kopf statt nur im Menü; Dialog mit „Freigegebener Inhalt“ statt „Wurzel“, Einordnung beim ersten Stand vorbelegt. - Auswahllisten zeigen Name, Kennung und Stand; Artikel ohne Stand sind gekennzeichnet, Produktseiten nennen die Auffindbarkeit im Shop, Paketfassungen ihre Artikel. - Angebotsaktivierung lehnt Artikel ohne veröffentlichten Stand (auch in Paketen) mit Erklärung ab. Die Domänenregel in OfferService bleibt unverändert; das ist eine Oberflächenabsicherung und bei Bedarf eine fachliche Entscheidung. - Erfolgsmeldungen nennen den nächsten Schritt. Bestandstest geändert: OrganizationPurchaseTest::test_membership_boundaries_decide_the_club_access setzte die Uhrzeit erst nach der Bestellung auf 12:00 Uhr und scheiterte dadurch nach 12:00 UTC. Die feste Uhrzeit gilt jetzt vor der Bestellung; die Assertions bleiben unverändert. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e0760db1e
commit
f72b79fd8c
11 files changed
+677
-15
No files matched your search
@@ -114,12 +114,13 @@ public function test_a_second_ordering_member_of_the_same_club_gets_nothing_from
|
||||
|
||||
public function test_membership_boundaries_decide_the_club_access(): void
|
||||
{
|
||||
// Feste Uhrzeit vor der Bestellung, damit die Berechtigung nicht erst nach dem Testzeitpunkt beginnt.
|
||||
$this->travelTo(now()->startOfDay()->addHours(12));
|
||||
$vera = $this->vera();
|
||||
app(Checkout::class)->confirmTestPayment($this->orderOf($vera, [$this->clubKonflikte()]), 'test-verein');
|
||||
[$article, $release, $film] = $this->parts();
|
||||
$membership = fn () => Membership::query()->where(['user_id' => $vera->id, 'party_id' => $this->club()->id]);
|
||||
$allowed = fn (): bool => app(DecideAccess::class)($vera, $article, $release, $film, 'laden')->allowed;
|
||||
$this->travelTo(now()->startOfDay()->addHours(12));
|
||||
|
||||
$membership()->update(['valid_until' => today()]);
|
||||
$this->assertTrue($allowed(), 'Der letzte Tag gilt noch.');
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Filament\Resources\Bundles\Pages\ViewBundle;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Etappe 1, Nachbesserung der Shop-Verwaltung: Aus „Name angelegt“ führt die Oberfläche bis zum kaufbaren Angebot.
|
||||
* Geprüft werden die gemeinsame Anzeige der Voraussetzungen (Artikel, Paket, Angebot), der verständliche Dialog für den
|
||||
* ersten Artikelstand, die gekennzeichnete Auswahl und die Absicherung gegen Artikel ohne Inhalt.
|
||||
*/
|
||||
class ShopVerwaltungAbnahmeTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
public function test_an_article_without_stand_names_the_next_step_and_offers_the_content_as_main_action(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-ohne-stand');
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->assertSee('Bis zur Veröffentlichung')
|
||||
->assertSeeText('Nächster Schritt:')
|
||||
->assertSee('Inhalt festlegen')
|
||||
->assertSee('Der Artikel lizenziert noch nichts');
|
||||
|
||||
$this->assertStringContainsString('wire:click="mountAction('release')"', $component->html());
|
||||
$this->assertStringContainsString('vw-btn is-primary', (string) preg_replace('/\s+/', ' ', explode('Weitere Aktionen', $component->html())[0]), 'Der Einstieg steht als Hauptaktion im Kopf, nicht nur im Menü.');
|
||||
}
|
||||
|
||||
public function test_the_first_stand_dialog_is_plain_prefilled_and_publishes(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-erster-stand');
|
||||
$root = 'composition:'.$this->article('shop-grenzen')->currentRelease->root_composition_version_id;
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->mountAction('release');
|
||||
$action = $component->instance()->getMountedAction();
|
||||
|
||||
$this->assertSame('Inhalt festlegen: ersten Stand veröffentlichen', $action->getModalHeading());
|
||||
$this->assertSame('Stand veröffentlichen', $action->getModalSubmitActionLabel());
|
||||
$page = $component->instance();
|
||||
$schema = (new \ReflectionMethod($page, 'getMountedActionSchema'))->invoke($page);
|
||||
$labels = collect($schema->getFlatComponents())
|
||||
->map(fn ($field): ?string => method_exists($field, 'getLabel') ? (string) $field->getLabel() : null)
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
$this->assertContains('Freigegebener Inhalt', $labels);
|
||||
$this->assertNotContains('Wurzel', $labels);
|
||||
$this->assertSame('Erster Stand dieses Lizenzartikels.', $component->get('mountedActions.0.data.classification'));
|
||||
|
||||
$component->fillForm(['root' => $root])->callMountedAction()->assertHasNoActionErrors();
|
||||
|
||||
$article->refresh();
|
||||
$this->assertNotNull($article->current_release_id);
|
||||
$this->assertSame('Erster Stand dieses Lizenzartikels.', $article->currentRelease->classification_note);
|
||||
$this->assertTrue(app(PublicationReadiness::class)->forArticle($article)['schritte'][0]['stand'] === 'erledigt');
|
||||
}
|
||||
|
||||
public function test_a_later_stand_still_asks_for_the_classification(): void
|
||||
{
|
||||
$article = $this->article('shop-grenzen');
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->mountAction('release');
|
||||
|
||||
$this->assertSame('Neuen Stand veröffentlichen', $component->instance()->getMountedAction()->getModalHeading());
|
||||
$component->fillForm(['root' => 'composition:'.$article->currentRelease->root_composition_version_id, 'classification' => ''])
|
||||
->callMountedAction()
|
||||
->assertHasActionErrors(['classification' => 'required']);
|
||||
}
|
||||
|
||||
public function test_pickers_name_articles_with_title_and_stand_and_mark_those_without_content(): void
|
||||
{
|
||||
app(ArticleService::class)->create('leer-ohne-stand');
|
||||
$options = app(PublicationReadiness::class)->articleOptions();
|
||||
|
||||
$leer = collect($options)->first(fn (string $label): bool => str_contains($label, 'leer-ohne-stand'));
|
||||
$this->assertSame('leer-ohne-stand · noch ohne Stand, nicht verwendbar', $leer);
|
||||
$this->assertStringContainsString('· Stand 1', (string) collect($options)->first(fn (string $label): bool => str_contains($label, 'shop-konflikte')));
|
||||
$this->assertStringContainsString('shop-konflikte', implode(' ', app(PublicationReadiness::class)->bundleVersionOptions()));
|
||||
}
|
||||
|
||||
public function test_an_offer_for_an_article_without_stand_cannot_be_activated(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('angebot-ohne-stand');
|
||||
$offer = app(OfferService::class)->create('Angebot ohne Inhalt');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||
->mountAction('activate')
|
||||
->fillForm([
|
||||
'holder_kind' => 'person',
|
||||
'grant_kind' => 'kauf',
|
||||
'price_euro' => '19,00',
|
||||
'lines' => [['kind' => 'article', 'article_id' => $article->id, 'rights_id' => $this->rights()->id]],
|
||||
])
|
||||
->callMountedAction()
|
||||
->assertNotified('Der Lizenzartikel „angebot-ohne-stand“ (angebot-ohne-stand) hat noch keinen veröffentlichten Stand und vergibt keine Inhalte. Lege zuerst am Artikel mit „Inhalt festlegen“ den Inhalt fest, bevor du das Angebot aktivierst.');
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count(), 'Es entsteht keine Angebotsfassung.');
|
||||
}
|
||||
|
||||
public function test_an_offer_for_a_bundle_with_an_article_without_stand_cannot_be_activated(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('paket-ohne-stand');
|
||||
$bundle = app(BundleService::class)->create('Paket mit leerem Artikel');
|
||||
$version = app(BundleService::class)->publish($bundle, [$article, $this->article('shop-konflikte')]);
|
||||
$offer = app(OfferService::class)->create('Paketangebot ohne Inhalt');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||
->mountAction('activate')
|
||||
->fillForm([
|
||||
'holder_kind' => 'person',
|
||||
'grant_kind' => 'kauf',
|
||||
'price_euro' => '19,00',
|
||||
'lines' => [['kind' => 'bundle', 'bundle_version_id' => $version->id, 'rights_id' => $this->rights()->id]],
|
||||
])
|
||||
->callMountedAction();
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
|
||||
$check = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
$this->assertFalse($check['bereit']);
|
||||
$this->assertSame('Jeder enthaltene Artikel hat einen Inhalt', $check['naechster']['titel']);
|
||||
$this->assertStringContainsString('paket-ohne-stand', $check['naechster']['text']);
|
||||
}
|
||||
|
||||
public function test_the_offer_page_walks_from_empty_to_findable_in_the_shop(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Neues Angebot');
|
||||
$readiness = app(PublicationReadiness::class);
|
||||
$page = fn () => Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||
|
||||
$page()->assertSee('Bis zur Veröffentlichung')->assertSeeText('Nächster Schritt: Artikel oder Paket, Rechte, Preis und Vergabe festlegen');
|
||||
$this->assertFalse($readiness->forOffer($offer->refresh())['bereit']);
|
||||
|
||||
// Aktiv, aber ohne Produktseite: nicht im Shop.
|
||||
app(OfferService::class)->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$page()->assertSeeText('Nächster Schritt: Produktseite zuordnen');
|
||||
$this->assertSame('Produktseite zuordnen', $readiness->forOffer($offer->refresh())['naechster']['titel']);
|
||||
|
||||
// Zugeordnet, aber Programm ohne Anzeigefreigabe: nicht auffindbar.
|
||||
$hidden = $this->hiddenProgram();
|
||||
app(OfferService::class)->assignProduct($offer, $hidden->id, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertSame('Produktseite öffentlich', $check['naechster']['titel']);
|
||||
$this->get('/shop')->assertOk()->assertDontSee('Testoption');
|
||||
|
||||
// Öffentliche Produktseite: bereit und im Shop.
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Konflikte im Training')->id, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertTrue($check['bereit']);
|
||||
$page()->assertSeeText('Alle Voraussetzungen sind erfüllt.');
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training'), false))->assertOk()->assertSee('Testoption')->assertSee('39,00');
|
||||
}
|
||||
|
||||
public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundle(): void
|
||||
{
|
||||
$bundle = app(BundleService::class)->create('Frisches Paket');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewBundle::class, ['record' => $bundle->getKey()])
|
||||
->assertSee('Bis zur Veröffentlichung')
|
||||
->assertSeeText('Nächster Schritt: Bestandteile festlegen');
|
||||
|
||||
app(BundleService::class)->publish($bundle, [$this->article('shop-konflikte'), $this->article('shop-grenzen')]);
|
||||
$check = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
$this->assertTrue($check['bereit'], 'Pflichtschritte erfüllt; das Angebot ist eine Empfehlung.');
|
||||
$this->assertSame('offen', $check['schritte'][2]['stand']);
|
||||
$this->assertFalse($check['schritte'][2]['pflicht']);
|
||||
}
|
||||
|
||||
public function test_the_bundle_offer_lists_the_scope_and_is_found_in_the_shop(): void
|
||||
{
|
||||
$starter = $this->program('Starterpaket für neue Trainer');
|
||||
$this->get('/shop')->assertOk()->assertSee('Starterpaket für neue Trainer');
|
||||
$this->get(route('public.program', $starter, false))->assertOk()->assertSee('Starterpaket (zwei Programme und Einführung)')->assertSee('59,00');
|
||||
}
|
||||
|
||||
private function rights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
|
||||
}
|
||||
|
||||
private function hiddenProgram(): Composition
|
||||
{
|
||||
$composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->save();
|
||||
|
||||
return $composition;
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user