seed(RolesAndPermissionsSeeder::class); $admin = User::factory()->create(['is_active' => true]); $admin->assignRole('admin'); $this->actingAs($admin); $company = Company::factory()->create(); $category = Category::factory()->withTranslations()->create(); PressRelease::factory() ->count(2) ->create([ 'user_id' => $admin->id, 'company_id' => $company->id, 'category_id' => $category->id, 'portal' => Portal::Presseecho->value, ]); PressRelease::factory() ->create([ 'user_id' => $admin->id, 'company_id' => $company->id, 'category_id' => $category->id, 'portal' => Portal::Businessportal24->value, ]); LivewireVolt::test('admin.categories.index') ->assertSee(route('admin.press-releases.index', ['category' => $category->id]), false) ->assertViewHas('stats', fn (array $stats): bool => $stats['with_releases'] === 1 && $stats['total_releases'] === 3 && $stats['presseecho_releases'] === 2 && $stats['businessportal24_releases'] === 1) ->assertViewHas('categories', function ($categories): bool { $firstCategory = $categories->first(); return $firstCategory instanceof Category && $firstCategory->press_releases_count === 3 && $firstCategory->presseecho_press_releases_count === 2 && $firstCategory->businessportal24_press_releases_count === 1 && $firstCategory->relationLoaded('translations') && ! $firstCategory->relationLoaded('pressReleases'); }); }); test('press release index can be filtered by category and shows category column', function () { /** @var TestCase $this */ $this->seed(RolesAndPermissionsSeeder::class); $admin = User::factory()->create(['is_active' => true]); $admin->assignRole('admin'); $this->actingAs($admin); $longCompanyName = 'Eine sehr lange Firma mit einem Namen der in der Tabelle begrenzt werden muss GmbH'; $company = Company::factory()->create([ 'name' => $longCompanyName, ]); $selectedCategory = Category::factory()->create(); $otherCategory = Category::factory()->create(); $selectedCategory->translations()->createMany([ ['locale' => 'de', 'name' => 'Wirtschaft', 'slug' => 'wirtschaft'], ['locale' => 'en', 'name' => 'Business', 'slug' => 'business'], ]); $otherCategory->translations()->create([ 'locale' => 'de', 'name' => 'Technologie', 'slug' => 'technologie', ]); $longTitle = 'Gefilterte Pressemitteilung mit einem sehr langen Titel der in der Tabelle ebenfalls begrenzt werden muss'; PressRelease::factory()->create([ 'user_id' => $admin->id, 'company_id' => $company->id, 'category_id' => $selectedCategory->id, 'title' => $longTitle, ]); PressRelease::factory()->create([ 'user_id' => $admin->id, 'company_id' => $company->id, 'category_id' => $otherCategory->id, 'title' => 'Andere Pressemitteilung', ]); LivewireVolt::test('admin.press-releases.index') ->set('categoryFilter', (string) $selectedCategory->id) ->assertSee('Kategorie') ->assertSee('Wirtschaft') ->assertSee($longTitle) ->assertSee($longCompanyName) ->assertDontSee('Andere Pressemitteilung'); });