Files
amare/tests/Feature/PublicSite/MotionMarkupTest.php
manoel freitas b54908541f feat: add Dossiê vivo motion to the public site
Introduce a focal Home opening, chapter index, and restrained continuity
reveals while keeping reduced-motion and visual baselines intact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 19:40:40 -03:00

133 lines
5.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\PublicSite;
use App\Models\PortfolioCase;
use App\Models\Service;
use App\Models\SiteSetting;
use App\Models\Testimonial;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class MotionMarkupTest extends TestCase
{
use RefreshDatabase;
public function test_home_exposes_focal_hero_hooks_and_chapter_index_links(): void
{
$settings = SiteSetting::instance();
$settings->update([
'hero_title' => 'Celebrações com propósito',
'default_og_image_path' => 'media/hero.jpg',
'default_og_image_alt' => 'Capa editorial',
]);
Service::factory()->published()->featured()->create(['title' => 'Casamentos']);
PortfolioCase::factory()->published()->create([
'title' => 'Caso A',
'is_featured' => true,
]);
Testimonial::factory()->published()->create(['author_name' => 'Ana']);
$response = $this->get(route('home'));
$response
->assertOk()
->assertSee('data-motion="dossie-hero"', false)
->assertSee('data-motion-beat="seal"', false)
->assertSee('data-motion-beat="title"', false)
->assertSee('data-motion-beat="media"', false)
->assertSee('data-motion-beat="cta"', false)
->assertSee('data-chapter-index', false)
->assertSee('data-chapter-progress', false)
->assertSee('href="#hero-heading"', false)
->assertSee('href="#manifesto-heading"', false)
->assertSee('href="#services-heading"', false)
->assertSee('href="#portfolio-heading"', false)
->assertSee('href="#method-heading"', false)
->assertSee('href="#testimonials-heading"', false)
->assertSee('href="#positioning-heading"', false)
->assertSee('href="#final-cta-heading"', false)
->assertSee('data-chapter="hero"', false)
->assertSee('data-chapter="manifesto"', false)
->assertSee('data-reveal', false);
}
public function test_chapter_index_omits_empty_cms_sections(): void
{
SiteSetting::instance();
$response = $this->get(route('home'));
$response
->assertOk()
->assertSee('data-chapter-index', false)
->assertSee('href="#hero-heading"', false)
->assertSee('href="#manifesto-heading"', false)
->assertSee('href="#method-heading"', false)
->assertSee('href="#positioning-heading"', false)
->assertSee('href="#final-cta-heading"', false)
->assertDontSee('href="#services-heading"', false)
->assertDontSee('href="#portfolio-heading"', false)
->assertDontSee('href="#testimonials-heading"', false)
->assertDontSee('id="services-heading"', false)
->assertDontSee('id="portfolio-heading"', false)
->assertDontSee('id="testimonials-heading"', false);
}
public function test_motion_tokens_and_runtime_exist_with_reduced_motion_guards(): void
{
$tokens = (string) file_get_contents(resource_path('css/tokens.css'));
$appCss = (string) file_get_contents(resource_path('css/app.css'));
$appJs = (string) file_get_contents(resource_path('js/app.js'));
$this->assertStringContainsString('--amare-duration-focal:', $tokens);
$this->assertStringContainsString('--amare-ease-arrival:', $tokens);
$this->assertStringContainsString('--amare-duration-focal: 0.01ms', $tokens);
$this->assertStringContainsString('[data-motion="dossie-hero"]', $appCss);
$this->assertStringContainsString('[data-reveal]', $appCss);
$this->assertStringContainsString('[data-chapter-index]', $appCss);
$this->assertStringContainsString('prefers-reduced-motion: no-preference', $appCss);
$this->assertFileExists(resource_path('js/motion.js'));
$this->assertStringContainsString("import './motion.js'", $appJs);
$this->assertStringContainsString('prefers-reduced-motion', (string) file_get_contents(resource_path('js/motion.js')));
}
public function test_internal_pages_expose_shared_page_open_hook(): void
{
SiteSetting::instance();
$case = PortfolioCase::factory()->published()->create([
'slug' => 'casamento-jardim',
'title' => 'Casamento Jardim',
]);
$this->get(route('services.index'))
->assertOk()
->assertSee('data-motion="page-open"', false);
$this->get(route('portfolio.index'))
->assertOk()
->assertSee('data-motion="page-open"', false);
$this->get(route('portfolio.show', $case->slug))
->assertOk()
->assertSee('data-motion="page-open"', false);
$this->get(route('about'))
->assertOk()
->assertSee('data-motion="page-open"', false);
$this->get(route('contact'))
->assertOk()
->assertDontSee('data-motion="page-open"', false);
$this->get(route('privacy'))
->assertOk()
->assertDontSee('data-motion="page-open"', false);
}
}