import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import test from 'node:test'; const VOLVER_A_TI_PATH = 'dist/volver-a-ti/index.html'; function readVolverATiHtml() { const resolved = path.resolve(VOLVER_A_TI_PATH); assert.ok(fs.existsSync(resolved), `${VOLVER_A_TI_PATH} must exist after build`); return fs.readFileSync(resolved, 'utf-8'); } function extractMain(html) { const match = html.match(/]*\bid="main"[^>]*>([\s\S]*?)<\/main>/i); assert.ok(match, `${VOLVER_A_TI_PATH} must contain
`); return match[1]; } function extractSections(mainHtml) { return [...mainHtml.matchAll(/]*>[\s\S]*?<\/section>/gi)].map((m) => m[0]); } function getAttr(tagHtml, attrName) { const match = tagHtml.match(new RegExp(`\\b${attrName}="([^"]*)"`, 'i')); return match ? match[1] : ''; } test('Issue #13 Acceptance Criteria: Volver a ti visual rhythm, layout, and CTA balance', async (t) => { const html = readVolverATiHtml(); const mainHtml = extractMain(html); const sections = extractSections(mainHtml); await t.test( 'Criterion 1: Hero image uses asymmetric organic rounding and appears before prose in DOM with md:order- desktop swap', () => { const heroSection = sections.find((section) => section.includes('volver-a-ti-hero.webp')); assert.ok(heroSection, 'Hero
containing volver-a-ti-hero.webp must exist'); // Why: asymmetric organic corners soften the portrait frame without looking like a generic rounded card. const imgWrapperMatch = heroSection.match( /]*)>\s*]*src="[^"]*volver-a-ti-hero\.webp"[^>]*>/i, ); assert.ok(imgWrapperMatch, 'Hero image must be wrapped in a
container'); const wrapperClass = getAttr(`
`, 'class'); for (const cls of [ 'rounded-tl-[3rem]', 'rounded-br-[3rem]', 'rounded-tr-xl', 'rounded-bl-xl', ]) { assert.ok( wrapperClass.split(/\s+/).includes(cls), `Hero image wrapper must include organic rounding class "${cls}", got "${wrapperClass}"`, ); } // Why: mobile (<768px) stacks in DOM order, so the hero image must precede the intro prose in HTML. const imgPos = heroSection.indexOf('volver-a-ti-hero.webp'); const prosePos = heroSection.indexOf( 'A veces sabemos que algo en nuestra vida necesita cambiar', ); assert.ok(prosePos !== -1, 'Hero section must contain intro prose'); assert.ok( imgPos < prosePos, 'volver-a-ti-hero.webp must appear BEFORE intro prose in DOM order for mobile-first stacking', ); // Why: desktop (>=768px) swaps visual order via md:order-* so prose stays left and image stays right. const heroColumns = [...heroSection.matchAll(/]*\bmd:col-span-6\b[^>]*>/gi)].map( (m) => m[0], ); assert.equal(heroColumns.length, 2, 'Hero grid must have 2 md:col-span-6 columns'); const firstColClass = getAttr(heroColumns[0], 'class'); const secondColClass = getAttr(heroColumns[1], 'class'); assert.match( firstColClass, /\bmd:order-(?:2|last)\b/, `First DOM hero column (image) must use md:order-2/last for desktop right placement, got "${firstColClass}"`, ); assert.match( secondColClass, /\bmd:order-(?:1|first)\b/, `Second DOM hero column (prose) must use md:order-1/first for desktop left placement, got "${secondColClass}"`, ); }, ); await t.test( 'Criterion 2: Philosophy pull-quote removes white bordered card, centers in max-w-2xl, and styles closing line with italic + gold border-y', () => { const targetHeading = 'Un camino que se construye desde tu propia experiencia'; const philosophyIdx = mainHtml.indexOf(targetHeading); assert.ok(philosophyIdx !== -1, `Page must contain "${targetHeading}"`); const sectionEnd = mainHtml.indexOf('
', philosophyIdx); const blockStart = mainHtml.lastIndexOf(']*)>\s*(?:]*)>\s*)?]*>\s*Un camino que se construye desde tu propia experiencia/i, ); assert.ok(containerMatch, 'Could not locate container(s) wrapping the philosophy heading'); const outerClasses = getAttr(`
`, 'class'); const innerClasses = containerMatch[2] ? getAttr(`
`, 'class') : ''; const combinedClasses = `${outerClasses} ${innerClasses}`; assert.match( combinedClasses, /\bmax-w-2xl\b/, `Philosophy block must be centered in max-w-2xl, got "${combinedClasses}"`, ); assert.doesNotMatch( combinedClasses, /\bbg-white\/75\b/, 'Philosophy block must not be wrapped in a bg-white/75 card', ); assert.doesNotMatch( combinedClasses, /\bborder-sage\/30\b/, 'Philosophy block must not be wrapped in a border-sage/30 card', ); const closingQuoteMatch = philosophyChunk.match( /<(blockquote|p)\b([^>]*)>[\s\S]*?Tu práctica será el espacio\.\s*Tu experiencia, la maestra\.\s*Y el compromiso contigo, el camino\.[\s\S]*?<\/\1>/i, ); assert.ok(closingQuoteMatch, 'Philosophy block must contain the closing quote'); const quoteClass = getAttr(`<${closingQuoteMatch[1]} ${closingQuoteMatch[2]}>`, 'class'); assert.match(quoteClass, /\bitalic\b/, `Closing quote must use italic, got "${quoteClass}"`); assert.match( quoteClass, /\bborder-y\b/, `Closing quote must use border-y hairline, got "${quoteClass}"`, ); assert.match( quoteClass, /\bborder-(?:gold(?:\/\d+)?|\[#7d5d28\](?:\/\d+)?)\b/, `Closing quote must use gold hairline border (border-gold or border-[#7d5d28]), got "${quoteClass}"`, ); }, ); await t.test( 'Criterion 3: Checklist uses 2-column grid with custom check icons (11 items) and borderless warm callout', () => { const checklistSection = sections.find((section) => section.includes('Este acompañamiento es para ti si…'), ); assert.ok(checklistSection, 'Section "Este acompañamiento es para ti si…" must exist'); const ulMatch = checklistSection.match(/]*)>([\s\S]*?)<\/ul>/i); assert.ok(ulMatch, 'Checklist section must contain a
    '); const ulClass = getAttr(`
      `, 'class'); const ulInner = ulMatch[2]; assert.match( ulClass, /\bmd:grid-cols-2\b/, `Checklist
        must use md:grid-cols-2, got "${ulClass}"`, ); assert.doesNotMatch( ulClass, /\blist-disc\b/, `Checklist
          must replace default bullets (list-disc) with custom check icons, got "${ulClass}"`, ); const listItems = [...ulInner.matchAll(/]*>([\s\S]*?)<\/li>/gi)]; assert.equal(listItems.length, 11, 'Checklist must preserve all 11
        • items'); for (const [idx, item] of listItems.entries()) { assert.ok( /]*)>\s*]*>\s*No necesitas tener experiencia previa en Kundalini Yoga\./i, ); assert.ok(calloutMatch, 'Checklist section must contain the borderless callout container'); const calloutClass = getAttr(`
          `, 'class'); assert.doesNotMatch( calloutClass, /\bborder(?:-[^\s]+)?\b/, `Warm callout container must be borderless (no border* class), got "${calloutClass}"`, ); }, ); await t.test( 'Criterion 4: "Tu proceso incluye" renders sequential 01-06 timeline with 4 aspect-[16/10] images and 2 typographic milestone rows', () => { const timelineSection = sections.find((section) => section.includes('Tu proceso incluye')); assert.ok(timelineSection, 'Section "Tu proceso incluye" must exist'); const expectedSteps = [ { num: '1', title: 'Encuentro inicial y mapa de tu proceso', img: 'volver-a-ti-proceso-inicial.webp', }, { num: '2', title: 'Clases individuales de Kundalini Yoga en vivo', img: null }, { num: '3', title: 'Seguimiento y espacios de integración', img: null }, { num: '4', title: 'Práctica personal entre sesiones', img: 'volver-a-ti-practica-personal.webp', }, { num: '5', title: 'Diario de práctica y reflexión', img: 'volver-a-ti-diario.webp' }, { num: '6', title: 'Recursos complementarios', img: 'volver-a-ti-recursos.webp' }, ]; let prevPos = -1; for (const step of expectedSteps) { const pos = timelineSection.indexOf(step.title); assert.ok(pos !== -1, `Timeline must include step ${step.num}: "${step.title}"`); assert.ok( pos > prevPos, `Timeline step ${step.num} ("${step.title}") must appear in sequential DOM order`, ); prevPos = pos; } // Why: steps 02 and 03 are typographic milestone rows without images; only 01, 04, 05, 06 have photos. const imgTags = [...timelineSection.matchAll(/]*>/gi)].map((m) => m[0]); assert.equal( imgTags.length, 4, `Timeline must contain exactly 4 elements (01, 04, 05, 06), found ${imgTags.length}`, ); const expectedImgs = expectedSteps.filter((s) => s.img).map((s) => s.img); for (const [idx, imgTag] of imgTags.entries()) { const src = getAttr(imgTag, 'src'); assert.ok( src.includes(expectedImgs[idx]), `Timeline image #${idx + 1} must be ${expectedImgs[idx]}, got "${src}"`, ); const imgClass = getAttr(imgTag, 'class'); for (const cls of ['aspect-[16/10]', 'w-full', 'object-cover']) { assert.ok( imgClass.split(/\s+/).includes(cls), `Timeline image ${expectedImgs[idx]} must include class "${cls}", got "${imgClass}"`, ); } } // Why: alternating desktop rows keep DOM order 01->06 while swapping image/copy sides via md:order-*. const articles = [...timelineSection.matchAll(/]*>[\s\S]*?<\/article>/gi)].map( (m) => m[0], ); const photoRows = articles.filter((article) => / rows (01, 04, 05, 06), found ${photoRows.length}`, ); const expectedAlternation = [ { num: '01', imgOrder: /\bmd:order-(?:1|first)\b/, proseOrder: /\bmd:order-(?:2|last)\b/ }, { num: '04', imgOrder: /\bmd:order-(?:2|last)\b/, proseOrder: /\bmd:order-(?:1|first)\b/ }, { num: '05', imgOrder: /\bmd:order-(?:1|first)\b/, proseOrder: /\bmd:order-(?:2|last)\b/ }, { num: '06', imgOrder: /\bmd:order-(?:2|last)\b/, proseOrder: /\bmd:order-(?:1|first)\b/ }, ]; for (const [idx, row] of photoRows.entries()) { const expected = expectedAlternation[idx]; const cols = [...row.matchAll(/]*\bmd:col-span-6\b[^>]*>/gi)].map((m) => m[0]); assert.equal( cols.length, 2, `Timeline photo row ${expected.num} must have 2 md:col-span-6 columns, found ${cols.length}`, ); const imgColClass = getAttr(cols[0], 'class'); const proseColClass = getAttr(cols[1], 'class'); assert.match( imgColClass, expected.imgOrder, `Timeline row ${expected.num} image column must use ${expected.imgOrder}, got "${imgColClass}"`, ); assert.match( proseColClass, expected.proseOrder, `Timeline row ${expected.num} prose column must use ${expected.proseOrder}, got "${proseColClass}"`, ); } }, ); await t.test( 'Criterion 5: #inscripcion uses concise Zelle CTA label and items-stretch/items-center/justify-center balance', () => { const inscripcionSection = sections.find((section) => /\bid=["']?inscripcion["']?/i.test(section), ); assert.ok(inscripcionSection, 'Section #inscripcion must exist'); assert.doesNotMatch( inscripcionSection, /Coordinar pago por Zelle \(WhatsApp\)/, '#inscripcion must replace verbose "Coordinar pago por Zelle (WhatsApp)" label', ); assert.match( inscripcionSection, /Pagar con Zelle \(WhatsApp\)/, '#inscripcion gated CTA must display "Pagar con Zelle (WhatsApp)"', ); const ctaContainerMatch = inscripcionSection.match( /]*)>\s*]*data-disclaimer-gate\b[\s\S]*?<\/div>/i, ); assert.ok(ctaContainerMatch, '#inscripcion must contain a flex container wrapping the CTAs'); const containerClass = getAttr(`
          `, 'class'); assert.match( containerClass, /\bitems-stretch\b/, `#inscripcion CTA flex container must include items-stretch, got "${containerClass}"`, ); const ctaLinks = [...ctaContainerMatch[0].matchAll(/]*>/gi)].map((m) => m[0]); assert.equal(ctaLinks.length, 2, '#inscripcion CTA container must have 2 elements'); for (const [idx, linkTag] of ctaLinks.entries()) { const linkClass = getAttr(linkTag, 'class'); assert.match( linkClass, /\bitems-center\b/, `#inscripcion CTA #${idx + 1} must include items-center, got "${linkClass}"`, ); assert.match( linkClass, /\bjustify-center\b/, `#inscripcion CTA #${idx + 1} must include justify-center, got "${linkClass}"`, ); } }, ); });