Files
amare/tests/Feature/PublicSite/PublicPagesTest.php
Manoel Freitas cf1589c916 feat: recreate public frontend with Heritage Editorial identity (#5)
* feat: recreate public frontend with Heritage Editorial identity

Replace placeholder visual system with EB Garamond/olive tokens, brand assets, editorial home narrative, São Paulo settings, real testimonials, and regenerated visual baselines.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: archive recreate-public-frontend and sync Heritage Editorial specs

Merge delta requirements into main OpenSpec capabilities and move the completed change into the dated archive.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 23:39:00 -03:00

198 lines
6.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\PublicSite;
use App\Models\PortfolioCase;
use App\Models\PortfolioImage;
use App\Models\Service;
use App\Models\SiteSetting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Tests\TestCase;
class PublicPagesTest extends TestCase
{
use RefreshDatabase;
public function test_services_index_lists_published_services_in_sort_order(): void
{
SiteSetting::instance();
Service::factory()->create(['title' => 'Rascunho', 'published_at' => null]);
Service::factory()->published()->create(['title' => 'Serviço B', 'sort_order' => 20]);
Service::factory()->published()->create(['title' => 'Serviço A', 'sort_order' => 10]);
$this->get(route('services.index'))
->assertOk()
->assertSeeInOrder(['Serviço A', 'Serviço B'])
->assertDontSee('Rascunho');
}
public function test_portfolio_index_paginates_and_excludes_drafts(): void
{
SiteSetting::instance();
PortfolioCase::factory()->create(['title' => 'Rascunho', 'published_at' => null]);
foreach (range(1, 10) as $index) {
PortfolioCase::factory()->published()->create([
'title' => 'Caso '.$index,
'slug' => 'caso-pagina-'.$index,
'sort_order' => $index,
]);
}
$this->assertSame(10, PortfolioCase::query()->published()->count());
$this->get(route('portfolio.index'))
->assertOk()
->assertSee('>Caso 1</', false)
->assertSee('>Caso 9</', false)
->assertDontSee('>Caso 10</', false)
->assertDontSee('Rascunho');
$this->get(route('portfolio.index', ['page' => 2]))
->assertOk()
->assertSee('>Caso 10</', false)
->assertDontSee('>Caso 9</', false);
}
public function test_portfolio_show_renders_published_case_gallery_order_and_404_for_draft(): void
{
SiteSetting::instance();
$published = PortfolioCase::factory()->published()->create([
'slug' => 'casamento-jardim',
'title' => 'Casamento Jardim',
'challenge' => 'Desafio do caso',
'solution' => 'Solução do caso',
'result' => 'Resultado do caso',
]);
PortfolioImage::query()->create([
'portfolio_case_id' => $published->id,
'path' => 'content/gallery-b.jpg',
'alt_text' => 'Imagem B',
'caption' => null,
'sort_order' => 2,
]);
PortfolioImage::query()->create([
'portfolio_case_id' => $published->id,
'path' => 'content/gallery-a.jpg',
'alt_text' => 'Imagem A',
'caption' => null,
'sort_order' => 1,
]);
PortfolioCase::factory()->create([
'slug' => 'rascunho',
'published_at' => null,
]);
$this->get(route('portfolio.show', 'casamento-jardim'))
->assertOk()
->assertSee('Casamento Jardim')
->assertSee('Desafio do caso')
->assertSee('Solução do caso')
->assertSee('Resultado do caso')
->assertSeeInOrder(['Imagem A', 'Imagem B']);
$this->get(route('portfolio.show', 'rascunho'))->assertNotFound();
}
public function test_about_privacy_and_contact_use_site_settings_without_creating_leads(): void
{
$settings = SiteSetting::instance();
$settings->update([
'about_summary' => 'Sobre a Amare boutique',
'email' => 'amareassessoriaeventos@gmail.com',
'phone' => '(11) 90000-0000',
'city' => 'São Paulo - SP',
'social_links' => ['instagram' => 'https://instagram.com/amare'],
]);
$this->get(route('about'))
->assertOk()
->assertSee('Sobre a Amare boutique')
->assertSee('São Paulo - SP')
->assertDontSee('Fortaleza')
->assertSee('min-h-[calc(100dvh-14rem)]', false);
$this->get(route('privacy'))
->assertOk()
->assertSee('Política de privacidade')
->assertSee('amareassessoriaeventos@gmail.com');
$this->get(route('contact'))
->assertOk()
->assertSee('amareassessoriaeventos@gmail.com')
->assertSee('(11) 90000-0000')
->assertSee('São Paulo - SP')
->assertDontSee('Fortaleza')
->assertSee('https://instagram.com/amare', false)
->assertSee('min-h-[calc(100dvh-14rem)]', false)
->assertDontSee('<form', false)
->assertDontSee('</form>', false);
}
public function test_site_setting_defaults_use_sao_paulo_and_official_email(): void
{
$settings = SiteSetting::instance();
$this->assertSame('São Paulo - SP', $settings->city);
$this->assertSame('amareassessoriaeventos@gmail.com', $settings->email);
$this->assertStringNotContainsStringIgnoringCase('Fortaleza', (string) $settings->city);
}
public function test_branded_404_and_500_without_stack_trace_when_debug_disabled(): void
{
SiteSetting::instance();
$this->get('/rota-inexistente-amare')
->assertNotFound()
->assertSee('Página não encontrada')
->assertSee('Voltar para a home');
Route::get('/__test-server-error', function (): never {
throw new \RuntimeException('segredo-interno-amare');
});
config(['app.debug' => false]);
$response = $this->get('/__test-server-error');
$response
->assertStatus(500)
->assertSee('Algo deu errado')
->assertDontSee('segredo-interno-amare')
->assertDontSee('RuntimeException');
}
public function test_portfolio_show_avoids_n_plus_one_on_gallery(): void
{
SiteSetting::instance();
$case = PortfolioCase::factory()->published()->create(['slug' => 'caso-n1']);
foreach (range(1, 8) as $order) {
PortfolioImage::query()->create([
'portfolio_case_id' => $case->id,
'path' => "content/gallery-{$order}.jpg",
'alt_text' => "Imagem {$order}",
'caption' => null,
'sort_order' => $order,
]);
}
DB::enableQueryLog();
$this->get(route('portfolio.show', 'caso-n1'))->assertOk();
$queryCount = count(DB::getQueryLog());
DB::disableQueryLog();
$this->assertLessThan(15, $queryCount);
}
}