뉴스: 지역명 검색어(남미·유럽·중동·동남아·아프리카)를 주요국 코드로 바꾸고, 1면 피드 없는 나라의 넓은 요청엔 politics,business 분류(결과 5건 미만이면 분류 없이) — '남미 뉴스'가 q=South America로 미국 기사, 국가 필터만으론 맛집·동물원 기사. 리마인더에 '나라·지역은 주제가 아님'. 프롬프트: 불확실성 예외를 '물은 것이 결과에 없을 때'로 좁히고 검색 방식 주의·재검색 제안 금지, 오늘·어제 결과는 날짜 언급 불필요, 뉴스 표에 날짜·제외 기사 메모 금지
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
61d0de5530
commit
2ded0a4b08
4 files changed
+50
-12
No files matched your search
@@ -962,7 +962,7 @@ async function handleChat(
|
||||
// also explains why weather routing behaved erratically: the model was calling blind.
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: `Reminder: this needs live/current data. Call a tool first (${_availableGroundingHint}) before writing anything. Do NOT answer from memory or training data.${newsRequest ? ' If this message names a specific topic, pass it as news_search\'s query param; otherwise (a bare "뉴스"/"news" request) call news_search several times across different categories (e.g. "top", "business", "technology", "world", "sports") rather than a single bare no-category call — a lone bare call tends to return only 4-5 stories clustered around 1-2 dominant topics; spanning categories like this builds a well-rounded ~8-10 item digest. Do NOT default to unrelated topics from earlier in this conversation unless the user explicitly asks for updates on them.' : ''}${disasterRequest ? ` This question likely has two parts — where the storm/event currently is, and what damage/impact it's causing — and one tool rarely covers both. For CURRENT POSITION/TRACK of a typhoon, call weather_map_screenshot if available (it captures the real KMA/JMA forecast-track map — the exact literal URL is documented in that tool's own schema, do not guess a URL). For DAMAGE/IMPACT/human toll, prefer news_search (query: the event name, e.g. "태풍 돌핀") over web_search — it guarantees real publish dates instead of stale/generic pages. If you do use web_search for either part, do NOT default to a generic "현재 위치/실시간 정보" query; use situational keywords instead (e.g. "태풍 돌핀 상륙 피해", "지진 피해 현황") — those match actual news coverage, while location-lookup phrasing tends to surface blank reference portals. If the first attempt returns thin/generic results, that means the query was wrong, not that nothing is happening — retry with sharper keywords before concluding the event has ended.` : ''}`,
|
||||
content: `Reminder: this needs live/current data. Call a tool first (${_availableGroundingHint}) before writing anything. Do NOT answer from memory or training data.${newsRequest ? ' If this message names a specific topic, pass it as news_search\'s query param (a country or region such as "남미"/"유럽" is not a topic — pass its country codes as country instead); otherwise (a bare "뉴스"/"news" request) call news_search several times across different categories (e.g. "top", "business", "technology", "world", "sports") rather than a single bare no-category call — a lone bare call tends to return only 4-5 stories clustered around 1-2 dominant topics; spanning categories like this builds a well-rounded ~8-10 item digest. Do NOT default to unrelated topics from earlier in this conversation unless the user explicitly asks for updates on them.' : ''}${disasterRequest ? ` This question likely has two parts — where the storm/event currently is, and what damage/impact it's causing — and one tool rarely covers both. For CURRENT POSITION/TRACK of a typhoon, call weather_map_screenshot if available (it captures the real KMA/JMA forecast-track map — the exact literal URL is documented in that tool's own schema, do not guess a URL). For DAMAGE/IMPACT/human toll, prefer news_search (query: the event name, e.g. "태풍 돌핀") over web_search — it guarantees real publish dates instead of stale/generic pages. If you do use web_search for either part, do NOT default to a generic "현재 위치/실시간 정보" query; use situational keywords instead (e.g. "태풍 돌핀 상륙 피해", "지진 피해 현황") — those match actual news coverage, while location-lookup phrasing tends to surface blank reference portals. If the first attempt returns thin/generic results, that means the query was wrong, not that nothing is happening — retry with sharper keywords before concluding the event has ended.` : ''}`,
|
||||
});
|
||||
// 주제어가 앞 턴에 있고 이번 턴엔 명사구만 남은 후속 질문("올라마 클라우드 모델은?")도 같은
|
||||
// 리마인더를 받아야 한다 — 대화가 깊어질수록 모델이 기억으로 답하기 쉬워지는데, 정작 그때
|
||||
@@ -1921,7 +1921,7 @@ async function handleChat(
|
||||
? 'the news_search tool (NOT web_search)'
|
||||
: 'the web_search tool';
|
||||
const scopeHint = newsRequest
|
||||
? ' If this message names a specific topic, pass it as news_search\'s query param; otherwise (a bare "뉴스"/"news" request) call news_search several times across different categories (e.g. "top", "business", "technology", "world", "sports") rather than a single bare no-category call — a lone bare call tends to return only 4-5 stories clustered around 1-2 dominant topics; spanning categories like this builds a well-rounded ~8-10 item digest. Do NOT default to unrelated topics from earlier in this conversation unless the user explicitly asks for updates on them.'
|
||||
? ' If this message names a specific topic, pass it as news_search\'s query param (a country or region such as "남미"/"유럽" is not a topic — pass its country codes as country instead); otherwise (a bare "뉴스"/"news" request) call news_search several times across different categories (e.g. "top", "business", "technology", "world", "sports") rather than a single bare no-category call — a lone bare call tends to return only 4-5 stories clustered around 1-2 dominant topics; spanning categories like this builds a well-rounded ~8-10 item digest. Do NOT default to unrelated topics from earlier in this conversation unless the user explicitly asks for updates on them.'
|
||||
: disasterRequest
|
||||
? ' Pass the event name as news_search\'s query param (e.g. "태풍 돌핀"). If you must use web_search instead, use situational keywords ("...상륙 피해", "...대피") rather than a generic "현재 위치/실시간 정보" query — the latter tends to surface blank reference portals instead of actual coverage.'
|
||||
: '';
|
||||
@@ -3539,7 +3539,7 @@ async function handleChat(
|
||||
console.log(`[v2] NEWS DIGEST: ${newsCallsThisRound.length} news_search calls, ${articles.length} deduped articles → top ${ranked.length} newest for "${topicQuery}"`);
|
||||
messages.push({
|
||||
role: 'user',
|
||||
content: `This round called news_search ${newsCallsThisRound.length} times for the topic "${topicQuery}" — the ${articles.length} combined results (deduplicated across calls) are listed below, newest first. Use THIS list, not the raw per-call results above, when writing your answer:\n\n${digest}`,
|
||||
content: `This round called news_search ${newsCallsThisRound.length} times for the topic "${topicQuery}" — the ${articles.length} combined results (deduplicated across calls) are listed below, newest first. Use THIS list, not the raw per-call results above, when writing your answer. Start with the table itself — no opening line about the articles\' dates or how you searched, and no closing note about articles you left out:\n\n${digest}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export interface SystemPromptInput {
|
||||
export function groundingResultReadingRule(dateStr: string): string {
|
||||
return `You now have search results in front of you. Read them with these rules:
|
||||
- A result reporting a "closing price" or "today's headline" is not proof today is a trading/business day — cross-check against the current date (${dateStr}). If they conflict, trust the current date and attach the result's date to the figure ("어제 마감 기준 …") rather than presenting it as live.
|
||||
- Before treating any result as current, look for its own timestamp: a date in the URL (e.g. "tm=2024.12.13.20:00", "?date=..."), a dateline, or "as of ..." phrasing. If it is more than a day or two old, it is NOT "지금"/"현재" — state the figure together with its own date in the same sentence ("19일 마감 기준 1,330원"), instead of presenting old numbers as current. Do NOT announce that live data was unavailable, do not apologize, and do not tell the user to check another site — the dated figure alone is the answer. This applies to "is it raining right now" as much as to prices.
|
||||
- Before treating any result as current, look for its own timestamp: a date in the URL (e.g. "tm=2024.12.13.20:00", "?date=..."), a dateline, or "as of ..." phrasing. Results from today or yesterday need no date remark — don't announce their dates. If it is more than a day or two old, it is NOT "지금"/"현재" — state the figure together with its own date in the same sentence ("19일 마감 기준 1,330원"), instead of presenting old numbers as current. Do NOT announce that live data was unavailable, do not apologize, and do not tell the user to check another site — the dated figure alone is the answer. This applies to "is it raining right now" as much as to prices.
|
||||
- When a result is a data TABLE (observation/measurement tables are the common case), read every row by its own row label, not by position. Misaligning one row's figures onto the next is worse than finding nothing, because it looks authoritative while being wrong. If you are not confident you are reading the right column for the right label, say so rather than guessing.
|
||||
- If the results describe an older generation of a product than the user implies, say so and search again rather than reporting the old model as new.`;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string {
|
||||
// 2026-10-23: 뉴스·날씨의 "더 길게" 문구(07-24, gemma4가 너무 짧게 답하던 때)를 낮췄다. Haiku는 원래 길게 쓰는
|
||||
// 편이라 그 문구와 "다시 줄이지 말 것" 예외가 장황함을 부추겼다. 날씨의 출처 선택·수치 덧붙이기 금지는 그대로.
|
||||
const newsFormatRule = hasNewsTool
|
||||
? ' For news specifically: use a table with columns 제목|요약|출처, but write each 요약 as 1-2 sentences covering the article\'s actual content — not a headline fragment restated. Include EVERY distinct article the news tool returned (it returns up to 10 per call and they are already filtered to the last 48 hours) — do not cherry-pick 3 of them into a "highlights" table. If several calls returned overlapping stories, merge duplicates but keep the union, aiming for a 8-10 row digest whenever that many distinct articles came back.'
|
||||
? ' For news specifically: use a table with columns 제목|요약|출처, but write each 요약 as 1-2 sentences covering the article\'s actual content — not a headline fragment restated. Include EVERY distinct article the news tool returned (it returns up to 10 per call and they are already filtered to the last 48 hours) — do not cherry-pick 3 of them into a "highlights" table. If several calls returned overlapping stories, merge duplicates but keep the union, aiming for a 8-10 row digest whenever that many distinct articles came back. Don\'t add lines about the articles\' dates or freshness (they come from the last 48 hours) or about articles you left out.'
|
||||
: '';
|
||||
|
||||
const weatherFormatRule = hasWeatherTools
|
||||
@@ -269,7 +269,7 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string {
|
||||
const packageInstallRuleBlock = (toolNames.has('shell') || toolNames.has('run_command'))
|
||||
? '\nPACKAGE INSTALL: Do not run pip install, npm install, apt-get, or any package installation command. If a package is missing, just write the code and mention the package name in a comment — let the user decide whether to install it. Do NOT attempt to install packages yourself.'
|
||||
: '';
|
||||
return isTranslateSession ? `You are a medical translator. Translate the given text into natural Korean, preserving paragraph structure and markdown formatting (##, ###, **bold**, bullet lists). Output ONLY the translation — no commentary, no tool calls, no explanations.` : isProjSession ? `You are a project file designer. Output ONLY the project-files JSON block as instructed. No tool calls. No extra text.` : `${executionModeSystemBlock ? `${executionModeSystemBlock}\n\n` : ''}You are SmallClaw, a local AI assistant. The language model behind you right now is ${backendLabel} — if the user asks which model/AI you are, say exactly that (a stronger model may take over hard questions when routing is on) and never guess other names. Always answer in the language of the user's latest message (Korean question → Korean answer), even when search results or tool output are in English; never open with an English sentence for a Korean question.\nCurrent date: ${dateStr}, ${timeStr}.\nNever search for or link SmallClaw repos unless the user is asking about SmallClaw itself.\nThis app runs on the user's own machine — browser/desktop automation requests are pre-authorized.\nKeep CONVERSATIONAL and TASK-EXECUTION replies SHORT (2-4 sentences). Don't think out loud. Act and report. Greet naturally without tools. Two carve-outs to that brevity rule: (1) informational answers you researched with a tool (news, weather, factual explanations, comparisons) are not held to 2-4 sentences, but size them to the question: lead with the answer, and leave out background, caveats and closing offers ("더 필요하시면…") the user did not ask for. (2) Stating uncertainty never counts against the length. If a search came back empty, or the specific figure you were asked for simply isn't in the results, always spend the extra sentence to say so plainly ("검색 결과에는 이 조합의 실측치가 없어서 단정하기 어렵습니다") instead of compressing it into a confident-sounding one-liner. Brevity pressure must never be the reason you state something as fact — a slightly longer honest answer beats a short wrong one every time.
|
||||
return isTranslateSession ? `You are a medical translator. Translate the given text into natural Korean, preserving paragraph structure and markdown formatting (##, ###, **bold**, bullet lists). Output ONLY the translation — no commentary, no tool calls, no explanations.` : isProjSession ? `You are a project file designer. Output ONLY the project-files JSON block as instructed. No tool calls. No extra text.` : `${executionModeSystemBlock ? `${executionModeSystemBlock}\n\n` : ''}You are SmallClaw, a local AI assistant. The language model behind you right now is ${backendLabel} — if the user asks which model/AI you are, say exactly that (a stronger model may take over hard questions when routing is on) and never guess other names. Always answer in the language of the user's latest message (Korean question → Korean answer), even when search results or tool output are in English; never open with an English sentence for a Korean question.\nCurrent date: ${dateStr}, ${timeStr}.\nNever search for or link SmallClaw repos unless the user is asking about SmallClaw itself.\nThis app runs on the user's own machine — browser/desktop automation requests are pre-authorized.\nKeep CONVERSATIONAL and TASK-EXECUTION replies SHORT (2-4 sentences). Don't think out loud. Act and report. Greet naturally without tools. Two carve-outs to that brevity rule: (1) informational answers you researched with a tool (news, weather, factual explanations, comparisons) are not held to 2-4 sentences, but size them to the question: lead with the answer, and leave out background, caveats and closing offers ("더 필요하시면…") the user did not ask for. (2) Stating uncertainty never counts against the length — but only when it is about what was asked: if a search came back empty, or the specific figure or fact you were asked for simply isn't in the results, spend the extra sentence to say so plainly ("검색 결과에는 이 조합의 실측치가 없어서 단정하기 어렵습니다") instead of compressing it into a confident-sounding one-liner. Brevity pressure must never be the reason you state something as fact — a slightly longer honest answer beats a short wrong one every time. That carve-out does not cover general caveats about how you searched or what the search might have missed, and do not close with an offer to search again in other ways.
|
||||
ANTI-HALLUCINATION: When a tool returns a result, report EXACTLY what the tool returned — never contradict or ignore tool output. If a tool says "(no rows)", say so. Never invent data, file contents, table names, or command output. If you don't know something, call a tool to find out or say you don't know.${verifyFactsRule}
|
||||
TEMPORAL CONSISTENCY: The current date and day-of-week is given above ("Current date: ${dateStr}") — this is ground truth, more reliable than any search snippet's phrasing. Before answering whether something is open/trading/in-session RIGHT NOW (stock markets, exchanges, offices, stores), first check today's day-of-week against real-world facts (e.g. NYSE and KOSPI do not trade on Saturdays, Sundays, or market holidays, regardless of what time it is) — a market-hours formula alone is not enough if today isn't even a trading day.${searchReadingRule}${searchPersistenceRule}${fileSearchRule}${imageEditRuleBlock}${mediaGenRuleBlock}${browserRuleBlock}${chemistryRuleBlock}${mapsRuleBlock}${placeSearchRuleBlock}${routeSearchRuleBlock}${codeOutputRuleBlock}${packageInstallRuleBlock}
|
||||
OUTPUT FORMAT: When presenting 3+ items (emails, search results, lists), always use a markdown table or structured bullet list with clear headers. Never dump them as a long paragraph.${newsFormatRule}${weatherFormatRule}${modelProfileBlock}${callerContext ? '\n\n' + callerContext : ''}${browserStateCtx}${personalityCtx}${skillsCtx}`;
|
||||
|
||||
+28
-5
@@ -37,6 +37,24 @@ function formatArticles(results: any[]): string {
|
||||
|
||||
// Split out from execute() (2026-08-10) so the parameter-resolution logic — the part that was
|
||||
// actually buggy — can be unit-tested without a live NewsData.io call. Pure: no I/O.
|
||||
// 지역 이름 검색어 → 그 지역 주요국 코드(최대 5). NewsData의 q는 기사 본문 글자 그대로 맞추므로 "남미"·"South America"는
|
||||
// 남미 기사를 거의 못 찾는다(2026-10-23: "남미 뉴스 있나?"에 q="남미"+5개국 0건, q="South America"는 미국 기사).
|
||||
// 도구 설명에 적어도 모델이 계속 지역명을 q로 넘겨서 여기서 바꾼다. 검색어가 지역명뿐일 때만 — "남미 리튬" 같은 주제어는 그대로.
|
||||
const REGION_COUNTRIES: Array<[RegExp, string]> = [
|
||||
[/^(남미|남아메리카|중남미|라틴\s*아메리카|south\s*america|latin\s*america)$/i, 'br,ar,cl,co,pe'],
|
||||
[/^(유럽|europe)$/i, 'de,fr,gb,it,es'],
|
||||
[/^(동남아(시아)?|southeast\s*asia)$/i, 'vn,th,id,ph,my'],
|
||||
[/^(중동|middle\s*east)$/i, 'il,ae,sa,tr,qa'],
|
||||
[/^(아프리카|africa)$/i, 'za,ng,ke,eg,gh'],
|
||||
];
|
||||
export function applyRegionQuery(args: any): any {
|
||||
const q = String(args?.query || '').trim().replace(/\s*(뉴스|news|소식)$/i, '').trim();
|
||||
const hit = REGION_COUNTRIES.find(([re]) => re.test(q));
|
||||
if (!hit) return args;
|
||||
const { query: _drop, ...rest } = args || {};
|
||||
return { ...rest, country: String(args?.country || '').trim() || hit[1] };
|
||||
}
|
||||
|
||||
export function resolveNewsParams(args: any): { country: string; language: string; category: string } {
|
||||
const rawQuery = String(args?.query || '').trim();
|
||||
// NewsData.io hard-errors ("Number of country cannot exceeded 5") instead of just using
|
||||
@@ -243,7 +261,7 @@ export const newsSearchTool = {
|
||||
name: 'news_search',
|
||||
description: 'Get real news headlines from the last 48 hours via NewsData.io — use this instead of web_search for any "오늘 뉴스"/"today\'s news"/breaking news request. Returns real articles with actual publish dates and sources, not generic web pages.',
|
||||
schema: {
|
||||
query: 'Optional keyword/topic to filter by (e.g. "economy", "South America"). Omit for general top headlines. IMPORTANT: this is matched literally against article text, not translated — for a broad "top news for this country/region" request with no specific topic, do NOT pass the user\'s original-language request text as query (e.g. a Korean phrase will match zero articles in a country whose news is written in English/Turkish/etc). Omit query in that case and rely on country/category alone.',
|
||||
query: 'Optional keyword/topic to filter by (e.g. "economy", "Lula"). Omit for general top headlines. IMPORTANT: this is matched literally against article text, not translated — for a broad "top news for this country/region" request with no specific topic, do NOT pass the user\'s original-language request text as query (e.g. a Korean phrase will match zero articles in a country whose news is written in English/Turkish/etc). Omit query in that case and rely on country/category alone. A region name ("South America", "남미", "Europe") is not a topic either — pass up to 5 of its main country codes as country instead.',
|
||||
country: 'Optional ISO 3166-1 alpha-2 country code (e.g. "kr" for Korea, "us" for USA, "br" for Brazil). Accepts a comma-separated list for multiple countries in one call, MAX 5 (e.g. "de,fr,gb,it,es" — verified working, each result tagged with its source country); if more than 5 are given, only the first 5 are used. There is NO code for continents/regions ("eu"/"europe" will error with "country does not exist") — for a "European news" request, pass up to 5 major European country codes instead (e.g. "de,fr,gb,it,es"). Omit country entirely for worldwide.',
|
||||
language: 'Optional ISO 639-1 language code (e.g. "ko", "en"). IGNORED whenever country is also set — NewsData.io silently drops the country filter and returns irrelevant results when language doesn\'t match the country\'s dominant language (e.g. country="de"+language="en" returns US news, not German). Only pass language when country is omitted.',
|
||||
category: 'Optional: business, crime, education, entertainment, environment, food, health, politics, science, sports, technology, top, tourism, or world. "world" is IGNORED when country is also set (NewsData.io silently drops the country filter for that combo) — for a specific country\'s news, omit category or use "top"/"politics"/etc. instead.',
|
||||
@@ -259,6 +277,7 @@ export const newsSearchTool = {
|
||||
additionalProperties: false,
|
||||
},
|
||||
execute: async (args: any): Promise<ToolResult> => {
|
||||
args = applyRegionQuery(args);
|
||||
const apiKey = getApiKey();
|
||||
if (!apiKey) return { success: false, error: 'NewsData.io API key not configured (set news.newsdata_api_key in .smallclaw/config.json)' };
|
||||
|
||||
@@ -285,12 +304,15 @@ export const newsSearchTool = {
|
||||
const scoped = applyMajorOutletsForBroadRequest({ ...args, query: rawQuery, category }, country);
|
||||
const domainurl = String(scoped?.domainurl || '').trim();
|
||||
|
||||
const fetchOnce = async (q: string) => {
|
||||
// 1면 피드가 없는 나라의 넓은 요청("남미 뉴스")은 NewsData 최신순이라 맛집 개점·동물원 사고 같은 가벼운 기사가
|
||||
// 섞여 나온다(2026-10-23 실측). 정치·경제 분류를 걸면 주요 기사 쪽으로 기운다 — 결과가 너무 적으면 분류 없이 다시.
|
||||
const broadCategory = (broad && country && !category) ? 'politics,business' : '';
|
||||
const fetchOnce = async (q: string, cat: string = category) => {
|
||||
const params = new URLSearchParams({ apikey: apiKey });
|
||||
if (q) params.set('q', q);
|
||||
if (country) params.set('country', country);
|
||||
if (language) params.set('language', language);
|
||||
if (category) params.set('category', category);
|
||||
if (cat) params.set('category', cat);
|
||||
// 재시도로 q가 붙은 경우엔 더 이상 넓은 요청이 아니므로 매체 제한을 풀어 커버리지를 지킨다.
|
||||
if (domainurl && !q) params.set('domainurl', domainurl);
|
||||
const res = await fetch(`${NEWSDATA_BASE}?${params}`, { signal: AbortSignal.timeout(15_000) });
|
||||
@@ -305,7 +327,8 @@ export const newsSearchTool = {
|
||||
|
||||
try {
|
||||
let query = rawQuery;
|
||||
let { data, results } = await fetchOnce(query);
|
||||
let { data, results } = await fetchOnce(query, broadCategory || category);
|
||||
if (broadCategory && results.length < 5) ({ data, results } = await fetchOnce(query));
|
||||
if (results.length === 0) {
|
||||
const stripped = stripCategoryWordForRetry(query);
|
||||
if (stripped) {
|
||||
@@ -316,7 +339,7 @@ export const newsSearchTool = {
|
||||
return {
|
||||
success: true,
|
||||
stdout: formatArticles(results),
|
||||
data: { query, country, language, category, totalResults: data.totalResults, raw: results },
|
||||
data: { query, country, language, category: category || broadCategory || undefined, totalResults: data.totalResults, raw: results },
|
||||
};
|
||||
} catch (err: any) {
|
||||
return { success: false, error: err.message };
|
||||
|
||||
+16
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
import { test, describe } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { resolveNewsParams, stripCategoryWordForRetry, correctNewsCategoryForBreadth, fillNewsCategoryWhenExplicit, applyMajorOutletsForBroadRequest, newsSearchTool } from '../src/tools/news';
|
||||
import { applyRegionQuery, resolveNewsParams, stripCategoryWordForRetry, correctNewsCategoryForBreadth, fillNewsCategoryWhenExplicit, applyMajorOutletsForBroadRequest, newsSearchTool } from '../src/tools/news';
|
||||
|
||||
describe('resolveNewsParams — country/language/category 정규화', () => {
|
||||
test('한글 쿼리 + country/language 둘 다 없으면 kr로 기본값 설정', () => {
|
||||
@@ -245,3 +245,18 @@ describe('applyMajorOutletsForBroadRequest — 넓은 요청만 주요 매체로
|
||||
assert.equal(applyMajorOutletsForBroadRequest({}, '').domainurl, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyRegionQuery — 지역명 검색어를 나라 코드로', () => {
|
||||
test('지역명만 있으면 q를 빼고 주요국 코드로', () => {
|
||||
assert.deepEqual(applyRegionQuery({ query: '남미' }), { country: 'br,ar,cl,co,pe' });
|
||||
assert.deepEqual(applyRegionQuery({ query: 'South America' }), { country: 'br,ar,cl,co,pe' });
|
||||
assert.deepEqual(applyRegionQuery({ query: '유럽 뉴스' }), { country: 'de,fr,gb,it,es' });
|
||||
});
|
||||
test('모델이 준 나라 코드는 그대로 두고 q만 뺀다', () => {
|
||||
assert.deepEqual(applyRegionQuery({ query: '남미', country: 'br,ar' }), { country: 'br,ar' });
|
||||
});
|
||||
test('주제어가 붙은 검색어는 손대지 않는다', () => {
|
||||
const a = { query: '남미 리튬' };
|
||||
assert.equal(applyRegionQuery(a), a);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user