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); LivewireVolt::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); LivewireVolt::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); LivewireVolt::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); });