From 209ab4eb9c4bce99f62906113baf98565fa612bf Mon Sep 17 00:00:00 2001 From: Elie Habib Date: Thu, 26 Feb 2026 10:19:44 +0400 Subject: [PATCH 1/2] fix: sort tariff datapoints newest-first in trade policy panel --- src/components/TradePolicyPanel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TradePolicyPanel.ts b/src/components/TradePolicyPanel.ts index 1a3244536..c723f1ed9 100644 --- a/src/components/TradePolicyPanel.ts +++ b/src/components/TradePolicyPanel.ts @@ -150,7 +150,7 @@ export class TradePolicyPanel extends Panel { return `
${t('components.tradePolicy.noTariffData')}
`; } - const rows = this.tariffsData.datapoints.map(d => + const rows = [...this.tariffsData.datapoints].sort((a, b) => b.year - a.year).map(d => ` ${d.year} ${d.tariffRate.toFixed(1)}% From def65b41410f0511027086f9e18273b70fc0ab13 Mon Sep 17 00:00:00 2001 From: Elie Habib Date: Thu, 26 Feb 2026 10:19:54 +0400 Subject: [PATCH 2/2] fix: update tests broken by cachedFetchJson migration - Restore "Strip unterminated" comment in summarize-article.ts that tests use to locate the unterminated tag stripping section - Update ACLED tests to check for cachedFetchJson instead of removed getCachedJson/setCachedJson patterns --- .../worldmonitor/news/v1/summarize-article.ts | 1 + tests/ttl-acled-ais-guards.test.mjs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/server/worldmonitor/news/v1/summarize-article.ts b/server/worldmonitor/news/v1/summarize-article.ts index 488a675ab..491bf767f 100644 --- a/server/worldmonitor/news/v1/summarize-article.ts +++ b/server/worldmonitor/news/v1/summarize-article.ts @@ -139,6 +139,7 @@ export async function summarizeArticle( .replace(/[\s\S]*?<\/reflection>/gi, '') .trim(); + // Strip unterminated thinking blocks (no closing tag) rawContent = rawContent .replace(/[\s\S]*/gi, '') .replace(/<\|thinking\|>[\s\S]*/gi, '') diff --git a/tests/ttl-acled-ais-guards.test.mjs b/tests/ttl-acled-ais-guards.test.mjs index 39c28ecbd..47a296696 100644 --- a/tests/ttl-acled-ais-guards.test.mjs +++ b/tests/ttl-acled-ais-guards.test.mjs @@ -52,13 +52,11 @@ describe('ACLED shared cache layer', () => { 'Cache key should include event types, start date, end date'); }); - it('checks Redis cache before upstream API call', () => { - const cacheCheckIdx = src.indexOf('getCachedJson(cacheKey)'); - const fetchIdx = src.indexOf('fetch(`${ACLED_API_URL}'); - assert.ok(cacheCheckIdx > -1, 'Should check Redis cache'); - assert.ok(fetchIdx > -1, 'Should call ACLED API'); - assert.ok(cacheCheckIdx < fetchIdx, - 'Cache check should come before upstream fetch'); + it('uses cachedFetchJson to check Redis cache before upstream API call', () => { + assert.match(src, /cachedFetchJson\s*<.*>\s*\(cacheKey/, + 'Should use cachedFetchJson which handles cache check + coalescing'); + assert.ok(src.includes('fetch(`${ACLED_API_URL}'), + 'Should call ACLED API inside the fetcher'); }); it('uses 15-minute cache TTL', () => { @@ -71,9 +69,9 @@ describe('ACLED shared cache layer', () => { 'Should gracefully degrade when ACLED_ACCESS_TOKEN is not set'); }); - it('writes to cache on successful fetch', () => { - assert.match(src, /setCachedJson\(cacheKey, events, ACLED_CACHE_TTL\)/, - 'Should cache successful results'); + it('caches successful results via cachedFetchJson', () => { + assert.match(src, /cachedFetchJson/, + 'Should use cachedFetchJson which writes to cache automatically on successful fetch'); }); it('caches empty successful responses to avoid repeated cache misses', () => {