web: Entitaeten im JSON-LD verknuepft, News-Sitemap und llms.txt (Roadmap 2.1, 2.2, 2.7)
- App\Support\StructuredData: Portal-Organization als Publisher mit @id und Logo (ImageObject), Newsroom-@id; NewsArticle.author auf der Meldung und Organization auf der Newsroom-Seite beschreiben jetzt dieselbe Entitaet. Startseiten nutzen denselben Publisher. - /sitemap-news.xml je Spoke (NewsSitemapController): im Archiv sichtbare Meldungen der letzten 48 h, max. 1.000, news:publication mit Portalname und Sprache; 15 min gecacht, mit den anderen Sitemaps geleert; in robots.txt der Spokes. Hub liefert leere Liste. - /llms.txt je Host (LlmsTxtController): sachliche Beschreibung, URL-Aufbau, aktive Kategorien, Seiten fuer Unternehmen, Rechtliches; Hub verweist auf beide Portale. Keine Aussagen ueber KI-Nennungen. - Protokoll Teil 5 (Block 2) inkl. Betreiber-Schritten fuer das Publisher Center und Befund zu 2.5/E5; Roadmap 2.1/2.7 abgehakt. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8cd76df0bb
commit
b60a28dc9c
15 changed files with 521 additions and 23 deletions
45
tests/Feature/Web/LlmsTxtTest.php
Normal file
45
tests/Feature/Web/LlmsTxtTest.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Category;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* `/llms.txt` je Host (Roadmap 2.7): sachliche Beschreibung, URL-Aufbau,
|
||||
* Kategorien — ohne Werbeaussagen.
|
||||
*/
|
||||
test('a spoke serves llms.txt with its structure, categories and legal pages', function () {
|
||||
/** @var TestCase $this */
|
||||
$category = Category::factory()->create(['portal' => Portal::Presseecho, 'is_active' => true]);
|
||||
$category->translations()->create(['locale' => 'de', 'name' => 'Energie', 'slug' => 'energie']);
|
||||
$inactive = Category::factory()->create(['portal' => Portal::Presseecho, 'is_active' => false]);
|
||||
$inactive->translations()->create(['locale' => 'de', 'name' => 'Veraltet', 'slug' => 'veraltet']);
|
||||
|
||||
$response = $this->get('https://presseecho.test/llms.txt')
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'text/plain; charset=UTF-8');
|
||||
|
||||
$text = (string) $response->getContent();
|
||||
expect($text)
|
||||
->toStartWith("# presseecho\n\n> ")
|
||||
->toContain('https://presseecho.test/de/press-release/{slug}')
|
||||
->toContain('https://presseecho.test/sitemap-news.xml')
|
||||
->toContain('- [Energie](https://presseecho.test/de/category/energie)')
|
||||
->toContain('- [Impressum](https://presseecho.test/de/impressum)')
|
||||
->toContain('NewsArticle');
|
||||
|
||||
$this->assertStringNotContainsString('veraltet', $text);
|
||||
});
|
||||
|
||||
test('the hub serves llms.txt that points to both portals', function () {
|
||||
/** @var TestCase $this */
|
||||
$text = (string) $this->get('https://pressekonto.test/llms.txt')->assertSuccessful()->getContent();
|
||||
|
||||
expect($text)
|
||||
->toStartWith("# pressekonto\n\n> ")
|
||||
->toContain('https://presseecho.test/llms.txt')
|
||||
->toContain('https://businessportal24.test/llms.txt')
|
||||
->toContain('https://pressekonto.test/docs/api/v1');
|
||||
|
||||
$this->assertStringNotContainsString('press-release/{slug}', $text);
|
||||
});
|
||||
74
tests/Feature/Web/NewsSitemapTest.php
Normal file
74
tests/Feature/Web/NewsSitemapTest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Support\WebCaches;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Google-News-Sitemap je Spoke (Roadmap 2.2): nur Meldungen der letzten
|
||||
* 48 Stunden, mit Publikationsname und Sprache.
|
||||
*/
|
||||
function newsSitemapRelease(Portal $portal, string $slug, array $attributes = []): PressRelease
|
||||
{
|
||||
return PressRelease::factory()
|
||||
->published()
|
||||
->forPortal($portal)
|
||||
->for(Category::factory()->create(['portal' => $portal]))
|
||||
->for(Company::factory()->businessportal24()->create())
|
||||
->create(['slug' => $slug, ...$attributes]);
|
||||
}
|
||||
|
||||
test('the news sitemap lists only releases of the last 48 hours of the own portal', function () {
|
||||
/** @var TestCase $this */
|
||||
newsSitemapRelease(Portal::Businessportal24, 'frisch', ['title' => 'Frische Meldung & mehr', 'published_at' => now()->subHours(3)]);
|
||||
newsSitemapRelease(Portal::Both, 'beide-portale', ['published_at' => now()->subHours(20)]);
|
||||
newsSitemapRelease(Portal::Businessportal24, 'zu-alt', ['published_at' => now()->subDays(3)]);
|
||||
newsSitemapRelease(Portal::Presseecho, 'fremdes-portal', ['published_at' => now()->subHour()]);
|
||||
newsSitemapRelease(Portal::Businessportal24, 'terminiert', ['published_at' => now()->addHour()]);
|
||||
|
||||
$response = $this->get('https://businessportal24.test/sitemap-news.xml')->assertSuccessful();
|
||||
|
||||
expect($response->headers->get('Content-Type'))->toContain('application/xml');
|
||||
|
||||
$xml = (string) $response->getContent();
|
||||
expect($xml)
|
||||
->toContain('xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"')
|
||||
->toContain('<loc>https://businessportal24.test/de/press-release/frisch</loc>')
|
||||
->toContain('<news:name>businessportal24</news:name>')
|
||||
->toContain('<news:language>de</news:language>')
|
||||
->toContain('<news:title>Frische Meldung & mehr</news:title>')
|
||||
->toContain('<loc>https://businessportal24.test/de/press-release/beide-portale</loc>');
|
||||
|
||||
$this->assertStringNotContainsString('zu-alt', $xml);
|
||||
$this->assertStringNotContainsString('fremdes-portal', $xml);
|
||||
$this->assertStringNotContainsString('terminiert', $xml);
|
||||
});
|
||||
|
||||
test('the hub serves an empty news sitemap and does not advertise it in robots.txt', function () {
|
||||
/** @var TestCase $this */
|
||||
newsSitemapRelease(Portal::Presseecho, 'nicht-im-hub', ['published_at' => now()->subHour()]);
|
||||
|
||||
$xml = (string) $this->get('https://pressekonto.test/sitemap-news.xml')->assertSuccessful()->getContent();
|
||||
expect($xml)->toContain('<urlset');
|
||||
$this->assertStringNotContainsString('<url>', $xml);
|
||||
|
||||
$robots = (string) $this->get('https://pressekonto.test/robots.txt')->getContent();
|
||||
$this->assertStringNotContainsString('sitemap-news.xml', $robots);
|
||||
|
||||
$this->get('https://presseecho.test/robots.txt')
|
||||
->assertSee('Sitemap: https://presseecho.test/sitemap-news.xml', false);
|
||||
});
|
||||
|
||||
test('the news sitemap is cached per host and cleared with the other sitemaps', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->get('https://presseecho.test/sitemap-news.xml')->assertSuccessful();
|
||||
expect(Cache::has('web.sitemap-news.presseecho.test'))->toBeTrue();
|
||||
|
||||
WebCaches::forgetSitemaps();
|
||||
|
||||
expect(Cache::has('web.sitemap-news.presseecho.test'))->toBeFalse();
|
||||
});
|
||||
|
|
@ -38,8 +38,10 @@ test('the release detail page emits NewsArticle and BreadcrumbList JSON-LD', fun
|
|||
->assertSee('"@type":"NewsArticle"', false)
|
||||
->assertSee('"headline":"Strukturierte Daten für Pressemitteilungen"', false)
|
||||
->assertSee('"datePublished"', false)
|
||||
->assertSee('"publisher":{"@type":"Organization","name":"businessportal24"', false)
|
||||
->assertSee('"author":{"@type":"Organization","name":"Muster GmbH"', false)
|
||||
->assertSee('"publisher":{"@type":"Organization","@id":"https://businessportal24.test/#organization","name":"businessportal24"', false)
|
||||
->assertSee('"logo":{"@type":"ImageObject","url":"https://businessportal24.test/images/businessportal-logo.svg"', false)
|
||||
->assertSee('"author":{"@type":"Organization","@id":"https://businessportal24.test/de/newsroom/', false)
|
||||
->assertSee('#organization","name":"Muster GmbH"', false)
|
||||
->assertSee('"@type":"BreadcrumbList"', false)
|
||||
->assertSee('"articleSection":"Technologie"', false);
|
||||
});
|
||||
|
|
@ -77,7 +79,9 @@ test('a portal homepage emits WebSite JSON-LD with a SearchAction', function ()
|
|||
->assertSuccessful()
|
||||
->assertSee('"@type":"WebSite"', false)
|
||||
->assertSee('"@type":"SearchAction"', false)
|
||||
->assertSee('https://presseecho.test/de/suche?q={search_term_string}', false);
|
||||
->assertSee('https://presseecho.test/de/suche?q={search_term_string}', false)
|
||||
->assertSee('"@id":"https://presseecho.test/#organization"', false)
|
||||
->assertSee('"url":"https://presseecho.test/images/presseecho-logo.svg"', false);
|
||||
});
|
||||
|
||||
test('the newsroom page emits Organization JSON-LD for the company', function () {
|
||||
|
|
@ -100,6 +104,7 @@ test('the newsroom page emits Organization JSON-LD for the company', function ()
|
|||
$this->get('https://businessportal24.test/de/newsroom/'.$company->slug)
|
||||
->assertSuccessful()
|
||||
->assertSee('"@type":"Organization"', false)
|
||||
->assertSee('"@id":"https://businessportal24.test/de/newsroom/'.$company->slug.'#organization"', false)
|
||||
->assertSee('"name":"Newsroom AG"', false)
|
||||
->assertSee('"sameAs":["https://newsroom-ag.example"]', false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue