import {expect, it} from 'vitest'; import {renderToStaticMarkup} from 'react-dom/server'; import type {SitePayload} from '@o2o/shared'; import {SiteProvider} from '@site/lib/site-context'; import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay'; import {ReviewSection} from './ReviewSection'; function withReviews(count: number): SitePayload { const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD); payload.reviews = Array.from({length: count}, (_, i) => ({ reviewId: `review-${i}`, body: `${i}번째 후기입니다. 마당이 조용해서 좋았습니다.`, nickname: i % 2 === 0 ? `손님${i}` : '', publishedAt: '2026-09-14T09:00:00', })); return payload; } function render(payload: SitePayload) { return renderToStaticMarkup(); } it('후기가 없어도 남기는 자리는 선다', () => { const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD); delete payload.reviews; const html = render(payload); // 쓰기 폼은 모달이라 처음에는 안 그린다 — 버튼만 선다. expect(html).toContain('후기 남기기'); expect(html).not.toContain(' { const html = render(withReviews(12)); for (let i = 0; i < 12; i += 1) expect(html).toContain(`${i}번째 후기입니다`); }); it('이름을 안 적으면 손님으로 나간다', () => { expect(render(withReviews(2))).toContain('손님'); }); it('별점을 그리지 않는다 — 구조화 데이터도 만들지 않는다', () => { const html = render(withReviews(3)); expect(html).not.toContain('aggregateRating'); expect(html).not.toContain('ratingValue'); expect(html).not.toContain('★'); });