import {expect, it} from 'vitest';
import {renderToStaticMarkup} from 'react-dom/server';
import {FactStatus, SourceType, type SitePayload} from '@o2o/shared';
import {SiteProvider} from '@site/lib/site-context';
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
import {AnswerBlock} from './AnswerBlock';
import {EssentialInfoSection} from './EssentialInfoSection';
import {AboutSection} from './AboutSection';
function fixture(summary?: string): SitePayload {
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
payload.facts = [{
key: 'intro', label: '숙소 소개', value: '숙소 소개 전체 원문입니다.', summary,
scope: 'place', type: 'text', status: FactStatus.VERIFIED,
sourceType: SourceType.LLM, critical: false, required: false,
}];
payload.narrative = {about: ['숙소 소개 전체 원문입니다.'], summary: '기존 첫 문장'};
return payload;
}
it('shows the same summary in both booking information sections', () => {
const payload = fixture('짧게 요약한 숙소 소개');
for (const section of [, ]) {
const html = renderToStaticMarkup({section});
expect(html).toContain('짧게 요약한 숙소 소개');
expect(html).not.toContain('숙소 소개 전체 원문입니다.');
}
const about = renderToStaticMarkup();
expect(about).toContain('숙소 소개 전체 원문입니다.');
});
it.each([undefined, ' '])('keeps original text when summary is %s', (summary) => {
const payload = fixture(summary);
const html = renderToStaticMarkup();
expect(html).toContain('숙소 소개 전체 원문입니다.');
});
it('does not expose summaries from unverified facts', () => {
const payload = fixture('검증 안 된 요약');
payload.facts[0].status = FactStatus.UNVERIFIED;
for (const section of [, ]) {
const html = renderToStaticMarkup({section});
expect(html).not.toContain('검증 안 된 요약');
}
});