|
| 1 | +<?php |
| 2 | + |
| 3 | +use App\Enums\LocaleEnum; |
| 4 | +use App\Enums\SessionKeyEnum; |
| 5 | +use App\Models\Service; |
| 6 | +use Illuminate\Support\Str; |
| 7 | + |
| 8 | +use function Pest\Laravel\get; |
| 9 | +use function Pest\Laravel\withSession; |
| 10 | + |
| 11 | +it('returns 200 for both locales', function (string $locale) { |
| 12 | + withSession([SessionKeyEnum::LANGUAGE->value => $locale]) |
| 13 | + ->get(route(Str::slug($locale).'.services.index')) |
| 14 | + ->assertOk(); |
| 15 | +})->with([LocaleEnum::DE->value, LocaleEnum::EN->value])->group('services'); |
| 16 | + |
| 17 | +it('shows a published service with name and teaser', function () { |
| 18 | + Service::factory()->create([ |
| 19 | + 'locale' => LocaleEnum::DE->value, |
| 20 | + 'name' => 'Konzeption Visible', |
| 21 | + 'teaser' => 'Sichtbarer Teaser Text', |
| 22 | + 'published' => true, |
| 23 | + ]); |
| 24 | + |
| 25 | + get(route('de-ch.services.index')) |
| 26 | + ->assertOk() |
| 27 | + ->assertSee('Konzeption Visible') |
| 28 | + ->assertSee('Sichtbarer Teaser Text'); |
| 29 | +})->group('services'); |
| 30 | + |
| 31 | +it('does not show unpublished services', function () { |
| 32 | + Service::factory()->create([ |
| 33 | + 'locale' => LocaleEnum::DE->value, |
| 34 | + 'name' => 'Hidden Service XYZ', |
| 35 | + 'published' => false, |
| 36 | + ]); |
| 37 | + |
| 38 | + get(route('de-ch.services.index')) |
| 39 | + ->assertOk() |
| 40 | + ->assertDontSee('Hidden Service XYZ'); |
| 41 | +})->group('services'); |
| 42 | + |
| 43 | +it('does not show services of another locale', function () { |
| 44 | + Service::factory()->create([ |
| 45 | + 'locale' => LocaleEnum::EN->value, |
| 46 | + 'name' => 'English Only Service', |
| 47 | + 'published' => true, |
| 48 | + ]); |
| 49 | + |
| 50 | + get(route('de-ch.services.index')) |
| 51 | + ->assertOk() |
| 52 | + ->assertDontSee('English Only Service'); |
| 53 | +})->group('services'); |
0 commit comments