- Introduced BufferedCommitQueue for efficient commit handling. - Updated workspaceLoadService to hydrate thread messages and branches more effectively. - Replaced adnifyDirService with workspaceFileRepository in workspaceStateRepository and workspaceStorageRuntime. - Modified workspaceStateService to stage workspace state persistence. - Enhanced shellRegistryService to integrate with persistenceCoordinator. - Added new session persistence types and interfaces for better type safety. - Implemented tests for agentSessionRepository and BufferedCommitQueue. - Removed outdated sessionDataLossGuards and sessionFileStore tests. - Added SQLite session store tests to ensure data integrity and migration handling. - Updated Vite configuration to include sessionStorage.worker for better build management.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { BufferedCommitQueue } from '@/shared/persistence/BufferedCommitQueue'
|
|
|
|
describe('BufferedCommitQueue', () => {
|
|
it('coalesces staged values and serializes commits', async () => {
|
|
vi.useFakeTimers()
|
|
const committed: number[] = []
|
|
const queue = new BufferedCommitQueue<number>({
|
|
delayMs: 100,
|
|
commit: async value => { committed.push(value) },
|
|
})
|
|
|
|
queue.stage(1)
|
|
queue.stage(2)
|
|
await vi.advanceTimersByTimeAsync(100)
|
|
|
|
expect(committed).toEqual([2])
|
|
vi.useRealTimers()
|
|
})
|
|
|
|
it('retains a failed value for an explicit retry', async () => {
|
|
let attempts = 0
|
|
const queue = new BufferedCommitQueue<string>({
|
|
delayMs: 10_000,
|
|
commit: async () => {
|
|
attempts += 1
|
|
if (attempts === 1) throw new Error('disk unavailable')
|
|
},
|
|
})
|
|
|
|
queue.stage('critical')
|
|
await expect(queue.flush()).rejects.toThrow('disk unavailable')
|
|
await expect(queue.flush()).resolves.toBeUndefined()
|
|
expect(attempts).toBe(2)
|
|
})
|
|
})
|