* feat: ship public site with SEO and visuals Publish CMS content on public routes with responsive media, accessibility checks, and deterministic visual baselines. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: make browser visual CI deterministic for media Mount host public storage into FrankenPHP so seeded fixtures are served, and replace PNG-as-JPG fixtures with real JPEGs so Chromium can render them. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: serve public media on same-origin storage paths Pest Browser hosts on 127.0.0.1:port while Storage::url used http://localhost, so screenshots captured broken images. Use relative /storage URLs for media and absolutize only OG tags via url(). Co-authored-by: Cursor <cursoragent@cursor.com> * test: refresh visual baselines from CI Ubuntu screenshots Media now loads on same-origin /storage paths, so baselines must capture the rendered fixtures. Use full-page snapshots from the CI runner to keep Pest's exact snapshot match stable across environments. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
102 lines
3.5 KiB
PHP
102 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\PublicSite;
|
|
|
|
use App\Models\PortfolioCase;
|
|
use App\Models\SiteSetting;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Tests\TestCase;
|
|
|
|
class PageMetaRenderingTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_case_meta_overrides_appear_in_rendered_head(): void
|
|
{
|
|
Storage::fake('public');
|
|
|
|
SiteSetting::instance()->update([
|
|
'default_meta_title' => 'Default Title',
|
|
'default_meta_description' => 'Default Description',
|
|
'default_og_image_path' => 'og/default.jpg',
|
|
'default_og_image_alt' => 'Default alt',
|
|
]);
|
|
|
|
$case = PortfolioCase::factory()->published()->create([
|
|
'slug' => 'casamento-jardim',
|
|
'title' => 'Casamento Jardim',
|
|
'summary' => 'Resumo do caso',
|
|
'meta_title' => 'Meta do Casamento',
|
|
'meta_description' => 'Descrição SEO do casamento',
|
|
'cover_image_path' => 'cases/cover.jpg',
|
|
'cover_image_alt' => 'Capa do casamento',
|
|
]);
|
|
|
|
$canonical = route('portfolio.show', $case->slug);
|
|
|
|
$this->get($canonical)
|
|
->assertOk()
|
|
->assertSee('<title>Meta do Casamento</title>', false)
|
|
->assertSee('content="Descrição SEO do casamento"', false)
|
|
->assertSee('href="'.$canonical.'"', false)
|
|
->assertSee('content="article"', false)
|
|
->assertSee(Storage::disk('public')->url('cases/cover.jpg'), false)
|
|
->assertSee('content="Capa do casamento"', false);
|
|
}
|
|
|
|
public function test_case_without_meta_falls_back_to_title_summary_and_site_og(): void
|
|
{
|
|
Storage::fake('public');
|
|
|
|
SiteSetting::instance()->update([
|
|
'default_meta_title' => 'Default Title',
|
|
'default_meta_description' => 'Default Description',
|
|
'default_og_image_path' => 'og/default.jpg',
|
|
'default_og_image_alt' => 'Default alt',
|
|
]);
|
|
|
|
$case = PortfolioCase::factory()->published()->create([
|
|
'slug' => 'casamento-praia',
|
|
'title' => 'Casamento Praia',
|
|
'summary' => 'Resumo praia',
|
|
'meta_title' => null,
|
|
'meta_description' => null,
|
|
'cover_image_path' => '',
|
|
'cover_image_alt' => '',
|
|
]);
|
|
|
|
$canonical = route('portfolio.show', $case->slug);
|
|
|
|
$this->get($canonical)
|
|
->assertOk()
|
|
->assertSee('<title>Casamento Praia</title>', false)
|
|
->assertSee('content="Resumo praia"', false)
|
|
->assertSee('href="'.$canonical.'"', false)
|
|
->assertSee(Storage::disk('public')->url('og/default.jpg'), false)
|
|
->assertSee('content="Default alt"', false);
|
|
}
|
|
|
|
public function test_institutional_page_falls_back_to_site_defaults_when_no_page_title_override_needed(): void
|
|
{
|
|
Storage::fake('public');
|
|
|
|
SiteSetting::instance()->update([
|
|
'default_meta_title' => 'Amare Assessoria de Eventos',
|
|
'default_meta_description' => 'Assessoria premium.',
|
|
'default_og_image_path' => 'og/default.jpg',
|
|
]);
|
|
|
|
$canonical = route('home');
|
|
|
|
$this->get($canonical)
|
|
->assertOk()
|
|
->assertSee('<title>Amare Assessoria de Eventos</title>', false)
|
|
->assertSee('content="Assessoria premium."', false)
|
|
->assertSee('href="'.$canonical.'"', false)
|
|
->assertSee(Storage::disk('public')->url('og/default.jpg'), false);
|
|
}
|
|
}
|