Mache den Download bei reiner Download-Lizenz erreichbar und zeige den Stand zum Verkaufsstart
CI Feature / test (push) Failing after 3m2s
CI Feature / test (push) Failing after 3m2s
Die Artikelseite zeigte bei einer Lizenz nur zum Herunterladen (kein Streamen oder Ansehen) "Nicht enthalten"; jetzt bietet sie den Download. Tests belegen Einzelfilm und Begleit-PDF aus der Bibliothek mit Dateiname und Zugriffsgrenzen. Neue Verwaltungsseite Verkaufsstart nennt fehlende Rechtstexte und den Zustand der Zahlungseinrichtung, ohne Schlüssel zu zeigen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
76fab81386
commit
42e0a6bb93
6 files changed
+414
No files matched your search
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Startangebote: Ein einzeln gekaufter Film und ein tatsächlich herunterladbares Begleit-PDF sind mit passender
|
||||
* Lizenz aus der Bibliothek erreichbar (Verkaufsstart, Download-Befunde der Etappe 1).
|
||||
*/
|
||||
class LibraryDownloadTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Artikel aus genau einem Medium samt Angebot mit den gewünschten Rechten.
|
||||
*
|
||||
* @param array<string, list<string>> $capabilities
|
||||
* @return array{0: LicenseArticle, 1: Offer}
|
||||
*/
|
||||
private function singleMedium(string $class, string $title, string $file, string $body, array $capabilities): array
|
||||
{
|
||||
Storage::disk('media_derived')->put($file, $body);
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement($class, $class, $title);
|
||||
$element->description = 'Beschreibung '.$title;
|
||||
$element->save();
|
||||
$version = $content->publishElementVersion($element, null, ['file' => $file]);
|
||||
$articles = app(ArticleService::class);
|
||||
$article = $articles->create('einzel-'.$class.'-'.count($capabilities).'-'.md5($title), 'Testkauf');
|
||||
$article->working_title = $title;
|
||||
$article->save();
|
||||
$articles->publishRelease($article, $version, 'Einzelmedium.');
|
||||
|
||||
$offers = app(OfferService::class);
|
||||
$rights = $offers->createRightsProfile('Rechte '.$title, 'ehrenamtlich', $capabilities);
|
||||
$offer = $offers->create('Einzelkauf '.$title);
|
||||
$offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], [
|
||||
'grant_kind' => 'kauf', 'price_cents' => 1200, 'holder_kind' => 'person', 'licence_scope' => 'einzel',
|
||||
]);
|
||||
|
||||
return [$article->fresh(), $offer];
|
||||
}
|
||||
|
||||
private function buy(Offer $offer): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$offer]);
|
||||
app(Checkout::class)->confirmTestPayment($order, 'test-dl-'.$offer->id);
|
||||
}
|
||||
|
||||
public function test_a_single_film_is_in_the_library_and_downloads_with_its_title_as_file_name(): void
|
||||
{
|
||||
[$article, $offer] = $this->singleMedium('film', 'Lara im Park', 'inhalte/einzel/film.mp4', 'FILMINHALT', ['film' => ['streamen', 'laden']]);
|
||||
$this->buy($offer);
|
||||
|
||||
$this->actingAs($this->tina())->get(route('member.library'))->assertOk()->assertSee('Lara im Park')->assertSee(route('member.article', $article), false);
|
||||
$this->get(route('member.article', $article))->assertOk()->assertSee('Herunterladen');
|
||||
$link = $this->downloadUrl($article);
|
||||
$this->assertNotSame('', $link, 'Der Film bietet „Herunterladen“.');
|
||||
|
||||
$download = $this->get($link);
|
||||
$download->assertOk();
|
||||
$this->assertStringContainsString('attachment', (string) $download->headers->get('Content-Disposition'));
|
||||
$this->assertStringContainsString('Lara im Park.mp4', rawurldecode((string) $download->headers->get('Content-Disposition')));
|
||||
$this->assertSame('FILMINHALT', $download->streamedContent());
|
||||
}
|
||||
|
||||
public function test_a_single_film_with_download_only_rights_offers_the_download_and_no_dead_end(): void
|
||||
{
|
||||
[$article, $offer] = $this->singleMedium('film', 'Nur Download', 'inhalte/einzel/nur.mp4', 'NURDOWNLOAD', ['film' => ['laden']]);
|
||||
$this->buy($offer);
|
||||
|
||||
$this->actingAs($this->tina())->get(route('member.article', $article))
|
||||
->assertOk()
|
||||
->assertSee('Herunterladen')
|
||||
->assertDontSee('Nicht enthalten. Für diesen Teil liegt keine Freigabe vor.');
|
||||
}
|
||||
|
||||
public function test_a_companion_pdf_downloads_as_a_real_pdf_with_view_and_download_decided_separately(): void
|
||||
{
|
||||
[$article, $offer] = $this->singleMedium('pdf', 'Begleitmaterial Abstand', 'inhalte/einzel/material.pdf', "%PDF-1.4\n%Abstand\n%%EOF\n", ['pdf' => ['ansehen', 'laden']]);
|
||||
$this->buy($offer);
|
||||
|
||||
$page = $this->actingAs($this->tina())->get(route('member.article', $article))->assertOk()->assertSee('Ansehen')->assertSee('Herunterladen');
|
||||
preg_match_all('/href="([^"]+)"/', $page->getContent(), $links);
|
||||
$download = collect($links[1])->map(fn (string $href): string => html_entity_decode($href))->first(fn (string $href): bool => str_contains($href, '/laden?'));
|
||||
$this->assertNotNull($download, 'Das PDF bietet einen Downloadlink.');
|
||||
|
||||
$response = $this->get($download)->assertOk();
|
||||
$this->assertStringContainsString('attachment', (string) $response->headers->get('Content-Disposition'));
|
||||
$this->assertStringContainsString('Begleitmaterial Abstand.pdf', rawurldecode((string) $response->headers->get('Content-Disposition')));
|
||||
$this->assertStringStartsWith('%PDF-1.4', $response->streamedContent());
|
||||
}
|
||||
|
||||
public function test_a_pdf_without_the_download_right_shows_no_download(): void
|
||||
{
|
||||
[$article, $offer] = $this->singleMedium('pdf', 'Nur ansehen', 'inhalte/einzel/ansehen.pdf', "%PDF-1.4\n%A\n%%EOF\n", ['pdf' => ['ansehen']]);
|
||||
$this->buy($offer);
|
||||
|
||||
$this->actingAs($this->tina())->get(route('member.article', $article))->assertOk()->assertSee('Ansehen')->assertDontSee('Herunterladen');
|
||||
}
|
||||
|
||||
public function test_the_download_needs_payment_and_the_buying_account(): void
|
||||
{
|
||||
[$article, $offer] = $this->singleMedium('film', 'Gesperrt', 'inhalte/einzel/gesperrt.mp4', 'GESPERRT', ['film' => ['streamen', 'laden']]);
|
||||
$order = $this->orderOf($this->tina(), [$offer]);
|
||||
|
||||
$this->actingAs($this->tina())->get(route('member.article', $article))->assertOk()->assertDontSee('Herunterladen');
|
||||
|
||||
app(Checkout::class)->confirmTestPayment($order, 'test-lock');
|
||||
$this->get(route('member.article', $article))->assertSee('Herunterladen');
|
||||
$url = $this->downloadUrl($article);
|
||||
|
||||
auth()->logout();
|
||||
$this->actingAs($this->max())->get($url)->assertForbidden();
|
||||
$this->actingAs($this->max())->get(route('member.article', $article))->assertDontSee('Herunterladen');
|
||||
}
|
||||
|
||||
private function downloadUrl(LicenseArticle $article): string
|
||||
{
|
||||
$page = $this->get(route('member.article', $article));
|
||||
preg_match_all('/href="([^"]+)"/', $page->getContent(), $links);
|
||||
|
||||
return (string) collect($links[1])->map(fn (string $href): string => html_entity_decode($href))->first(fn (string $href): bool => str_contains($href, '/laden?'));
|
||||
}
|
||||
}
|
||||
@@ -281,4 +281,22 @@ public function test_the_offer_page_flags_a_version_without_scope(): void
|
||||
|
||||
$this->assertSame(1, $offer->versions()->count(), 'Ohne Nutzerkreis entsteht keine neue Fassung.');
|
||||
}
|
||||
|
||||
public function test_the_sales_start_page_names_what_is_missing_without_showing_secrets(): void
|
||||
{
|
||||
config(['services.stripe.secret' => 'sk_test_geheim_nicht_zeigen', 'services.stripe.webhook_secret' => 'whsec_geheim']);
|
||||
|
||||
$this->actingAs($this->staff('kundenbetreuung'), 'staff')->get('/verwaltung/verkaufsstart')
|
||||
->assertOk()
|
||||
->assertSee('Allgemeine Geschäftsbedingungen')
|
||||
->assertSee('Widerrufsbelehrung')
|
||||
->assertSee('Fehlt')
|
||||
->assertSee('Produktivfreigabe (SHOP_LIVE_RELEASE): nicht gesetzt')
|
||||
->assertSee('Stripe-Schlüssel: Testmodus')
|
||||
->assertSee('Steuerstatus und Belegangaben sind noch nicht entschieden')
|
||||
->assertDontSee('sk_test_geheim_nicht_zeigen')
|
||||
->assertDontSee('whsec_geheim');
|
||||
|
||||
$this->actingAs($this->staff('redakteur'), 'staff')->get('/verwaltung/verkaufsstart')->assertForbidden();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user