presseportale/tests/Feature/NewsroomProfileTest.php
Kevin Adametz 31da9ea8b6
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
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

96 lines
4.1 KiB
PHP

<?php
use App\Enums\ConversionEventType;
use App\Enums\ConversionSource;
use App\Enums\Portal;
use App\Models\Company;
use App\Models\ConversionEvent;
use App\Models\PressRelease;
use App\Models\User;
use App\Services\Auth\MagicLinkGenerator;
use Livewire\Livewire;
use Tests\TestCase;
/**
* Kostenlose Profilpflege des Newsrooms (Roadmap 1b.3): Beschreibungstext
* durch die Rot-Ebene, reiner Text ohne Links, Bilder als BALD-Platzhalter.
*/
function profileCustomer(): array
{
config()->set('blacklist.words', ['spam-keyword']);
config()->set('scoring.classification.provider', 'deterministic');
$customer = User::factory()->create(['is_active' => true]);
$company = Company::factory()->businessportal24()->create(['name' => 'Muster GmbH', 'slug' => 'muster-gmbh', 'boilerplate' => null]);
$customer->companies()->attach($company->id, ['role' => 'responsible']);
test()->actingAs($customer);
return [$customer, $company];
}
test('a customer can write the newsroom description and it shows on the public newsroom', function () {
/** @var TestCase $this */
[$customer, $company] = profileCustomer();
PressRelease::factory()->published()->forPortal(Portal::Businessportal24)->create(['company_id' => $company->id, 'published_at' => now()->subDay(), 'language' => 'de']);
// Seiten-Cache warm — die Änderung muss trotzdem sofort sichtbar sein.
$this->get('https://businessportal24.test/de/newsroom/muster-gmbh')->assertOk()->assertDontSeeText('führender Anbieter');
Livewire::test('customer.press-kits.show', ['id' => $company->id])
->call('startEditCompany')
->set('companyBoilerplate', "Muster ist ein <b>führender Anbieter</b> für Musterlösungen.\n<a href=\"https://spam.example\">Link</a>")
->call('saveCompany')
->assertHasNoErrors();
// Reiner Text: Tags fallen weg, Links im Profiltext gibt es nicht.
expect($company->fresh()->boilerplate)->toBe("Muster ist ein führender Anbieter für Musterlösungen.\nLink");
$this->get('https://businessportal24.test/de/newsroom/muster-gmbh')
->assertOk()
->assertSeeText('führender Anbieter')
->assertDontSee('spam.example', false);
});
test('a description that hits the red level is rejected and nothing is saved', function () {
/** @var TestCase $this */
[$customer, $company] = profileCustomer();
Livewire::test('customer.press-kits.show', ['id' => $company->id])
->call('startEditCompany')
->set('companyName', 'Muster GmbH neu')
->set('companyBoilerplate', 'Wir sind ein spam-keyword Anbieter.')
->call('saveCompany')
->assertHasErrors(['companyBoilerplate']);
$company->refresh();
expect($company->boilerplate)->toBeNull()
->and($company->name)->toBe('Muster GmbH');
});
test('saving the profile records step three once, with the origin of the last magic link', function () {
/** @var TestCase $this */
[$customer, $company] = profileCustomer();
$link = app(MagicLinkGenerator::class)->createLoginLink($customer, null, 15, ConversionSource::ProfileClaim);
$link['magic_link']->update(['consumed_at' => now()]);
$component = Livewire::test('customer.press-kits.show', ['id' => $company->id]);
$component->call('startEditCompany')->set('companyBoilerplate', 'Erste Fassung.')->call('saveCompany')->assertHasNoErrors();
$component->call('startEditCompany')->set('companyBoilerplate', 'Zweite Fassung.')->call('saveCompany')->assertHasNoErrors();
$events = ConversionEvent::query()->where('type', ConversionEventType::NewsroomEdited->value)->get();
expect($events)->toHaveCount(1)
->and($events->first()->company_id)->toBe($company->id)
->and($events->first()->source)->toBe(ConversionSource::ProfileClaim);
});
test('image upload is shown as a placeholder, not offered', function () {
/** @var TestCase $this */
[$customer, $company] = profileCustomer();
Livewire::test('customer.press-kits.show', ['id' => $company->id])
->call('startEditCompany')
->assertSee('Bilder im Newsroom')
->assertSee('BALD')
->assertSee('Funktion folgt');
});