20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
107
tests/Feature/PartnerProfilePageTest.php
Normal file
107
tests/Feature/PartnerProfilePageTest.php
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Enums\ProductStatus;
|
||||
use App\Models\Hub;
|
||||
use App\Models\Partner;
|
||||
use App\Models\Product;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Livewire\Volt\Volt;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
beforeEach(function () {
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
Role::create(['name' => 'Retailer']);
|
||||
Role::create(['name' => 'Customer']);
|
||||
});
|
||||
|
||||
test('authenticated user can view partner profile page', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
$partner = Partner::factory()->setupCompleted()->create([
|
||||
'hub_id' => $hub->id,
|
||||
'company_name' => 'Tischlerei Müller GmbH',
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('partner.profile', ['partnerId' => $partner->id])
|
||||
->assertSee($partner->company_name);
|
||||
});
|
||||
|
||||
test('partner profile shows display name when set', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
$partner = Partner::factory()->setupCompleted()->create([
|
||||
'hub_id' => $hub->id,
|
||||
'company_name' => 'Tischlerei Müller GmbH',
|
||||
'display_name' => 'Tischlerei Müller',
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('partner.profile', ['partnerId' => $partner->id])
|
||||
->assertSee('Tischlerei Müller')
|
||||
->assertSee('Tischlerei Müller GmbH');
|
||||
});
|
||||
|
||||
test('partner profile shows story text when present', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
$partner = Partner::factory()->setupCompleted()->create([
|
||||
'hub_id' => $hub->id,
|
||||
'story_text' => 'Wir sind seit 1985 eine regionale Tischlerei.',
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('partner.profile', ['partnerId' => $partner->id])
|
||||
->assertSee('Wir sind seit 1985 eine regionale Tischlerei.');
|
||||
});
|
||||
|
||||
test('partner profile only shows active curated available products', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
$partner = Partner::factory()->setupCompleted()->create(['hub_id' => $hub->id]);
|
||||
|
||||
$visibleProduct = Product::factory()->create([
|
||||
'partner_id' => $partner->id,
|
||||
'hub_id' => $hub->id,
|
||||
'status' => ProductStatus::Active,
|
||||
'is_curated' => true,
|
||||
'is_available' => true,
|
||||
]);
|
||||
|
||||
$draftProduct = Product::factory()->create([
|
||||
'partner_id' => $partner->id,
|
||||
'hub_id' => $hub->id,
|
||||
'status' => ProductStatus::Draft,
|
||||
'is_curated' => false,
|
||||
'is_available' => false,
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('partner.profile', ['partnerId' => $partner->id])
|
||||
->assertSee($visibleProduct->name)
|
||||
->assertDontSee($draftProduct->name);
|
||||
});
|
||||
|
||||
test('partner profile throws model not found for non-existent partner', function () {
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
expect(fn () => Volt::test('partner.profile', ['partnerId' => 99999]))
|
||||
->toThrow(ModelNotFoundException::class);
|
||||
});
|
||||
|
||||
test('unauthenticated user is redirected from partner profile', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
$partner = Partner::factory()->setupCompleted()->create(['hub_id' => $hub->id]);
|
||||
|
||||
$this->get(route('partner.profile', ['partnerId' => $partner->id]))
|
||||
->assertRedirect(route('login'));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue