- 83 Komponenten: Livewire\Volt\Component → Livewire\Component
- 73 Routen (admin, auth, customer): Volt::route() → Route::livewire()
- 88 Testdateien: Volt::test/actingAs → Livewire::test/actingAs
- VoltServiceProvider gelöscht; composer remove livewire/volt
- config/livewire.php auf v4-Schlüssel (component_layout, component_placeholder,
component_locations, make_command: SFC ohne ⚡). Der alte Schlüssel layout war
wirkungslos; alle gerouteten Komponenten setzen ihr Layout selbst.
- CLAUDE.md, AGENTS.md, boost.json, .cursorrules, Skill volt-development
- Roadmap: erledigt; Larastan erfasst SFCs weiterhin nicht (Blade-Dateien)
Suite 2.325 grün, einer übersprungen; Larastan und Pint ohne Meldung;
route:cache und view:cache laufen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
156 lines
5.8 KiB
PHP
156 lines
5.8 KiB
PHP
<?php
|
|
|
|
use App\Enums\ActivityType;
|
|
use App\Enums\PressReleaseStatus;
|
|
use App\Listeners\RecordAuthActivity;
|
|
use App\Models\ActivityEvent;
|
|
use App\Models\ContactMessage;
|
|
use App\Models\PressRelease;
|
|
use App\Models\User;
|
|
use App\Models\WithdrawalRequest;
|
|
use App\Services\Billing\StripeCheckoutService;
|
|
use App\Services\PressRelease\PressReleaseService;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Illuminate\Auth\Events\Login;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
test('a self registration is recorded in the activity log', function () {
|
|
/** @var TestCase $this */
|
|
Notification::fake();
|
|
|
|
Livewire::test('auth.register')
|
|
->set('name', 'Verlauf Tester')
|
|
->set('email', 'verlauf@example.com')
|
|
->set('password', 'password')
|
|
->set('password_confirmation', 'password')
|
|
->set('terms_accepted', true)
|
|
->call('register');
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::UserRegistered->value)->sole();
|
|
|
|
expect($event->meta['way'])->toBe('form')
|
|
->and($event->description)->toContain('verlauf@example.com')
|
|
->and($event->user_id)->not->toBeNull();
|
|
});
|
|
|
|
test('a login is recorded with its method', function () {
|
|
$user = User::factory()->create(['is_active' => true]);
|
|
|
|
request()->attributes->set(RecordAuthActivity::AUTH_METHOD_ATTRIBUTE, 'magic-link');
|
|
event(new Login('web', $user, false));
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::UserLoggedIn->value)->sole();
|
|
|
|
expect($event->meta['method'])->toBe('magic-link')
|
|
->and($event->description)->toContain('Magic-Link')
|
|
->and($event->user_id)->toBe($user->id);
|
|
});
|
|
|
|
test('a press release status change is recorded', function () {
|
|
Queue::fake();
|
|
|
|
$pressRelease = PressRelease::factory()->create(['status' => PressReleaseStatus::Draft]);
|
|
|
|
app(PressReleaseService::class)->submitForReview($pressRelease);
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::PressReleaseStatus->value)->first();
|
|
|
|
expect($event)->not->toBeNull()
|
|
->and($event->description)->toContain($pressRelease->title)
|
|
->and($event->subject_id)->toBe($pressRelease->id)
|
|
->and($event->actor_label)->toBe('System');
|
|
});
|
|
|
|
test('form submissions are recorded via the observer', function () {
|
|
ContactMessage::factory()->create([
|
|
'name' => 'Max Beispiel',
|
|
'email' => 'max@example.com',
|
|
]);
|
|
WithdrawalRequest::factory()->create([
|
|
'name' => 'Erika Beispiel',
|
|
'email' => 'erika@example.com',
|
|
]);
|
|
|
|
expect(ActivityEvent::query()->where('type', ActivityType::ContactRequest->value)->sole()->description)
|
|
->toContain('max@example.com');
|
|
expect(ActivityEvent::query()->where('type', ActivityType::WithdrawalRequest->value)->sole()->description)
|
|
->toContain('erika@example.com');
|
|
});
|
|
|
|
test('the activity report page lists events and filters by type', function () {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
|
|
ActivityEvent::query()->create([
|
|
'type' => ActivityType::ContactRequest->value,
|
|
'occurred_at' => now(),
|
|
'actor_label' => 'Gast',
|
|
'description' => 'Kontaktanfrage „Testthema“ von Gast (gast@example.com).',
|
|
]);
|
|
ActivityEvent::query()->create([
|
|
'type' => ActivityType::UserLoggedIn->value,
|
|
'occurred_at' => now(),
|
|
'user_id' => $admin->id,
|
|
'actor_label' => $admin->name,
|
|
'description' => 'Admin hat sich angemeldet — Passwort.',
|
|
]);
|
|
|
|
$this->actingAs($admin);
|
|
|
|
$this->get(route('admin.reports.activity'))->assertOk();
|
|
|
|
Livewire::test('admin.reports.activity')
|
|
->assertSee('Kontaktanfrage „Testthema“')
|
|
->assertSee('hat sich angemeldet')
|
|
->set('typeFilter', ActivityType::ContactRequest->value)
|
|
->assertSee('Kontaktanfrage „Testthema“')
|
|
->assertDontSee('hat sich angemeldet');
|
|
});
|
|
|
|
test('a sent mail is recorded and linked to the recipient user', function () {
|
|
$user = User::factory()->create(['email' => 'empfaenger@example.com']);
|
|
|
|
Mail::raw('Inhalt', function ($message) {
|
|
$message->to('empfaenger@example.com')->subject('Willkommen bei pressekonto');
|
|
});
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::MailSent->value)->sole();
|
|
|
|
expect($event->description)->toContain('Willkommen bei pressekonto')
|
|
->and($event->description)->toContain('empfaenger@example.com')
|
|
->and($event->user_id)->toBe($user->id)
|
|
->and($event->meta['to'])->toBe(['empfaenger@example.com'])
|
|
->and($event->meta['subject'])->toBe('Willkommen bei pressekonto');
|
|
});
|
|
|
|
test('a mail to an unknown address is recorded with the address as actor label', function () {
|
|
Mail::raw('Inhalt', function ($message) {
|
|
$message->to('extern@example.com')->subject('Externe Info');
|
|
});
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::MailSent->value)->sole();
|
|
|
|
expect($event->user_id)->toBeNull()
|
|
->and($event->actor_label)->toBe('extern@example.com');
|
|
});
|
|
|
|
test('a checkout redirect is recorded in the activity log', function () {
|
|
$user = User::factory()->create(['name' => 'Kauf Karla']);
|
|
|
|
app(StripeCheckoutService::class)
|
|
->recordCheckoutStarted($user, 'Abo „Business" (monatlich)', ['kind' => 'subscription', 'interval' => 'monthly']);
|
|
|
|
$event = ActivityEvent::query()->where('type', ActivityType::CheckoutStarted->value)->sole();
|
|
|
|
expect($event->user_id)->toBe($user->id)
|
|
->and($event->description)->toContain('zur Zahlung weitergeleitet')
|
|
->and($event->description)->toContain('Abo „Business" (monatlich)')
|
|
->and($event->meta['kind'])->toBe('subscription');
|
|
});
|