presseportale/tests/Feature/Web/NewsroomPageTest.php
Kevin Adametz 021ee2d23c admin: Newsletter mit Abmelde-Liste, Follow-up-Filtern und gedrosseltem Versand
- Unterseite /admin/newsletter/abmeldungen listet Newsletter-Opt-outs mit
  Zeitpunkt, Suche und Link zur User-Detailseite
- Kampagnen-Filter: Empfänger einer früheren Kampagne ausschließen
  (Abgleich per User-ID und E-Mail-Snapshot) für Follow-up-Mailings
- Login-Filter kann Monats-Scheiben (von–bis) abgrenzen, um große
  Listen Monat für Monat abzuarbeiten
- Versand läuft in Wellen (Standard 50 Mails / 15 Min, per .env
  justierbar) gegen SMTP-Limits und Blocklisten; Hinweis im Senden-Modal
- web: Firmen-Website im Newsroom & Co. als absolute URL verlinkt
  (Company::websiteUrl), statt relativ auf /newsroom/www.example.de
- kunde: API-Doku-Button öffnet die /de/api-Seite; OpenAPI-Spezifikation
  als eigener, benannter Download (pressekonto-api-v1.yml)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 12:38:47 +00:00

136 lines
5.3 KiB
PHP

<?php
use App\Enums\Portal;
use App\Models\Category;
use App\Models\Company;
use App\Models\PressRelease;
use Illuminate\Support\Str;
use Tests\TestCase;
function makeNewsroom(string $name, Portal $portal = Portal::Businessportal24, array $attributes = []): Company
{
return Company::factory()
->state(['portal' => $portal->value])
->create(array_merge([
'name' => $name,
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(1000, 9999),
'is_active' => true,
], $attributes));
}
function publishForCompany(Company $company, string $title, array $attributes = [], ?Category $category = null): PressRelease
{
$category ??= Category::factory()->create(['portal' => Portal::Both]);
return PressRelease::factory()
->published()
->forPortal(Portal::Businessportal24)
->for($category)
->for($company)
->create(array_merge([
'title' => $title,
'slug' => Str::slug($title).'-'.fake()->unique()->numberBetween(1000, 9999),
'language' => 'de',
'published_at' => now()->subDay(),
], $attributes));
}
test('the newsrooms index renders the editorial shell and lists active newsrooms', function () {
/** @var TestCase $this */
$company = makeNewsroom('Nordwind Energie AG');
publishForCompany($company, 'Nordwind nimmt neuen Windpark in Betrieb');
$this->get('https://businessportal24.test/de/newsrooms')
->assertSuccessful()
->assertSee('businessportal', false)
->assertSeeText('Newsrooms')
->assertSeeText('Nordwind Energie AG');
});
test('the newsrooms index filters by company name', function () {
/** @var TestCase $this */
$match = makeNewsroom('Solartec Industries GmbH');
publishForCompany($match, 'Solartec meldet Rekordquartal');
$other = makeNewsroom('Hafenlogistik Bremen AG');
publishForCompany($other, 'Hafenlogistik baut Terminal aus');
$this->get('https://businessportal24.test/de/newsrooms?q=Solartec')
->assertSuccessful()
->assertSeeText('Solartec Industries GmbH')
->assertDontSeeText('Hafenlogistik Bremen AG');
});
test('the newsrooms index excludes companies without published releases', function () {
/** @var TestCase $this */
makeNewsroom('Stilles Unternehmen AG');
$this->get('https://businessportal24.test/de/newsrooms')
->assertSuccessful()
->assertDontSeeText('Stilles Unternehmen AG');
});
test('the newsroom detail page renders company data and its releases', function () {
/** @var TestCase $this */
$company = makeNewsroom('Bavaria Maschinenbau AG', attributes: [
'boilerplate' => 'Bavaria Maschinenbau ist ein führender Anbieter von Industrielösungen.',
]);
publishForCompany($company, 'Bavaria präsentiert neue Produktionslinie');
$this->get('https://businessportal24.test/de/newsroom/'.$company->slug)
->assertSuccessful()
->assertSeeText('Bavaria Maschinenbau AG')
->assertSeeText('Bavaria präsentiert neue Produktionslinie')
->assertSeeText('Alle Meldungen');
});
test('the newsroom detail page links the company website with an absolute url', function () {
/** @var TestCase $this */
// Bestandsdaten ohne Schema („www.akgsoftware.de“) — als roher href
// würde daraus der relative Link /de/newsroom/www.akgsoftware.de.
$company = makeNewsroom('AKG Software Consulting GmbH', attributes: [
'website' => 'www.akgsoftware.de',
]);
publishForCompany($company, 'AKG veröffentlicht neue Version');
$this->get('https://businessportal24.test/de/newsroom/'.$company->slug)
->assertSuccessful()
->assertSee('href="https://www.akgsoftware.de"', false)
->assertDontSee('newsroom/www.akgsoftware.de', false);
// Hinterlegte URLs mit Schema bleiben unverändert.
expect(Company::factory()->make(['website' => 'https://akgsoftware.de'])->websiteUrl())
->toBe('https://akgsoftware.de')
->and(Company::factory()->make(['website' => null])->websiteUrl())->toBeNull();
});
test('the newsroom detail page returns 404 for an unknown slug', function () {
/** @var TestCase $this */
$this->get('https://businessportal24.test/de/newsroom/gibt-es-nicht')
->assertNotFound();
});
test('the newsroom detail page returns 404 when the company has no published releases', function () {
/** @var TestCase $this */
$company = makeNewsroom('Leeres Newsroom AG');
$this->get('https://businessportal24.test/de/newsroom/'.$company->slug)
->assertNotFound();
});
test('the newsrooms pages are available per edition and portal', function () {
/** @var TestCase $this */
$this->get('https://businessportal24.test/en/newsrooms')->assertSuccessful();
$this->get('https://presseecho.test/de/newsrooms')
->assertSuccessful()
->assertSee('presse', false);
});
test('legacy newsroom html urls redirect to the clean edition path', function () {
/** @var TestCase $this */
$this->get('https://businessportal24.test/de/newsrooms.html')
->assertRedirect('https://businessportal24.test/de/newsrooms');
$this->get('https://businessportal24.test/de/newsroom/acme.html')
->assertRedirect('https://businessportal24.test/de/newsroom/acme');
});