perf(realtime): make dashboard JSON diff linear

This commit is contained in:
2026-08-12 16:05:49 +00:00
parent 1e196e200f
commit 421b190bf2
4 changed files with 185 additions and 4 deletions
@@ -89,6 +89,31 @@ describe('createReadModelDelta', () => {
);
});
it('keeps the snapshot fallback when a positional patch is larger', async () => {
const store = new MemoryStore();
const initialValue = { values: Array.from({ length: 24 }, () => 'old') };
const initial = await createReadModelDelta({
store,
profile: 'hwe:default',
viewerId: 'user-1',
slice: 'context',
value: initialValue,
forceSnapshot: true,
});
const nextValue = { values: Array.from({ length: 24 }, () => 'new') };
const changed = await createReadModelDelta({
store,
profile: 'hwe:default',
viewerId: 'user-1',
slice: 'context',
value: nextValue,
knownRevision: initial.revision,
});
expect(changed).toMatchObject({ kind: 'snapshot', data: nextValue });
});
it('falls back to a snapshot when Redis is unavailable', async () => {
const store: ReadModelDeltaCacheStore = {
get: async () => {