seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); // WHEN $response = $this->get('/'); // THEN $response->assertOk(); }); it('displays star products, slides and ranges', function () { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); $range = new Range(); $range->name = 'Boucherie'; $range->slug = 'boucherie'; $range->picture = 'ranges/boucherie.jpg'; $range->picture_alt = 'Boucherie'; $range->picture_title = 'Boucherie'; $range->status = true; $range->order = 1; $range->save(); $slide = new Slide(); $slide->title = 'Super Promo'; $slide->status = true; $slide->order = 1; $slide->connected = false; $slide->link = 'https://example.com'; $slide->date_start = Carbon::yesterday(); $slide->date_end = Carbon::tomorrow(); $slide->save(); $product = new Product(); $product->id = (string) Uuid::uuid7(); $product->name = 'Poulet Fermier'; $product->brand = ProductBrand::loue; $product->slug = 'poulet-fermier'; $product->description = 'Délicieux poulet fermier'; $product->picture_alt = 'Poulet Fermier'; $product->picture_title = 'Poulet Fermier'; $product->picture_large_alt = 'Poulet Fermier'; $product->picture_large_title = 'Poulet Fermier'; $product->price = Money::EUR(1500); $product->invoicing_unit = InvoicingUnit::KGM; $product->sell_unit = SellUnit::KGM; $product->tax_rate = TaxRate::TVA_5_5; $product->stock = 10; $product->range_id = $range->id; $product->order = 1; $product->star = true; $product->status = true; $product->save(); // WHEN $response = $this->get('/'); // THEN $response->assertOk(); $response->assertSee('id="hero-carousel"', false); $response->assertSee('Poulet Fermier'); $response->assertSee('Super Promo'); $response->assertSee('Boucherie'); }); it('does not display slider section when no slides are published', function () { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); $expiredSlide = new Slide(); $expiredSlide->title = 'Expired Promo'; $expiredSlide->status = true; $expiredSlide->order = 1; $expiredSlide->connected = false; $expiredSlide->link = 'https://example.com'; $expiredSlide->date_start = Carbon::now()->subDays(5); $expiredSlide->date_end = Carbon::now()->subDays(2); $expiredSlide->save(); // WHEN $response = $this->get('/'); // THEN $response->assertOk(); $response->assertDontSee('id="hero-carousel"', false); $response->assertDontSee('Expired Promo'); }); it('displays promo prices in red for discounted star products on homepage', function () { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached() ->mapWithKeys(fn ($page) => [ $page->slug->value() => $page, ])); $range = new Range(); $range->name = 'Boucherie'; $range->slug = 'boucherie'; $range->picture = 'ranges/boucherie.jpg'; $range->picture_alt = 'Boucherie'; $range->picture_title = 'Boucherie'; $range->status = true; $range->order = 1; $range->save(); $discount = new Discount(); $discount->type = DiscountType::PERCENT; $discount->value = DiscountValue::fromPercentage(10); $discount->is_old_price_displayed = false; $discount->date_start = Carbon::yesterday(); $discount->date_end = Carbon::tomorrow(); $discount->save(); $promoProduct = new Product(); $promoProduct->id = (string) Uuid::uuid7(); $promoProduct->name = 'Foie Gras Promo'; $promoProduct->brand = ProductBrand::loue; $promoProduct->slug = 'foie-gras-promo'; $promoProduct->description = 'Foie Gras en promo'; $promoProduct->picture_alt = 'Foie Gras Promo'; $promoProduct->picture_title = 'Foie Gras Promo'; $promoProduct->picture_large_alt = 'Foie Gras Promo'; $promoProduct->picture_large_title = 'Foie Gras Promo'; $promoProduct->price = Money::EUR(2000); $promoProduct->invoicing_unit = InvoicingUnit::PCE; $promoProduct->sell_unit = SellUnit::PCE; $promoProduct->tax_rate = TaxRate::TVA_5_5; $promoProduct->stock = 10; $promoProduct->range_id = $range->id; $promoProduct->order = 1; $promoProduct->star = true; $promoProduct->status = true; $promoProduct->discount_id = $discount->id; $promoProduct->save(); $regularProduct = new Product(); $regularProduct->id = (string) Uuid::uuid7(); $regularProduct->name = 'Poulet Standard'; $regularProduct->brand = ProductBrand::loue; $regularProduct->slug = 'poulet-standard'; $regularProduct->description = 'Poulet standard sans promo'; $regularProduct->picture_alt = 'Poulet Standard'; $regularProduct->picture_title = 'Poulet Standard'; $regularProduct->picture_large_alt = 'Poulet Standard'; $regularProduct->picture_large_title = 'Poulet Standard'; $regularProduct->price = Money::EUR(1500); $regularProduct->invoicing_unit = InvoicingUnit::PCE; $regularProduct->sell_unit = SellUnit::PCE; $regularProduct->tax_rate = TaxRate::TVA_5_5; $regularProduct->stock = 10; $regularProduct->range_id = $range->id; $regularProduct->order = 2; $regularProduct->star = true; $regularProduct->status = true; $regularProduct->discount_id = null; $regularProduct->save(); // WHEN $response = $this->get('/'); // THEN $response->assertOk(); $content = $response->getContent(); expect($content)->toContain('Foie Gras Promo') ->and($content)->toContain('Poulet Standard'); // Promo product price span has text-danger class expect($content)->toMatch('/Foie Gras Promo.*?/s') // Regular product price span does NOT have text-danger class ->and($content)->toMatch('/Poulet Standard.*?/s'); }); it('escapes decoded HTML payloads in featured product slider description', function (): void { /** @var \Tests\TestCase $this */ // GIVEN $this->seed(ContentSeeder::class); View::share('PageList', Page::getCached()->mapWithKeys(fn ($page) => [$page->slug->value() => $page])); $range = new Range(); $range->name = 'Volaille'; $range->slug = 'volaille'; $range->picture = 'ranges/volaille.jpg'; $range->picture_alt = 'Volaille'; $range->picture_title = 'Volaille'; $range->status = true; $range->order = 1; $range->save(); $product = new Product(); $product->id = (string) Uuid::uuid7(); $product->name = 'Poulet Sûr'; $product->brand = ProductBrand::loue; $product->slug = 'poulet-sur'; $product->description = '

Rôti <img src=x onerror=alert(1)>

'; $product->picture_alt = 'alt'; $product->picture_title = 'title'; $product->picture_large_alt = 'alt'; $product->picture_large_title = 'title'; $product->price = Money::EUR(1500); $product->invoicing_unit = InvoicingUnit::PCE; $product->sell_unit = SellUnit::PCE; $product->tax_rate = TaxRate::TVA_5_5; $product->stock = 10; $product->range_id = $range->id; $product->order = 1; $product->star = true; $product->status = true; $product->save(); // WHEN $response = $this->get('/'); // THEN $response->assertOk(); $response->assertDontSee('', false); $response->assertSee('Rôti <img src=x onerror=alert(1)>', false); }); });