Publish CMS content on public routes with responsive media, accessibility checks, and deterministic visual baselines. 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);
|
|
}
|
|
}
|