/** * weather-kma-supplement.test.ts * * formatDailySupplement was split out of weather_kma's forecast path (2026-08-10) after a real * incident: "이번 주말 날씨 어때?" (5 days out) hit weather_kma's ~3-day ceiling, and the model * told the user to ask again later instead of calling weather_openmeteo — even though * weather_kma's own description already said to do exactly that for >3-day requests. Prose * guidance kept failing to change this model's behavior (same pattern hit news_search earlier * the same day), so weather_kma now fetches the Open-Meteo extension itself and merges it in. * This pure function is the merge/filter logic — no network call, so it's directly testable. */ import { test, describe } from 'node:test'; import assert from 'node:assert/strict'; import { formatDailySupplement } from '../src/tools/weather'; describe('formatDailySupplement — KMA 3일 이후를 Open-Meteo로 보완', () => { test('KMA가 8/10까지 커버했으면 그 이후 날짜만 남긴다', () => { const dates = ['2026-08-09', '2026-08-10', '2026-08-11', '2026-08-12', '2026-08-15']; const tmax = [33, 34, 32, 31, 29]; const tmin = [24, 25, 23, 22, 21]; const pop = [20, 10, 30, 40, 60]; const out = formatDailySupplement(dates, tmax, tmin, pop, '20260810'); assert.ok(out, '보완 결과가 없으면 안 됨'); assert.ok(!out!.some(l => l.includes('2026-08-09')), 'KMA가 이미 커버한 과거 날짜가 남으면 안 됨'); assert.ok(!out!.some(l => l.includes('2026-08-10')), 'KMA가 이미 커버한 마지막 날짜가 남으면 안 됨'); assert.ok(out!.some(l => l.includes('2026-08-11'))); assert.ok(out!.some(l => l.includes('2026-08-15')), '이번 주말(8/15) 데이터가 포함돼야 함'); }); test('KMA가 이미 전체 범위를 커버했으면(추가 날짜 없음) null', () => { const dates = ['2026-08-09', '2026-08-10']; const out = formatDailySupplement(dates, [33, 34], [24, 25], [20, 10], '20260810'); assert.equal(out, null); }); test('lastCoveredYmd가 비어 있으면(경계 모름) 전체를 보완으로 취급', () => { const dates = ['2026-08-10', '2026-08-11']; const out = formatDailySupplement(dates, [34, 32], [25, 23], [10, 30], ''); assert.ok(out); assert.equal(out!.filter(l => l.startsWith('📅')).length, 2); }); test('강수확률이 없어도(null) 깨지지 않는다', () => { const out = formatDailySupplement(['2026-08-15'], [29], [21], [null], '20260810'); assert.ok(out); assert.ok(!out!.some(l => l.includes('강수확률')), 'null 강수확률은 줄 자체를 안 넣어야 함'); assert.ok(out!.some(l => l.includes('기온: 21~29°C'))); }); });