fix: preserve complete weekly brief content and date bounds
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user