Improve activity journal readability
This commit is contained in:
@@ -7,6 +7,7 @@ const root = path.resolve(import.meta.dirname, '../..');
|
||||
const page = fs.readFileSync(path.join(root, 'src/web/components/ClientOverviewPage.tsx'), 'utf8');
|
||||
const feature = fs.readFileSync(path.join(root, 'src/web/features/activity-journal/ActivityJournalFeature.tsx'), 'utf8');
|
||||
const styles = fs.readFileSync(path.join(root, 'src/web/styles/features/activity-journal.css'), 'utf8');
|
||||
const model = fs.readFileSync(path.join(root, 'src/web/features/activity-journal/activityJournalModel.ts'), 'utf8');
|
||||
|
||||
test('journal is the last Gateway-only drawer and refreshes whenever it opens', () => {
|
||||
assert.match(page, /<RoutingToggle[\s\S]*\{isGateway && <ActivityJournalToggle/);
|
||||
@@ -24,4 +25,10 @@ test('journal presents 30-day grouped history with refresh, pagination and stabl
|
||||
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(styles, /\.client-journal-event\.is-switch-primary::before \{ background: var\(--harbor-connect\); \}/);
|
||||
assert.match(styles, /\.client-journal-event\.is-switch-reserve::before \{ background: var\(--harbor-gateway\); \}/);
|
||||
assert.match(styles, /\.client-journal-event\.is-warning::before \{ background: oklch\(0\.68 0\.14 72\); \}/);
|
||||
assert.match(styles, /\.client-journal-event\.is-error::before \{ background: oklch\(0\.68 0\.15 28\); \}/);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
compactActivityJournalEvents,
|
||||
refreshStreakCopy,
|
||||
} from '../../.test-dist/src/web/features/activity-journal/activityJournalModel.js';
|
||||
|
||||
function event(id, occurredAt, type = 'subscription.refreshed', data = {}) {
|
||||
return {
|
||||
id,
|
||||
occurredAt,
|
||||
type,
|
||||
severity: 'info',
|
||||
source: type.startsWith('subscription.') ? 'subscription' : 'connection',
|
||||
dedupeKey: null,
|
||||
data: type === 'subscription.refreshed'
|
||||
? { profileLabel: 'Дом', serverCount: 8, added: 0, removed: 0, ...data }
|
||||
: data,
|
||||
};
|
||||
}
|
||||
|
||||
test('adjacent unchanged refreshes become one observed success streak', () => {
|
||||
const items = compactActivityJournalEvents([
|
||||
event('newest', '2026-08-25T15:00:00.000Z', 'subscription.refreshed', { profileLabel: 'Дом' }),
|
||||
event('middle', '2026-08-25T13:30:00.000Z', 'subscription.refreshed', { profileLabel: 'Работа' }),
|
||||
event('oldest', '2026-08-25T12:00:00.000Z', 'subscription.refreshed', { profileLabel: 'Дом' }),
|
||||
]);
|
||||
|
||||
assert.equal(items.length, 1);
|
||||
assert.deepEqual(items[0].refreshStreak, {
|
||||
count: 3,
|
||||
firstOccurredAt: '2026-08-25T12:00:00.000Z',
|
||||
profileLabels: ['Дом', 'Работа'],
|
||||
});
|
||||
assert.deepEqual(refreshStreakCopy(items[0]), [
|
||||
'Подписки обновлялись без ошибок',
|
||||
'3 ч всё хорошо · 3 обновления · подписок: 2',
|
||||
]);
|
||||
});
|
||||
|
||||
test('another event and a changed server list break refresh streaks', () => {
|
||||
const items = compactActivityJournalEvents([
|
||||
event('routine-new', '2026-08-25T15:00:00.000Z'),
|
||||
event('started', '2026-08-25T14:50:00.000Z', 'connection.started', { profileLabel: 'Дом', serverLabel: 'Амстердам' }),
|
||||
event('changed', '2026-08-25T14:45:00.000Z', 'subscription.refreshed', { added: 1 }),
|
||||
event('routine-old', '2026-08-25T14:30:00.000Z'),
|
||||
]);
|
||||
|
||||
assert.equal(items.length, 4);
|
||||
assert.ok(items.every(({ refreshStreak }) => refreshStreak === null));
|
||||
});
|
||||
|
||||
test('a local calendar-day boundary breaks an otherwise adjacent streak', () => {
|
||||
const newer = new Date(2026, 7, 25, 0, 5).toISOString();
|
||||
const older = new Date(2026, 7, 24, 23, 55).toISOString();
|
||||
const items = compactActivityJournalEvents([
|
||||
event('new-day', newer),
|
||||
event('old-day', older),
|
||||
]);
|
||||
|
||||
assert.equal(items.length, 2);
|
||||
assert.ok(items.every(({ refreshStreak }) => refreshStreak === null));
|
||||
});
|
||||
|
||||
test('one-profile streak names the profile and keeps the latest event identity', () => {
|
||||
const items = compactActivityJournalEvents([
|
||||
event('newest', '2026-08-25T15:15:00.000Z'),
|
||||
event('oldest', '2026-08-25T15:00:00.000Z'),
|
||||
]);
|
||||
|
||||
assert.equal(items[0].event.id, 'newest');
|
||||
assert.deepEqual(refreshStreakCopy(items[0]), [
|
||||
'Подписки обновлялись без ошибок',
|
||||
'15 мин всё хорошо · 2 обновления · Дом',
|
||||
]);
|
||||
});
|
||||
@@ -39,26 +39,26 @@ const expectedImports = [
|
||||
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
||||
const acceptedLedger = {
|
||||
counts: {
|
||||
cascadeEdges: 1037,
|
||||
cascadeEdges: 1098,
|
||||
customProperties: 106,
|
||||
declarations: 4110,
|
||||
declarations: 4122,
|
||||
important: 0,
|
||||
keyframes: 50,
|
||||
media: 17,
|
||||
rules: 1106,
|
||||
variableReferences: 1049,
|
||||
rules: 1113,
|
||||
variableReferences: 1051,
|
||||
},
|
||||
hashes: {
|
||||
cascadeEdges: 'da134201db19eb45f82a1169f571fbea293ff8a76c6bcb24d3b10b060bba2fbd',
|
||||
cascadeEdges: '9814b59202515f6993f2836d529b7bb9e25e632b0803c832a363ac264e5b60a3',
|
||||
customProperties: 'fd6f16069f9fe3526f09d4d574431ddae67150d8e7a8a40e04c9fd2d179ec7ac',
|
||||
declarations: '89d33ebe8f3b462b0dcb3ae45bf2710d9a8633033047d025aa317b9e35d4d2b1',
|
||||
declarations: 'dcbf716667469136ad6c25412fb24741c3b66749ceefb799d5785a6668dbf9de',
|
||||
duplicateKeyframes: '4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945',
|
||||
duplicateSelectors: '8982145dba05b33bf1c93b2d54cfbe76305b276ff3c657aa020144016ada5848',
|
||||
keyframes: 'af4b9ae18d070fd2462a9b050293f3821bf5017c6e7cc53bbe18dc826f0fe3b9',
|
||||
ruleDeclarationSequences: '17a00d972ccc4ecb5450cfc5abd385602b6fd3911085e63c375d69df70bbda7f',
|
||||
selectors: '28220ffd959c5f11f9956ebe90eb201c7fe3d4733b0ad6f756ecdc03f8512d13',
|
||||
variableReferences: '09c3fc03be5d841b5276279ae40557f75ca79ef2c8b21f7578e67c8801f2a87c',
|
||||
witnesses: 'ff6fe62b26aaae6c9171e176b9fd6176e13df145ce30998d83d52d696bb0ad8c',
|
||||
ruleDeclarationSequences: '55167d84597ea8e8a4c4898f8fc8431593e920dc2e089728cc18c52f31d8c2cb',
|
||||
selectors: '2ab1759842aadbf1e733e9fc97946f48578903bb47d192b0b373329262982299',
|
||||
variableReferences: '2065fa19b325d995769988999b4e5dc51b54e8b011af39397f980584c3fffbe4',
|
||||
witnesses: '2ade0023244f8fc6a2fed0b2e1c3a99c4055c32abd6d8bfcd0d5f117a48f05bb',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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-CpsQVQ8c.css']);
|
||||
assert.deepEqual(assets, ['index-BH_msVtT.css']);
|
||||
const built = fs.readFileSync(path.join(root, 'dist/assets', assets[0]));
|
||||
assert.equal(built.byteLength, 156271);
|
||||
assert.equal(sha256(built), '244fa71e9354cb1f81233cc630b8d5014c4f8ad910ad96dae4eee637d5c312e6');
|
||||
assert.equal(built.byteLength, 156918);
|
||||
assert.equal(sha256(built), 'a1eafbf8c9c89a57478ba5c78d8b2a2fa1d44bcc8dc7bb747cba2889096509c5');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user