Add failover channel events to activity journal
Build and Deploy Gateway / build-and-push (push) Successful in 24s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-27 14:36:08 +03:00
parent 4a566e082a
commit 8f2f418569
11 changed files with 388 additions and 77 deletions
+29
View File
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import {
activityJournalEventCopy,
compactActivityJournalEvents,
refreshStreakCopy,
} from '../../.test-dist/src/web/features/activity-journal/activityJournalModel.js';
@@ -75,3 +76,31 @@ test('one-profile streak names the profile and keeps the latest event identity',
'15 мин всё хорошо · 2 обновления · Дом',
]);
});
test('channel health events use role-specific copy without raw reason codes', () => {
const cases = [
['failover.primary_unavailable', 'primary', 'probe-failed', ['Основной канал недоступен', 'Проверки канала не пройдены']],
['failover.reserve_unavailable', 'reserve', 'probe-failed', ['Резервный канал недоступен', 'Проверки канала не пройдены']],
['failover.primary_recovered', 'primary', 'probe-recovered', ['Основной канал восстановлен', 'Проверки канала снова проходят успешно']],
['failover.reserve_recovered', 'reserve', 'probe-recovered', ['Резервный канал восстановлен', 'Проверки канала снова проходят успешно']],
['failover.recovered', 'primary', 'primary-recovered', ['Основной канал восстановлен', 'Проверки канала снова проходят успешно']],
['failover.recovered', 'reserve', 'reserve-recovered', ['Резервный канал восстановлен', 'Проверки канала снова проходят успешно']],
];
for (const [type, role, reason, copy] of cases) {
const item = event(`event-${type}-${role}`, '2026-08-27T10:00:00.000Z', type, { role, reason });
assert.deepEqual(activityJournalEventCopy(item), copy);
assert.equal(activityJournalEventCopy(item).join(' ').includes(reason), false);
}
const switched = event('switched', '2026-08-27T10:01:00.000Z', 'failover.switched', {
fromRole: 'primary',
toRole: 'reserve',
reason: 'failure-window',
});
assert.deepEqual(activityJournalEventCopy(switched), [
'Новые соединения переключены',
'primary → reserve',
]);
assert.equal(activityJournalEventCopy(switched).join(' ').includes('failure-window'), false);
});