22-05-2026 Optimierung der User und Admin Panels
This commit is contained in:
parent
d2ba22c0cf
commit
e8c47b7553
73 changed files with 10282 additions and 1546 deletions
|
|
@ -10,9 +10,7 @@ use App\Models\PressRelease;
|
|||
use App\Models\PressReleaseStatusLog;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
|
@ -61,82 +59,43 @@ test('customer can update own profile fields', function () {
|
|||
expect($customer->billingAddress?->country_code)->toBe('DE');
|
||||
});
|
||||
|
||||
test('customer can update an owned company and upload a logo with variants', function () {
|
||||
test('customer profile keeps company management out of the profile page', function () {
|
||||
/** @var TestCase $this */
|
||||
Storage::fake('public');
|
||||
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$company = Company::factory()->presseecho()->create([
|
||||
'owner_user_id' => $customer->id,
|
||||
'name' => 'Old Co',
|
||||
'name' => 'Nicht im Profil geladene Firma',
|
||||
]);
|
||||
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
$logo = UploadedFile::fake()->image('logo.png', 800, 400);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.profile')
|
||||
->set('editableCompanyId', $company->id)
|
||||
->set('companyName', 'New Co GmbH')
|
||||
->set('companyEmail', 'contact@example.test')
|
||||
->set('companyWebsite', 'https://example.test')
|
||||
->set('companyCountryCode', 'CH')
|
||||
->set('companyLogo', $logo)
|
||||
->call('saveCompany')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$company->refresh();
|
||||
|
||||
expect($company->name)->toBe('New Co GmbH');
|
||||
expect($company->email)->toBe('contact@example.test');
|
||||
expect($company->country_code)->toBe('CH');
|
||||
expect($company->logo_path)->not->toBeNull();
|
||||
expect($company->logo_variants)->toHaveKey('sq');
|
||||
expect($company->logo_variants)->toHaveKey('wide');
|
||||
|
||||
expect(Storage::disk('public')->exists($company->logo_path))->toBeTrue();
|
||||
expect(Storage::disk('public')->exists($company->logo_variants['sq']))->toBeTrue();
|
||||
expect(Storage::disk('public')->exists($company->logo_variants['wide']))->toBeTrue();
|
||||
->assertSee('Rechnungsadresse')
|
||||
->assertSee('Profileinstellungen')
|
||||
->assertSee('Firmen verwalten')
|
||||
->assertDontSee('Zugeordnete Firmen')
|
||||
->assertDontSee('Nicht im Profil geladene Firma');
|
||||
});
|
||||
|
||||
test('customer cannot edit a company they do not own or co-manage', function () {
|
||||
test('customer can save profile settings without a billing address', function () {
|
||||
/** @var TestCase $this */
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$otherCompany = Company::factory()->presseecho()->create([
|
||||
'owner_user_id' => User::factory()->create()->id,
|
||||
]);
|
||||
$customer->companies()->attach($otherCompany->id, ['role' => 'member']);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.profile')
|
||||
->set('editableCompanyId', $otherCompany->id)
|
||||
->set('companyName', 'Hijacked')
|
||||
->call('saveCompany');
|
||||
|
||||
$otherCompany->refresh();
|
||||
|
||||
expect($otherCompany->name)->not->toBe('Hijacked');
|
||||
});
|
||||
|
||||
test('customer can edit a company they own directly without pivot membership', function () {
|
||||
/** @var TestCase $this */
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$company = Company::factory()->presseecho()->create([
|
||||
'owner_user_id' => $customer->id,
|
||||
'name' => 'Owner Company',
|
||||
$customer = User::factory()->create([
|
||||
'is_active' => true,
|
||||
'name' => 'Ohne Rechnung',
|
||||
]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.profile')
|
||||
->set('editableCompanyId', $company->id)
|
||||
->set('companyName', 'Owner Company Updated')
|
||||
->call('saveCompany')
|
||||
->set('name', 'Nur Profil')
|
||||
->set('firstName', 'Nur')
|
||||
->set('lastName', 'Profil')
|
||||
->call('saveProfile')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect($company->refresh()->name)->toBe('Owner Company Updated');
|
||||
expect($customer->refresh()->name)->toBe('Nur Profil');
|
||||
expect($customer->billingAddress)->toBeNull();
|
||||
});
|
||||
|
||||
test('customer security page renders password and email forms', function () {
|
||||
|
|
@ -221,6 +180,7 @@ test('customer press releases derive portal from selected company', function ()
|
|||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
||||
$contact = Contact::factory()->for($company)->create(['portal' => $company->portal->value]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
|
|
@ -228,6 +188,7 @@ test('customer press releases derive portal from selected company', function ()
|
|||
->set('companyId', $company->id)
|
||||
->set('portal', Portal::Businessportal24->value)
|
||||
->set('categoryId', Category::factory()->create()->id)
|
||||
->set('contactId', $contact->id)
|
||||
->set('title', 'Neue Meldung fuer Presseecho')
|
||||
->set('text', str_repeat('Dies ist ein ausreichend langer Testtext. ', 3))
|
||||
->call('save', 'draft')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue