presseportale/tests/Feature/Web/NewsroomPageTest.php
Kevin Adametz 028b059975
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Editorial-Frontend: oeffentliche Unterseiten, Preise & Linkpflege
Oeffentliche Strecke durchgaengig auf das Editorial-Design umgestellt und
datengetrieben gemacht:

- Newsrooms-Verzeichnis + Newsroom-Detailseiten (Suche, Pagination)
- Preise-Seite neu (Abos via Plan, Einzel-PM via config/billing, Add-ons via
  config/credits); Texte ausgelagert nach lang/{de,en}/pricing.php
- Pricing-Teaser-Komponente auf den Startseiten + Preise-Link in Header/Footer
- Statische Seiten im Editorial-Design ueber neue Komponente x-web.static-page:
  impressum, datenschutz, agb, cookies, faq (Akkordeon), hilfe, kontakt,
  ueber-uns, api (altes Theme/gradient-hero entfernt)
- Header/Footer-Linkpflege: tote #-Anker raus, FAQ/Hilfe/Cookies verlinkt,
  "Anmelden" fuehrt in den Hub
- Legacy-URL-Redirects (.html, presskit->newsroom, Regionen)
- Datums-Bugfix in Feed-Komponenten

Tests: NewsroomPage, PreisePage, PricingTeaser, StaticPages, NavigationLinks,
LegacyRedirect. Doku in docs/frontend aktualisiert.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 16:08:46 +00:00

116 lines
4.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 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');
});