feat: adicionar cadência editorial à home

This commit is contained in:
2026-08-06 14:33:15 -03:00
parent 0aee15e848
commit 75ab0b0ff5
18 changed files with 302 additions and 35 deletions

View File

@@ -197,4 +197,65 @@ class HomePageContentTest extends TestCase
->assertDontSee('href="#testimonials-heading"', false)
->assertDontSee('Relato vazio');
}
public function test_home_folios_follow_rendered_chapter_order_and_hide_decorative_numbers(): void
{
SiteSetting::instance();
Service::factory()->published()->featured()->create();
PortfolioCase::factory()->published()->create(['is_featured' => true]);
Testimonial::factory()->published()->create(['quote' => 'Relato publicado.']);
$html = $this->get(route('home'))->assertOk()->getContent();
$this->assertSame([
'Capa',
'Manifesto',
'Serviços',
'Portfólio',
'Método',
'Depoimentos',
'A Amare',
'Próximo passo',
], $this->folioLabels((string) $html));
$this->assertSame(8, preg_match_all('/data-home-folio-number[^>]*aria-hidden="true"/i', (string) $html));
$this->assertSame(1, preg_match_all('/<h1\b/i', (string) $html));
$css = (string) file_get_contents(resource_path('css/app.css'));
$this->assertStringContainsString('counter-reset: home-chapter -1', $css);
$this->assertStringContainsString('counter-increment: home-chapter', $css);
$this->assertStringContainsString('counter(home-chapter, decimal-leading-zero)', $css);
}
public function test_home_folios_are_omitted_with_conditional_chapters_without_leaving_markup_gaps(): void
{
SiteSetting::instance();
$html = $this->get(route('home'))->assertOk()->getContent();
$this->assertSame([
'Capa',
'Manifesto',
'Método',
'A Amare',
'Próximo passo',
], $this->folioLabels((string) $html));
$this->assertSame(5, preg_match_all('/data-home-folio-number[^>]*aria-hidden="true"/i', (string) $html));
}
/** @return list<string> */
private function folioLabels(string $html): array
{
preg_match_all(
'/<span\b[^>]*data-home-folio-label[^>]*>\s*([^<]+?)\s*<\/span>/is',
$html,
$matches,
);
return array_values(array_map(
static fn (string $label): string => trim(html_entity_decode($label)),
$matches[1],
));
}
}