.
+ * 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)',
@@ -200,13 +234,14 @@ test('Slice 3 Acceptance Criteria: 5-Card Catalog, Brand Tokens & Complementary
);
});
- await t.test('Criterion 5: Contextual WhatsApp CTAs & Phone Invariant (5 cards + Hatha)', () => {
+ await t.test('Criterion 5: Contextual WhatsApp CTAs & Phone Invariant (4 cards + Hatha)', () => {
const phone = '573215428972';
// Find all WhatsApp links in the document
const waLinks = [...indexHtml.matchAll(/href="(https:\/\/wa\.me\/[^"]+)"/gi)].map((m) => m[1]);
- // Must have at least 8 WhatsApp links: floating, hero, 5 cards, hatha, contact
+ // Why: Card 2 now routes to /kundalini/, leaving 9 links (FAB, 2 hero, 4 cards,
+ // Hatha, contact); >= 8 keeps headroom for copy edits without masking a lost CTA.
assert.ok(waLinks.length >= 8, `Expected at least 8 WhatsApp links, found ${waLinks.length}`);
const uniqueMessages = new Set();
@@ -227,7 +262,7 @@ test('Slice 3 Acceptance Criteria: 5-Card Catalog, Brand Tokens & Complementary
}
}
- // Check that 5 service cards and Hatha Yoga have unique messages
+ // Why: 7 distinct texts = hero sesiones, 4 non-Kundalini cards, Hatha, contact.
assert.ok(
uniqueMessages.size >= 7,
`Expected at least 7 distinct contextual inquiry messages, found ${uniqueMessages.size}`,
@@ -246,6 +281,22 @@ test('Slice 3 Acceptance Criteria: 5-Card Catalog, Brand Tokens & Complementary
}
});
+ await t.test('Criterion 5b: Service Card 2 CTA routes in-tab to /kundalini/', () => {
+ const kundaliniCard = extractCardByHeading(
+ indexHtml,
+ 'Clases de Kundalini Yoga y Acompañamientos',
+ );
+ assert.ok(kundaliniCard, 'Service Card 2 (Kundalini Yoga) must exist in built HTML');
+
+ const ctaTag = [...kundaliniCard.matchAll(/
]*>/gi)]
+ .map((match) => match[0])
+ .find((tag) => /\bhref="\/kundalini\/"/i.test(tag));
+ assert.ok(ctaTag, 'Service Card 2 must have a CTA with href="/kundalini/"');
+ // Why: same-site navigation must stay in the current tab; target/rel are external-link only.
+ assert.doesNotMatch(ctaTag, /\btarget=/i, 'Card 2 CTA must not open a new tab');
+ assert.doesNotMatch(ctaTag, /\brel=/i, 'Card 2 CTA must not carry a rel attribute');
+ });
+
await t.test(
'Criterion 6: Reconciled Caminos Complementarios (Section 04: single container & media strip)',
() => {