fix(builder): Testimonials single-layout static-parity export (D2a)

The editor rendered layout="single" as an interactive carousel (prev/next
buttons, dot indicators, currentIndex state) but toHtml exported a static
stacked list of ALL testimonials -- a structural mismatch. This codebase's
static export has no published-JS interactivity for this component, so
static-parity is the lower-risk fix: the editor's single view now renders
just the first testimonial (no carousel chrome), and toHtml exports
exactly that one card. Grid layout is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 13:46:38 -07:00
co-authored by Claude Opus 4.8
parent a0cdbd1d82
commit 2887cc9bdf
2 changed files with 52 additions and 46 deletions
@@ -0,0 +1,39 @@
import { describe, test, expect } from 'vitest';
import { Testimonials } from './Testimonials';
const toHtml = (Testimonials as any).toHtml;
const testimonials = [
{ quote: 'Quote one', name: 'Name One', title: 'Title One', rating: 5 },
{ quote: 'Quote two', name: 'Name Two', title: 'Title Two', rating: 4 },
{ quote: 'Quote three', name: 'Name Three', title: 'Title Three', rating: 3 },
];
describe('Testimonials.toHtml single-layout export parity', () => {
// The editor's "single" layout shows exactly one testimonial (a single
// card, no stacked list). Static-parity fix: toHtml exports exactly one
// card too (the first testimonial), matching what the editor displays by
// default -- not a stacked list of all testimonials, and not a JS carousel
// (this codebase's static export has no published-JS interactivity for
// this component).
test('single layout: exports exactly one testimonial card, not all of them', () => {
const { html } = toHtml({ testimonials, layout: 'single' }, '');
expect(html).toContain('Name One');
expect(html).not.toContain('Name Two');
expect(html).not.toContain('Name Three');
expect(html).toContain('Quote one');
});
test('single layout: no carousel controls (prev/next/dots) in static export', () => {
const { html } = toHtml({ testimonials, layout: 'single' }, '');
expect(html).not.toContain('fa-chevron-left');
expect(html).not.toContain('fa-chevron-right');
});
test('grid layout: still exports all testimonials (unchanged behavior)', () => {
const { html } = toHtml({ testimonials, layout: 'grid' }, '');
expect(html).toContain('Name One');
expect(html).toContain('Name Two');
expect(html).toContain('Name Three');
});
});