mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-15 20:29:55 +00:00
refactor(sync): replace message reloads with incremental tail sync
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { ListCodexSessionsRpcResponseSchema } from './apiTypes'
|
||||
import { ListCodexSessionsRpcResponseSchema, MessagesQuerySchema } from './apiTypes'
|
||||
|
||||
describe('ListCodexSessionsRpcResponseSchema', () => {
|
||||
it('preserves Codex session messages when parsing runner RPC responses', () => {
|
||||
@@ -29,3 +29,41 @@ describe('ListCodexSessionsRpcResponseSchema', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('MessagesQuerySchema', () => {
|
||||
it('parses a forward cursor with a bounded snapshot and epoch', () => {
|
||||
expect(MessagesQuerySchema.parse({
|
||||
afterAt: '1000',
|
||||
afterSeq: '10',
|
||||
untilAt: '2000',
|
||||
untilSeq: '20',
|
||||
epoch: '3',
|
||||
limit: '200'
|
||||
})).toEqual({
|
||||
afterAt: 1000,
|
||||
afterSeq: 10,
|
||||
untilAt: 2000,
|
||||
untilSeq: 20,
|
||||
epoch: 3,
|
||||
limit: 200
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects mixed before and after directions', () => {
|
||||
expect(MessagesQuerySchema.safeParse({
|
||||
beforeAt: 1000,
|
||||
beforeSeq: 10,
|
||||
afterAt: 2000,
|
||||
afterSeq: 20
|
||||
}).success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects an unpaired or unscoped until cursor', () => {
|
||||
expect(MessagesQuerySchema.safeParse({ untilAt: 2000, untilSeq: 20 }).success).toBe(false)
|
||||
expect(MessagesQuerySchema.safeParse({ afterAt: 1000, afterSeq: 10, untilAt: 2000 }).success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects epoch without a forward cursor', () => {
|
||||
expect(MessagesQuerySchema.safeParse({ epoch: 1 }).success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user