1.1 Prototyp admin/users/table entfernt: Route (war durch admin/users/{id}
ohnehin unerreichbar) + Volt-Komponente table.blade.php geloescht,
ADMIN_ROUTES.md aktualisiert; Regressions-Test in PanelConsolidationTest.
1.2 16 tote Legacy-Wrapper-Views unter resources/views/admin/* geloescht
(nutzten alte Route-Parameter, nirgends via view/@include/@livewire
gerendert); admin.dashboard + .md-Doku behalten.
1.3 Tote Helfer entfernt: EnsureUserIsAdmin redundantes loadMissing('roles'),
ungenutzter statusColor-Key aus with() in admin PR edit/show,
LegacyInvoicePdfController Laufzeit-Schema::hasColumn (Spalte existiert
seit Migration) inkl. Schema-Import.
Volle Suite gruen (794 passed, 1 skipped).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
164 lines
6.1 KiB
PHP
164 lines
6.1 KiB
PHP
<?php
|
|
|
|
use App\Models\Plan;
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Tests\TestCase;
|
|
|
|
beforeEach(function (): void {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
});
|
|
|
|
test('the removed admin users table prototype route no longer exists', function () {
|
|
expect(Route::has('admin.users.table'))->toBeFalse();
|
|
});
|
|
|
|
test('legacy customer dashboard URL redirects to me dashboard', function () {
|
|
/** @var TestCase $this */
|
|
$this->get('/customer')
|
|
->assertRedirect('/admin/me');
|
|
});
|
|
|
|
test('legacy customer press releases URL redirects to me press releases', function () {
|
|
/** @var TestCase $this */
|
|
$this->get('/customer/press-releases')
|
|
->assertRedirect('/admin/me/press-releases');
|
|
|
|
$this->get('/customer/press-releases/create')
|
|
->assertRedirect('/admin/me/press-releases/create');
|
|
|
|
$this->get('/customer/press-releases/123')
|
|
->assertRedirect('/admin/me/press-releases/123');
|
|
|
|
$this->get('/customer/press-releases/123/edit')
|
|
->assertRedirect('/admin/me/press-releases/123/edit');
|
|
});
|
|
|
|
test('legacy customer settings URLs redirect to me area', function () {
|
|
/** @var TestCase $this */
|
|
$this->get('/customer/profile')->assertRedirect('/admin/me/profile');
|
|
$this->get('/customer/security')->assertRedirect('/admin/me/security');
|
|
$this->get('/customer/tokens')->assertRedirect('/admin/me/tokens');
|
|
$this->get('/customer/invoices')->assertRedirect('/admin/me/invoices');
|
|
$this->get('/customer/buchungen-add-ons')->assertRedirect('/admin/me/buchungen-add-ons');
|
|
$this->get('/customer/pressemappen')->assertRedirect('/admin/me/firmen');
|
|
$this->get('/customer/pressemappen/123')->assertRedirect('/admin/me/firmen/123');
|
|
});
|
|
|
|
test('me dashboard requires authentication', function () {
|
|
/** @var TestCase $this */
|
|
$this->get(route('me.dashboard'))
|
|
->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('customer can access me dashboard but not admin dashboard', function () {
|
|
/** @var TestCase $this */
|
|
$customer = User::factory()->create(['is_active' => true]);
|
|
$customer->assignRole('customer');
|
|
|
|
$this->actingAs($customer);
|
|
|
|
$this->get(route('me.dashboard'))->assertSuccessful();
|
|
$this->get(route('dashboard'))->assertForbidden();
|
|
});
|
|
|
|
test('customer bookings page shows the tariff grid and single pm block', function () {
|
|
// Seit Phase 9F zeigt die Seite das echte Tarif-Raster mit
|
|
// Stripe-Checkout statt des Credit-Konzept-Mocks (Credits → Phase 9I/2).
|
|
/** @var TestCase $this */
|
|
$customer = User::factory()->create(['is_active' => true]);
|
|
$customer->assignRole('customer');
|
|
|
|
Plan::factory()->create([
|
|
'name' => 'Starter',
|
|
'monthly_price_cents' => 2900,
|
|
'press_release_quota' => 3,
|
|
]);
|
|
|
|
$this->actingAs($customer)
|
|
->get(route('me.bookings.index'))
|
|
->assertSuccessful()
|
|
->assertSee('Den passenden Tarif wählen')
|
|
->assertSee('Starter')
|
|
->assertSee('29 €')
|
|
->assertSee('2 Monate gratis')
|
|
->assertSee('Einzel-Pressemitteilung — ohne Abo')
|
|
->assertSee('Noch kein Buchungsverlauf');
|
|
});
|
|
|
|
test('admin can access both panel dashboards', function () {
|
|
/** @var TestCase $this */
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
$this->actingAs($admin);
|
|
|
|
$this->get(route('dashboard'))->assertSuccessful();
|
|
$this->get(route('me.dashboard'))->assertSuccessful();
|
|
});
|
|
|
|
test('editor can access both panel dashboards', function () {
|
|
/** @var TestCase $this */
|
|
$editor = User::factory()->create(['is_active' => true]);
|
|
$editor->assignRole('editor');
|
|
|
|
$this->actingAs($editor);
|
|
|
|
$this->get(route('dashboard'))->assertSuccessful();
|
|
$this->get(route('me.dashboard'))->assertSuccessful();
|
|
});
|
|
|
|
test('inactive user cannot access panel', function () {
|
|
/** @var TestCase $this */
|
|
$user = User::factory()->create(['is_active' => false]);
|
|
$user->assignRole('customer');
|
|
|
|
$this->actingAs($user);
|
|
|
|
$this->get(route('me.dashboard'))->assertForbidden();
|
|
});
|
|
|
|
test('sidebar shows customer area for admins', function () {
|
|
/** @var TestCase $this */
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
$this->actingAs($admin)
|
|
->get(route('dashboard'))
|
|
->assertSee('Mein Bereich')
|
|
->assertSee('Administration');
|
|
});
|
|
|
|
test('sidebar hides admin area for customers', function () {
|
|
/** @var TestCase $this */
|
|
$customer = User::factory()->create(['is_active' => true]);
|
|
$customer->assignRole('customer');
|
|
|
|
$this->actingAs($customer)
|
|
->get(route('me.dashboard'))
|
|
->assertSee('Mein Bereich')
|
|
->assertSee('Buchungen & Add-ons', false)
|
|
->assertSee('Finanzen')
|
|
->assertSee('Rechnungen')
|
|
->assertSee('Konto')
|
|
->assertSee('API & Integrationen', false)
|
|
->assertDontSee('Administration')
|
|
->assertDontSee('Footer-Codes');
|
|
});
|
|
|
|
test('all me routes resolve to expected admin paths', function () {
|
|
expect(route('me.dashboard', absolute: false))->toBe('/admin/me');
|
|
expect(route('me.press-releases.index', absolute: false))->toBe('/admin/me/press-releases');
|
|
expect(route('me.press-releases.create', absolute: false))->toBe('/admin/me/press-releases/create');
|
|
expect(route('me.press-releases.show', ['id' => 5], absolute: false))->toBe('/admin/me/press-releases/5');
|
|
expect(route('me.press-releases.edit', ['id' => 5], absolute: false))->toBe('/admin/me/press-releases/5/edit');
|
|
expect(route('me.press-kits.index', absolute: false))->toBe('/admin/me/firmen');
|
|
expect(route('me.press-kits.show', ['id' => 5], absolute: false))->toBe('/admin/me/firmen/5');
|
|
expect(route('me.bookings.index', absolute: false))->toBe('/admin/me/buchungen-add-ons');
|
|
expect(route('me.invoices.index', absolute: false))->toBe('/admin/me/invoices');
|
|
expect(route('me.tokens.index', absolute: false))->toBe('/admin/me/tokens');
|
|
expect(route('me.profile', absolute: false))->toBe('/admin/me/profile');
|
|
expect(route('me.security', absolute: false))->toBe('/admin/me/security');
|
|
});
|