presseportale/tests/Feature/PressReleaseDraftNotLostTest.php
Kevin Adametz 2cde7284a1 livewire: Volt entfernt — Komponenten als Livewire-4-Single-File-Components, Route::livewire(), Livewire::test(); livewire/volt deinstalliert
- 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>
2026-10-06 13:59:36 +00:00

87 lines
3.4 KiB
PHP

<?php
use App\Enums\PressReleaseStatus;
use App\Models\Category;
use App\Models\Company;
use App\Models\Contact;
use App\Models\PressRelease;
use App\Models\User;
use Database\Seeders\RolesAndPermissionsSeeder;
use Livewire\Livewire;
use Tests\TestCase;
beforeEach(function (): void {
/** @var TestCase $this */
$this->seed(RolesAndPermissionsSeeder::class);
// Gate aktiv, damit der „Buchung auswählen"-Pfad im Submit-Modal greift.
config()->set('billing.enforce_booking', true);
});
test('create: choosing a booking from the submit modal saves the draft first', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
$contact = Contact::factory()->for($company)->create(['portal' => $company->portal->value]);
$category = Category::factory()->create();
$this->actingAs($customer);
Livewire::test('customer.press-releases.create')
->set('title', 'Entwurf der auf keinen Fall verloren gehen darf')
->set('text', str_repeat('Inhaltlich relevanter Fließtext. ', 5))
->set('categoryId', $category->id)
->set('contactId', $contact->id)
->call('saveDraftAndChooseBooking')
->assertHasNoErrors()
->assertRedirect(route('me.bookings.index'));
$pr = PressRelease::query()->where('user_id', $customer->id)->latest('id')->first();
expect($pr)->not->toBeNull();
expect($pr->title)->toBe('Entwurf der auf keinen Fall verloren gehen darf');
expect($pr->status)->toBe(PressReleaseStatus::Draft);
});
test('create: the submit modal offers the saving booking button when no booking exists', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
$this->actingAs($customer);
Livewire::test('customer.press-releases.create')
->assertSee('Buchung erforderlich')
->assertSee('Speichern & Buchung auswählen');
});
test('edit: choosing a booking from the submit modal persists the edits first', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
$pr = PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'category_id' => Category::factory()->create()->id,
'portal' => $company->portal->value,
'status' => 'draft',
'title' => 'Originaltitel',
]);
$this->actingAs($customer);
Livewire::test('customer.press-releases.edit', ['id' => $pr->id])
->set('title', 'Bearbeiteter Titel der erhalten bleiben muss')
->set('text', str_repeat('Neuer Fließtext mit Inhalt. ', 5))
->call('saveDraftAndChooseBooking')
->assertHasNoErrors()
->assertRedirect(route('me.bookings.index'));
expect($pr->fresh()->title)->toBe('Bearbeiteter Titel der erhalten bleiben muss');
expect($pr->fresh()->status)->toBe(PressReleaseStatus::Draft);
});