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
@@ -16,22 +16,40 @@ test('journal is the last Gateway-only drawer and refreshes whenever it opens',
assert.match(feature, /assertActivityJournalPage\(await loadPage\(cursor\)\)/);
});
test('journal presents 30-day grouped history with refresh, pagination and stable states', () => {
test('journal presents a semantic responsive timeline with stable states', () => {
assert.match(feature, /Важные события хранятся 30 дней/);
assert.match(feature, /Сегодня[\s\S]*Вчера/);
assert.match(feature, /Обновить журнал/);
assert.match(feature, /M5 8V4m0 4h4/);
assert.match(feature, /Показать ещё/);
assert.match(feature, /Журнал временно недоступен[\s\S]*Повторить/);
assert.match(styles, /\.client-journal-skeleton/);
assert.match(styles, /@media \(prefers-reduced-motion: reduce\)/);
assert.match(feature, /compactActivityJournalEvents\(events\)/);
assert.match(model, /Подписки обновлялись без ошибок/);
assert.match(feature, /<ol>[\s\S]*<li[\s\S]*<time dateTime=\{event\.occurredAt\}/);
assert.match(feature, /data-event-type=\{event\.type\}[\s\S]*data-severity=\{event\.severity\}[\s\S]*data-target-role=/);
assert.match(styles, /\.client-journal-event::before \{[^}]*background: var\(--client-journal-tone\); \}/);
const rowRule = styles.match(/\.client-journal-groups li \{[^}]*\}/)?.[0] || '';
const lineRule = styles.match(/\.client-journal-groups ol::before \{[^}]*\}/)?.[0] || '';
const dotRule = styles.match(/\.client-journal-event::before \{[^}]*\}/)?.[0] || '';
assert.match(rowRule, /min-height: 58px/);
assert.match(rowRule, /grid-template-columns: 52px minmax\(0, 1fr\)/);
assert.doesNotMatch(rowRule, /border-top/);
assert.match(lineRule, /width: 1px/);
assert.match(lineRule, /inset: 0 auto 0 -8px/);
assert.match(lineRule, /background: color-mix\(in oklch, var\(--client-border\) 48%, transparent\)/);
assert.doesNotMatch(lineRule, /--client-journal-tone|animation|transition/);
assert.match(dotRule, /width: 8px/);
assert.match(dotRule, /height: 8px/);
assert.match(dotRule, /border-radius: 50%/);
assert.match(dotRule, /inset: 15px auto auto -11\.5px/);
assert.match(dotRule, /background: var\(--client-journal-tone\)/);
assert.doesNotMatch(dotRule, /animation|transition/);
assert.match(styles, /\.client-journal-event \.client-journal-time span \{ color: var\(--client-journal-tone\); \}/);
assert.match(styles, /\[data-event-type='subscription\.refreshed'\][\s\S]*\[data-event-type='failover\.recovered'\][\s\S]*--client-journal-tone: var\(--harbor-connect\)/);
assert.match(styles, /\[data-target-role='reserve'\] \{ --client-journal-tone: var\(--harbor-gateway\); \}/);
assert.match(styles, /\[data-event-type='failover\.waiting_for_idle'\][\s\S]*\[data-severity='warning'\] \{ --client-journal-tone: oklch\(0\.68 0\.14 72\); \}/);
assert.match(styles, /\[data-event-type='failover\.primary_recovered'\][\s\S]*--client-journal-tone: var\(--harbor-connect\)/);
assert.match(styles, /\[data-event-type='failover\.reserve_recovered'\][\s\S]*--client-journal-tone: var\(--harbor-gateway\)/);
assert.match(styles, /\[data-severity='warning'\] \{ --client-journal-tone: oklch\(0\.68 0\.14 72\); \}/);
assert.match(styles, /\[data-severity='error'\] \{ --client-journal-tone: oklch\(0\.68 0\.15 28\); \}/);
assert.match(styles, /@media \(max-width: 560px\) \{[\s\S]*?\.client-journal-groups li \{[^}]*grid-template-columns: 1fr;[^}]*\}[\s\S]*?\.client-journal-time \{[^}]*display: flex;/);
assert.match(styles, /@media \(prefers-reduced-motion: reduce\) \{[^}]*animation: none;/);
});
+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);
});
+12 -12
View File
@@ -39,25 +39,25 @@ const expectedImports = [
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
const acceptedLedger = {
counts: {
cascadeEdges: 1054,
cascadeEdges: 1058,
customProperties: 111,
declarations: 4123,
declarations: 4131,
important: 0,
keyframes: 50,
media: 17,
rules: 1113,
rules: 1114,
variableReferences: 1055,
},
hashes: {
cascadeEdges: 'c3b2ebc3f49891437122b19af5e9a42e7db11a311ecb4c2c76446c1541fe1023',
customProperties: '14fb162f1c6d754e69dd355fefb1a3a192a191324468f85d7a5d811665ce35b4',
declarations: '37b2f9f3ace795a826ad5eca6e6c4ba98ab6bb893aac87938bdeef826c383d63',
cascadeEdges: '77b6f34b3bc07b326f477cc436926fb9c4c573e5da9bba840c9bf937542b4488',
customProperties: '42f9fa9f2caaab6e5d90ae7d224563355822fa270083ea3496cfe2caaaea50bf',
declarations: 'ac1ac026d0c9d656fde9b28f78faea216a518a44bd2856b2005041f7cb4abd11',
duplicateKeyframes: '4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945',
duplicateSelectors: '8982145dba05b33bf1c93b2d54cfbe76305b276ff3c657aa020144016ada5848',
keyframes: 'af4b9ae18d070fd2462a9b050293f3821bf5017c6e7cc53bbe18dc826f0fe3b9',
ruleDeclarationSequences: '24377c2c29079886b62124688c2f858142913247426728c9b81f4b0a79e559e6',
selectors: '0b7624b5064d514a267e9bb45c40c445ce10f3e6998a34af7e1b604e4c0445b9',
variableReferences: '56dbfff5943b1ddd09d31b9d6699ff6680d07e5e562285f5f8268cc7566dca59',
ruleDeclarationSequences: '885efbe91db2ecb739f3c5aa42023576a849d28e639a1694ad13ed696bef77c5',
selectors: 'fbd8ac40b8d543a29b7140db906d1a3f7fc16a64ebbb380f358629f78657456a',
variableReferences: '70cef326744490dbb615e83457cd42b81b6f2322b0e93e4de6661d53db97e14b',
witnesses: 'e9f8c6e640c19375635847dc064edd6752a8216c6acd3c2aad6ffd18c1a4aaa2',
},
};
@@ -408,8 +408,8 @@ test('main owns one public stylesheet and the regrouped production CSS is determ
assert.equal((main.match(/import ['"][^'"]+\.css['"]/g) || []).length, 1);
const assets = fs.readdirSync(path.join(root, 'dist/assets')).filter((file) => file.endsWith('.css'));
assert.deepEqual(assets, ['index-Dng8HPUW.css']);
assert.deepEqual(assets, ['index-3s7H6Y0X.css']);
const built = fs.readFileSync(path.join(root, 'dist/assets', assets[0]));
assert.equal(built.byteLength, 157518);
assert.equal(sha256(built), '4fbc6c3e73a497101cacc456b580c6c4b8a58a44870856689719f2ada5b92bd7');
assert.equal(built.byteLength, 157874);
assert.equal(sha256(built), '99b874016cac6f1b617cd21d5a7ac957f491d8926fe78e8ba514d9313255488f');
});