fix: improve tester timeouts and telegram proxy config

This commit is contained in:
ciat-777
2026-03-14 16:18:43 +08:00
parent 201a806e51
commit 7bd48a3c6f
12 changed files with 369 additions and 6 deletions
+24
View File
@@ -198,4 +198,28 @@ describe('notifyService', () => {
expect(payload.text || '').toContain('Local Time:');
expect(payload.text || '').toContain('UTC Time:');
});
it('uses TELEGRAM_API_BASE_URL when configured', async () => {
const { config } = await import('../config.js');
(config as any).telegramEnabled = true;
(config as any).telegramBotToken = '123456:telegram-token';
(config as any).telegramChatId = '-1001234567890';
(config as any).telegramApiBaseUrl = 'https://tg-proxy.example.com/custom/';
config.smtpEnabled = false;
fetchMock.mockResolvedValue({
ok: true,
status: 200,
});
const { sendNotification } = await import('./notifyService.js');
await sendNotification('测试通知', 'message', 'warning', { bypassThrottle: true, throwOnFailure: true });
expect(fetchMock).toHaveBeenCalledWith(
'https://tg-proxy.example.com/custom/bot123456:telegram-token/sendMessage',
expect.objectContaining({
method: 'POST',
}),
);
});
});
+2 -1
View File
@@ -218,7 +218,8 @@ export async function sendNotification(
}
if (config.telegramEnabled && config.telegramBotToken && config.telegramChatId) {
const telegramApiUrl = `https://api.telegram.org/bot${config.telegramBotToken}/sendMessage`;
const telegramApiBaseUrl = String(config.telegramApiBaseUrl || 'https://api.telegram.org').replace(/\/+$/, '');
const telegramApiUrl = `${telegramApiBaseUrl}/bot${config.telegramBotToken}/sendMessage`;
const text = buildTelegramText(title, resolvedMessage, level, timeFootnote);
tasks.push({
channel: 'telegram',