Files
amare/tests/Feature/PublicSite/PublicPagesTest.php
manoel freitas fc1c6177d6
All checks were successful
CI / static (push) Successful in 2m21s
CI / unit (push) Successful in 3m17s
CI / feature (push) Successful in 2m29s
CI / container (push) Successful in 18s
CI / browser (push) Successful in 3m8s
feat: remodelar /sobre conforme mock editorial
Co-authored-by: manoel freitas <manoel.josefneto@gmail.com>
Co-committed-by: manoel freitas <manoel.josefneto@gmail.com>
2026-08-12 20:34:13 +00:00

311 lines
11 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\PublicSite;
use App\Models\PortfolioCase;
use App\Models\PortfolioImage;
use App\Models\SiteSetting;
use App\Models\WeddingPackage;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Tests\TestCase;
class PublicPagesTest extends TestCase
{
use RefreshDatabase;
public function test_services_index_renders_editorial_sections_with_published_modalities_only(): void
{
SiteSetting::instance();
WeddingPackage::factory()->create(['name' => 'Rascunho', 'published_at' => null]);
WeddingPackage::factory()->published()->create([
'name' => 'Essenza',
'level' => '01 / COMPLETA',
'tag' => 'Assessoria completa',
'subtitle' => 'Do planejamento ao grande dia.',
'summary' => 'Para casais que desejam contar com a Amare desde o início.',
'scope_items' => ['Estruturação do planejamento', 'Coordenação da execução'],
'cta_label' => 'Quero conhecer a Essenza',
'compare_heading' => 'Começar com a Amare',
'compare_summary' => 'Acompanhamento mais amplo ao longo do planejamento.',
'sort_order' => 10,
]);
$this->get(route('services.index'))
->assertOk()
->assertSee('O cuidado certo para cada tipo de evento.')
->assertSee('Conhecer os serviços')
->assertSee('Tenho um evento em mente')
->assertSee('Duas vertentes')
->assertSee('Escolha por contexto, não por uma lista de pacotes.')
->assertSee('Amare Casamentos')
->assertSee('Acompanhamento para diferentes momentos do planejamento.')
->assertSee('Amare Corporate')
->assertSee('Planejamento e execução para eventos empresariais.')
->assertSee('Três formas de ter a Amare ao lado.')
->assertSee('Assessoria completa')
->assertSee('Essenza')
->assertSee('Do planejamento ao grande dia.')
->assertSee('Quero conhecer a Essenza')
->assertSee('Começar com a Amare')
->assertSee('Organização, produção e condução com linguagem empresarial.')
->assertSee('Estruturação do evento, escopo, prioridades e cronograma.')
->assertSee('Falar sobre um evento Corporate')
->assertSee('Do casamento ao evento corporativo, tudo começa com uma boa conversa.')
->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_portfolio_surfaces_expose_editorial_composition_without_changing_content_order(): void
{
SiteSetting::instance();
$firstCase = PortfolioCase::factory()->published()->create([
'title' => 'Primeiro caso',
'slug' => 'primeiro-caso-editorial',
'cover_image_path' => 'content/cases/primeiro.jpg',
'is_featured' => true,
'sort_order' => 10,
]);
PortfolioCase::factory()->published()->create([
'title' => 'Segundo caso',
'slug' => 'segundo-caso-editorial',
'cover_image_path' => 'content/cases/segundo.jpg',
'is_featured' => true,
'sort_order' => 20,
]);
PortfolioImage::query()->create([
'portfolio_case_id' => $firstCase->id,
'path' => 'content/gallery-primeira.jpg',
'alt_text' => 'Primeira imagem',
'sort_order' => 10,
]);
PortfolioImage::query()->create([
'portfolio_case_id' => $firstCase->id,
'path' => 'content/gallery-segunda.jpg',
'alt_text' => 'Segunda imagem',
'sort_order' => 20,
]);
$home = $this->get(route('home'));
$portfolio = $this->get(route('portfolio.index'));
$detail = $this->get(route('portfolio.show', $firstCase->slug));
$home
->assertOk()
->assertSee('data-editorial-portfolio', false)
->assertSee('data-editorial-portfolio-item="feature"', false);
$portfolio
->assertOk()
->assertSee('data-editorial-portfolio-grid', false)
->assertSeeInOrder(['Primeiro caso', 'Segundo caso']);
$detail
->assertOk()
->assertSee('data-editorial-gallery', false)
->assertSeeInOrder(['Primeira imagem', 'Segunda imagem']);
}
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('Sobre a Amare')
->assertSee('Conheça Michele')
->assertDontSee('Fortaleza')
->assertSee('data-tonal-hero', false)
->assertSee('data-about-hero', 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('São Paulo - SP')
->assertDontSee('Fortaleza')
->assertSee('https://instagram.com/amare', false)
->assertSee('Fornecedores e parcerias')
->assertSee('<form', false)
->assertSee('name="nome"', false)
->assertSee('name="atuacao"', false)
->assertDontSee('name="tipo_evento"', false)
->assertSee(route('privacy'), false);
$this->get(route('briefing'))
->assertOk()
->assertSee('min-h-[calc(100dvh-14rem)]', false)
->assertSee('name="tipo_evento"', false)
->assertSee('name="privacidade"', 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
{
config(['cache.default' => 'array']);
Cache::store('array')->flush();
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);
}
public function test_case_without_event_type_does_not_render_empty_eyebrow(): void
{
SiteSetting::instance();
$case = PortfolioCase::factory()->published()->create([
'slug' => 'caso-sem-tipo',
'title' => 'Caso Sem Tipo',
'event_type' => '',
]);
$response = $this->get(route('portfolio.show', $case->slug));
$response->assertOk()->assertSee('Caso Sem Tipo');
$emptyAccentParagraphs = preg_match_all(
'/class="[^"]*text-amare-accent[^"]*"><\/p>/',
(string) $response->getContent(),
);
expect($emptyAccentParagraphs)->toBe(0);
}
}