fix: preserve complete weekly brief content and date bounds

This commit is contained in:
2026-09-06 14:29:59 +03:00
parent 23512b7a87
commit d3a52caf2b
8 changed files with 143 additions and 24 deletions
+22
View File
@@ -0,0 +1,22 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { sendTelegram } from '../server/telegram.mjs';
test('brief plain-text mode reaches Telegram request without HTML parsing or content changes',async()=>{
const oldFetch=globalThis.fetch,oldToken=process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN='synthetic-test-token';
const payloads=[];
globalThis.fetch=async(url,options)=>{payloads.push(JSON.parse(options.body));return {ok:true,json:async()=>({ok:true})};};
try {
const text='Laboratuvar <test> & ürün 🧪';
assert.equal(await sendTelegram('test-chat',text,{parseMode:null}),true);
assert.equal(payloads[0].text,text);
assert.equal(Object.hasOwn(payloads[0],'parse_mode'),false);
await sendTelegram('test-chat','<b>Başlık</b>');
assert.equal(payloads[1].parse_mode,'HTML');
} finally {
globalThis.fetch=oldFetch;
if(oldToken===undefined)delete process.env.TELEGRAM_BOT_TOKEN;
else process.env.TELEGRAM_BOT_TOKEN=oldToken;
}
});