.
* Why: avoids coupling tests to HTML comments that minification may strip.
*/
function extractCardByHeading(html, headingText) {
const headingMatch = new RegExp(`
`, 'i').exec(html);
if (!headingMatch) {
return undefined;
}
let cardStart = -1;
for (const match of html.matchAll(/
]*class="[^"]*\brounded-2xl\b[^"]*"[^>]*>/gi)) {
if (match.index > headingMatch.index) {
break;
}
cardStart = match.index;
}
if (cardStart === -1) {
return undefined;
}
let depth = 0;
for (const tagMatch of html.matchAll(/<\/?div\b[^>]*>/gi)) {
if (tagMatch.index < cardStart) {
continue;
}
depth += tagMatch[0].startsWith('') ? -1 : 1;
if (depth === 0) {
return html.slice(cardStart, tagMatch.index + tagMatch[0].length);
}
}
return undefined;
}
test('Slice 3 Acceptance Criteria: 5-Card Catalog, Brand Tokens & Complementary Paths', async (t) => {
await t.test(
'Criterion 1: Brand System Integrity (Google Fonts loaded, Tailwind @theme color tokens)',
() => {
// 1. Google Fonts loaded in index.html
assert.match(
indexHtml,
/fonts\.googleapis\.com\/css2\?[^"]*family=Playfair\+Display/i,
'index.html must load Playfair Display from Google Fonts',
);
assert.match(
indexHtml,
/fonts\.googleapis\.com\/css2\?[^"]*family=Cormorant\+Garamond/i,
'index.html must load Cormorant Garamond from Google Fonts',
);
assert.match(
indexHtml,
/fonts\.googleapis\.com\/css2\?[^"]*family=Raleway/i,
'index.html must load Raleway from Google Fonts',
);
// 2. Custom color tokens in src/style.css @theme
assert.match(
styleCss,
/--color-porcelain-mist:\s*#f4f1ea/i,
'src/style.css must define --color-porcelain-mist: #f4f1ea in @theme',
);
assert.match(
styleCss,
/--color-gris-oscuro:\s*#303030/i,
'src/style.css must define --color-gris-oscuro: #303030 in @theme',
);
// 3. Typography mappings in @theme
assert.match(
styleCss,
/Playfair Display/i,
'src/style.css must reference Playfair Display for headings',
);
assert.match(
styleCss,
/Cormorant Garamond/i,
'src/style.css must reference Cormorant Garamond for card headings',
);
assert.match(styleCss, /Raleway/i, 'src/style.css must reference Raleway for body/ui');
},
);
await t.test(
'Criterion 2: Hero & Header Polish (contrast wash, clean subtitle hook, enlarged quote text-sm/md/lg)',
() => {
// 1. Sticky Navigation Bar with WCAG-legible ivory wash
// Why: Issue #11 replaces the low-contrast green tint wash with bg-ivory/95 for dark link legibility.
const headerMatch = indexHtml.match(/
]*class="([^"]*)"/i);
assert.ok(headerMatch, 'Header must exist with class attribute');
const headerClasses = headerMatch[1];
assert.match(headerClasses, /sticky/i, 'Header must be sticky');
assert.match(
headerClasses,
/bg-ivory\/95/i,
'Header must use WCAG-legible ivory wash (bg-ivory/95)',
);
assert.match(headerClasses, /backdrop-blur/i, 'Header must retain backdrop-blur');
assert.match(headerClasses, /border-b/i, 'Header must have border-b');
// 2. Hero Subtitle single clean hook
const heroSection = indexHtml.match(//)?.[0];
assert.ok(heroSection, 'Hero section must exist');
const expectedHeroHook =
'Un respiro consciente frente al parloteo mental y la fatiga del sistema nervioso para abrir tu corazón a tu propia medicina interna.';
assert.ok(
heroSection.includes(expectedHeroHook),
'Hero must include approved single clean subtitle hook',
);
assert.ok(
!heroSection.includes('Acompañamiento integral para habitar tu cuerpo sin dolor'),
'Hero must not contain dense multi-service copy (moved to Section 03)',
);
// 3. Quote Caption scale (desktop enlarged md:text-base/lg:text-lg, mobile text-sm without text-xs)
const quoteBlock = heroSection.match(/