Add Telegram cancellation import functionality with tests and documentation
- Implemented Telegram cancellation parsing logic in `telegramCancellationParser.js`. - Created unit tests for cancellation parsing in `telegramCancellationParser.test.js`. - Developed integration tests for Telegram import service in `telegramImport.integration.test.js`. - Added API tests for Telegram import endpoints in `telegramImportApi.test.js`. - Introduced service tests for Telegram import logic in `telegramImportService.test.js`. - Documented the Telegram cancellation import process in `telegram-cancellation-import.md`. - Built a React component for managing Telegram imports in `TelegramImportPanel.jsx`.
This commit is contained in:
@@ -8,6 +8,17 @@ const {
|
||||
} = require('../src/services/alertNotificationService');
|
||||
const { createFirebaseMessaging, getFirebaseConfig } = require('../src/config/firebase');
|
||||
|
||||
test('expires a cancellation at Minsk midnight and does not send a stale push', async () => {
|
||||
const now = new Date('2026-10-02T20:59:00Z');
|
||||
const alert = { id: 1, alert_type: 'cancellation', end_time: '2026-10-02T21:00:00Z' };
|
||||
assert.equal(buildAlertCreatedMessage(alert, { now }).android.ttl, 60_000);
|
||||
let sends = 0;
|
||||
const service = new AlertNotificationService({ enabled: true, now: () => new Date('2026-10-02T21:00:00Z'),
|
||||
getMessaging: async () => { sends++; }, logger: createLogger() });
|
||||
assert.deepEqual(await service.sendAlertCreated(alert), { sent: false, skipped: true, reason: 'expired' });
|
||||
assert.equal(sends, 0);
|
||||
});
|
||||
|
||||
function createLogger() {
|
||||
const errors = [];
|
||||
return {
|
||||
@@ -23,6 +34,7 @@ test('sends an exact data-only alert-created message with string-only data', asy
|
||||
const service = new AlertNotificationService({
|
||||
enabled: true,
|
||||
topic: 'route_alerts',
|
||||
now: () => new Date('2026-07-11T08:30:00Z'),
|
||||
androidChannelId: 'route_alerts',
|
||||
messaging: {
|
||||
async send(message) {
|
||||
@@ -64,7 +76,8 @@ test('sends an exact data-only alert-created message with string-only data', asy
|
||||
body: 'Задержка около 15 минут'
|
||||
},
|
||||
android: {
|
||||
priority: 'high'
|
||||
priority: 'high',
|
||||
ttl: 3_600_000
|
||||
}
|
||||
});
|
||||
assert.equal('notification' in messages[0], false);
|
||||
|
||||
Reference in New Issue
Block a user