mirror of
https://github.com/corazoncp/corazoncp-landing.git
synced 2026-12-01 04:30:31 +00:00
* test(volver-a-ti): add Red contract tests for issue #13 layout rhythm - Add contract assertions for hero asymmetric framing and mobile-first DOM order - Assert philosophy pull-quote without card border, 2-col checklist, 01-06 timeline, and balanced #inscripcion CTAs * style(volver-a-ti): break card fatigue with pull-quote, 2-col checklist, 01-06 timeline, and hero framing - Reorder hero image before intro prose in DOM for mobile (< 768px) with md:order-* desktop alignment and asymmetric organic rounding - Replace philosophy card with centered max-w-2xl prose and border-y gold hairline italic pull-quote - Convert 11-item checklist to md:grid-cols-2 with check icons and warm borderless tinted callout - Replace 2x2 process grid with sequential 01-06 alternating timeline (02/03 typographic milestones; 01/04/05/06 16:10 photos) - Balance #inscripcion CTAs with items-stretch and concise Zelle button label * test(volver-a-ti): harden timeline alternation and philosophy slice assertions (CR-01, CR-02) - Verify per-row alternating md:order-* classes on timeline rows 01, 04, 05, and 06 (CR-01) - Slice philosophyChunk from blockStart so containerMatch reliably captures the outer wrapper (CR-02)
347 lines
14 KiB
JavaScript
347 lines
14 KiB
JavaScript
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(/<main\b[^>]*\bid="main"[^>]*>([\s\S]*?)<\/main>/i);
|
|
assert.ok(match, `${VOLVER_A_TI_PATH} must contain <main id="main">`);
|
|
return match[1];
|
|
}
|
|
|
|
function extractSections(mainHtml) {
|
|
return [...mainHtml.matchAll(/<section\b[^>]*>[\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 <section> 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(
|
|
/<div\b([^>]*)>\s*<img\b[^>]*src="[^"]*volver-a-ti-hero\.webp"[^>]*>/i,
|
|
);
|
|
assert.ok(imgWrapperMatch, 'Hero image must be wrapped in a <div> container');
|
|
const wrapperClass = getAttr(`<div ${imgWrapperMatch[1]}>`, '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(/<div\b[^>]*\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('</section>', philosophyIdx);
|
|
const blockStart = mainHtml.lastIndexOf('<div', philosophyIdx);
|
|
assert.ok(
|
|
blockStart !== -1 && sectionEnd !== -1,
|
|
'Philosophy block must be inside a section',
|
|
);
|
|
|
|
const philosophyChunk = mainHtml.slice(blockStart, sectionEnd);
|
|
|
|
// Why: breaking card fatigue requires removing the white bordered card container around the philosophy prose.
|
|
const containerMatch = philosophyChunk.match(
|
|
/<div\b([^>]*)>\s*(?:<div\b([^>]*)>\s*)?<h2\b[^>]*>\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(`<div ${containerMatch[1]}>`, 'class');
|
|
const innerClasses = containerMatch[2] ? getAttr(`<div ${containerMatch[2]}>`, '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(/<ul\b([^>]*)>([\s\S]*?)<\/ul>/i);
|
|
assert.ok(ulMatch, 'Checklist section must contain a <ul>');
|
|
const ulClass = getAttr(`<ul ${ulMatch[1]}>`, 'class');
|
|
const ulInner = ulMatch[2];
|
|
|
|
assert.match(
|
|
ulClass,
|
|
/\bmd:grid-cols-2\b/,
|
|
`Checklist <ul> must use md:grid-cols-2, got "${ulClass}"`,
|
|
);
|
|
assert.doesNotMatch(
|
|
ulClass,
|
|
/\blist-disc\b/,
|
|
`Checklist <ul> must replace default bullets (list-disc) with custom check icons, got "${ulClass}"`,
|
|
);
|
|
|
|
const listItems = [...ulInner.matchAll(/<li\b[^>]*>([\s\S]*?)<\/li>/gi)];
|
|
assert.equal(listItems.length, 11, 'Checklist must preserve all 11 <li> items');
|
|
for (const [idx, item] of listItems.entries()) {
|
|
assert.ok(
|
|
/<svg\b/i.test(item[1]) || /[✓✔]/.test(item[1]),
|
|
`Checklist item #${idx + 1} must include a custom check icon`,
|
|
);
|
|
}
|
|
|
|
const calloutMatch = checklistSection.match(
|
|
/<div\b([^>]*)>\s*<p\b[^>]*>\s*No necesitas tener experiencia previa en Kundalini Yoga\./i,
|
|
);
|
|
assert.ok(calloutMatch, 'Checklist section must contain the borderless callout container');
|
|
const calloutClass = getAttr(`<div ${calloutMatch[1]}>`, '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(/<img\b[^>]*>/gi)].map((m) => m[0]);
|
|
assert.equal(
|
|
imgTags.length,
|
|
4,
|
|
`Timeline must contain exactly 4 <img> 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(/<article\b[^>]*>[\s\S]*?<\/article>/gi)].map(
|
|
(m) => m[0],
|
|
);
|
|
const photoRows = articles.filter((article) => /<img\b/i.test(article));
|
|
assert.equal(
|
|
photoRows.length,
|
|
4,
|
|
`Timeline must contain exactly 4 photo <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(/<div\b[^>]*\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(
|
|
/<div\b([^>]*)>\s*<a\b[^>]*data-disclaimer-gate\b[\s\S]*?<\/div>/i,
|
|
);
|
|
assert.ok(ctaContainerMatch, '#inscripcion must contain a flex container wrapping the CTAs');
|
|
|
|
const containerClass = getAttr(`<div ${ctaContainerMatch[1]}>`, 'class');
|
|
assert.match(
|
|
containerClass,
|
|
/\bitems-stretch\b/,
|
|
`#inscripcion CTA flex container must include items-stretch, got "${containerClass}"`,
|
|
);
|
|
|
|
const ctaLinks = [...ctaContainerMatch[0].matchAll(/<a\b[^>]*>/gi)].map((m) => m[0]);
|
|
assert.equal(ctaLinks.length, 2, '#inscripcion CTA container must have 2 <a> 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}"`,
|
|
);
|
|
}
|
|
},
|
|
);
|
|
});
|