feat(dashboard): add performance and operations slices
This commit is contained in:
1 parent
69d560d5c5
commit
c7dec45abe
13 files changed
+1059
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
createLiveConsoleState,
|
||||
reduceLiveConsoleState,
|
||||
selectVisibleConsoleEntries,
|
||||
} from '../../apps/dashboard/src/features/operations/live-console-model.js';
|
||||
|
||||
function entry(id: string, level: 'debug' | 'info' | 'warn' | 'error', message: string) {
|
||||
return { id, occurredAt: '2026-08-08T12:00:00.000Z', level, message };
|
||||
}
|
||||
|
||||
describe('live console state', () => {
|
||||
it('bounds entries, rejects duplicate IDs, and filters by level and search', () => {
|
||||
let state = createLiveConsoleState(2);
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('1', 'info', 'Sync started') });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('2', 'error', 'Matrix failed') });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('2', 'error', 'duplicate') });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('3', 'warn', 'Sync slow') });
|
||||
state = reduceLiveConsoleState(state, { type: 'set-level', level: 'warn' });
|
||||
state = reduceLiveConsoleState(state, { type: 'set-search', search: 'sync' });
|
||||
|
||||
expect(state.entries.map(({ id }) => id)).toEqual(['2', '3']);
|
||||
expect(selectVisibleConsoleEntries(state).map(({ id }) => id)).toEqual(['3']);
|
||||
});
|
||||
|
||||
it('holds bounded pending entries while paused and merges them on resume', () => {
|
||||
let state = createLiveConsoleState(2);
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('1', 'info', 'one') });
|
||||
state = reduceLiveConsoleState(state, { type: 'set-paused', paused: true });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('2', 'info', 'two') });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('3', 'info', 'three') });
|
||||
state = reduceLiveConsoleState(state, { type: 'append', entry: entry('4', 'info', 'four') });
|
||||
|
||||
expect(state.entries.map(({ id }) => id)).toEqual(['1']);
|
||||
expect(state.pendingEntries.map(({ id }) => id)).toEqual(['3', '4']);
|
||||
|
||||
state = reduceLiveConsoleState(state, { type: 'set-paused', paused: false });
|
||||
expect(state.entries.map(({ id }) => id)).toEqual(['3', '4']);
|
||||
expect(state.pendingEntries).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user