import {expect, it} from 'vitest'; import {renderToStaticMarkup} from 'react-dom/server'; import {SiteProvider} from '@site/lib/site-context'; import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay'; import {WeatherSection} from './WeatherSection'; import type {WeatherSnapshot} from '@o2o/shared'; function render(weather?: WeatherSnapshot) { const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD); payload.local.weather = weather; return renderToStaticMarkup(); } it('uses the first sky and temperature lines for deterministic HTML', () => { const weather = {temperature: 30, observedAt: '2026-09-15T12:00', condition: '구름많음', noteSets: {'구름많음': ['구름 첫 줄', '다음 줄']}, tempNoteSets: {'혹서': ['더위 첫 줄']}}; expect(render(weather)).toContain('구름 첫 줄'); expect(render(weather)).toContain('더위 첫 줄'); expect(render(weather)).not.toContain('다음 줄'); expect(render(weather)).toBe(render(weather)); }); it('preserves legacy single notes', () => { const html = render({temperature: 15, observedAt: '2026-09-15T12:00', condition: '비', notes: {'비': '기존 비 안내'}, tempNotes: {'쌀쌀': '겉옷 안내'}}); expect(html).toContain('기존 비 안내'); expect(html).toContain('겉옷 안내'); }); it('does not invent weather when an observation is missing', () => { expect(render()).toBe(''); });