Die Firmenseite im Kundenbereich bekommt den Beschreibungstext (max. 2 000 Zeichen, reiner Text). Er läuft durch dieselbe Klassifikation wie eine Meldung (CompanyProfileCheck, KI mit deterministischem Fallback); Rot wird abgewiesen. Links im Profiltext gibt es nicht — die Website ist das eine Link-Feld. Bilder zurückgestellt (BALD-Platzhalter), bis die Bild-Kennzeichnung angepasst ist. Stufe 3 der Konversionsleiter (newsroom_edited) wird hier geschrieben, einmal je Firma, mit der Herkunft des zuletzt eingelösten Magic Links. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
96 lines
4.1 KiB
PHP
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\Volt\Volt as LivewireVolt;
|
|
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');
|
|
|
|
LivewireVolt::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();
|
|
|
|
LivewireVolt::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 = LivewireVolt::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();
|
|
|
|
LivewireVolt::test('customer.press-kits.show', ['id' => $company->id])
|
|
->call('startEditCompany')
|
|
->assertSee('Bilder im Newsroom')
|
|
->assertSee('BALD')
|
|
->assertSee('Funktion folgt');
|
|
});
|