12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
106
tests/Feature/Admin/CategoryIndexPerformanceTest.php
Normal file
106
tests/Feature/Admin/CategoryIndexPerformanceTest.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
test('category index loads release counts without hydrating press release models', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->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');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue