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 führender Anbieter für Musterlösungen.\nLink") ->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'); });