Add feature tests for shop functionality and organization purchases
- Implement OfferOptionAdminTest to validate offer option management, including price display, activation, and cancellation. - Create OrganizationPurchaseTest to ensure correct handling of organization purchases, including access control and order processing. - Add ShopProductPageTest to verify shop product listings, search functionality, and product page details. - Introduce BuildsShop trait for seeding test data related to shop functionality. - Implement MoneyTest to validate money parsing and formatting, ensuring correct handling of euro amounts.
This commit is contained in:
1 parent
6c8bbee363
commit
4e0760db1e
106 files changed
+4068
-76
No files matched your search
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Etappe 1, Shop-Abnahme: „Kachel oder Shop-Suche öffnen: dieselbe Angebotsseite mit fachlichem Umfang, Bestandteilen
|
||||
* und kaufbaren Optionen“ sowie der Schutz vor Produktivbetrieb.
|
||||
*/
|
||||
class ShopProductPageTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
public function test_the_shop_lists_products_with_the_lowest_price_and_opens_the_product_page(): void
|
||||
{
|
||||
$page = $this->get(route('shop'))->assertOk();
|
||||
$page->assertSee('Konflikte im Training')
|
||||
->assertSee('Grenzen setzen im Verein')
|
||||
->assertSee('ab 49,00 €')
|
||||
->assertSee('2 Lizenzoptionen')
|
||||
->assertSee('ab 29,00 €')
|
||||
->assertSee('3 Produkte');
|
||||
$page->assertSee(route('public.program', $this->program('Konflikte im Training')), false);
|
||||
}
|
||||
|
||||
public function test_the_shop_search_filters_and_shows_an_empty_state(): void
|
||||
{
|
||||
$this->get(route('shop', ['suche' => 'Grenzen']))
|
||||
->assertOk()
|
||||
->assertSee('Grenzen setzen im Verein')
|
||||
->assertDontSee('Konflikte im Training')
|
||||
->assertSee('1 Produkt');
|
||||
|
||||
$this->get(route('shop', ['suche' => 'gibt-es-nicht']))
|
||||
->assertOk()
|
||||
->assertSee('Keine Treffer')
|
||||
->assertSee('Suche zurücksetzen');
|
||||
}
|
||||
|
||||
public function test_the_product_page_shows_content_and_options_with_price_rights_and_term(): void
|
||||
{
|
||||
$response = $this->get(route('public.program', $this->program('Konflikte im Training')))->assertOk();
|
||||
|
||||
$response->assertSee('Konflikte erkennen, benennen und gemeinsam lösen.')
|
||||
->assertSee('Film: Film Konflikte im Training')
|
||||
->assertSee('Lizenzoptionen')
|
||||
->assertSee('Privatlizenz')
|
||||
->assertSee('49,00 €')
|
||||
->assertSee('Privatpersonen')
|
||||
->assertSee('Dauerhaft nutzbar')
|
||||
->assertSee('Ehrenamtlich: Film ansehen, Film herunterladen, PDF ansehen, PDF herunterladen')
|
||||
->assertSee('Mehrfachlizenz für Vereine')
|
||||
->assertSee('149,00 €')
|
||||
->assertSee('Organisationen und Vereine')
|
||||
->assertSee('Institutionell: Film ansehen, Film herunterladen, PDF ansehen, PDF herunterladen')
|
||||
->assertSee('Konflikte im Training', false);
|
||||
// Die zugrunde liegende Artikel erscheint mit Titel, nicht mit der Kennung.
|
||||
$response->assertDontSee('shop-konflikte');
|
||||
}
|
||||
|
||||
public function test_a_withdrawn_option_disappears_while_the_other_options_stay_purchasable(): void
|
||||
{
|
||||
app(OfferService::class)->end($this->privateKonflikte());
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
->assertOk()
|
||||
->assertDontSee('Privatlizenz')
|
||||
->assertSee('Mehrfachlizenz für Vereine')
|
||||
->assertSee('149,00 €');
|
||||
}
|
||||
|
||||
public function test_free_and_unpriced_offers_are_not_shown_as_purchasable(): void
|
||||
{
|
||||
$free = app(OfferService::class)->create('Kostenloses Merkblatt');
|
||||
$article = $this->article('shop-konflikte');
|
||||
$rights = app(OfferService::class)->createRightsProfile('Frei', 'ehrenamtlich', ['pdf' => ['ansehen']]);
|
||||
app(OfferService::class)->activate($free, [['target' => $article, 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
app(OfferService::class)->assignProduct($free, $this->program('Konflikte im Training')->id, 'Kostenlos testen');
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
->assertOk()
|
||||
->assertDontSee('Kostenlos testen');
|
||||
}
|
||||
|
||||
public function test_the_shop_exists_only_with_test_payment_and_never_in_production(): void
|
||||
{
|
||||
$this->assertTrue(Shop::enabled());
|
||||
|
||||
config(['services.payment.driver' => 'stripe']);
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
$this->get(route('cart'))->assertNotFound();
|
||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
->assertOk()
|
||||
->assertDontSee('Lizenzoptionen')
|
||||
->assertDontSee('In den Warenkorb');
|
||||
|
||||
config(['services.payment.driver' => 'test']);
|
||||
$this->app['env'] = 'production';
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_an_option_without_a_product_page_is_not_listed_in_the_shop(): void
|
||||
{
|
||||
$this->privateGrenzen()->update(['composition_id' => null]);
|
||||
|
||||
$this->get(route('shop'))
|
||||
->assertOk()
|
||||
->assertDontSee('Grenzen setzen im Verein')
|
||||
->assertSee('Konflikte im Training');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user