test(client): type session timestamp assertions

This commit is contained in:
_Kerman
2026-08-11 16:49:29 +08:00
parent 79b9f3d524
commit ed39516c20
@@ -264,9 +264,13 @@ describe('createFixtureApi', () => {
await consuming await consuming
if (!created.result.ok) throw new Error('create failed') if (!created.result.ok) throw new Error('create failed')
const createdId = created.result.value.sessionId const createdId = created.result.value.sessionId
expect(seen).toEqual([{ expect(seen).toHaveLength(1)
type: 'host/session-added', sessionId: createdId, createdAt: expect.any(Number), blank: true, cwd: '/tmp/fixture', const added = seen[0]
}]) if (added?.type !== 'host/session-added') throw new Error('session-added frame missing')
expect(Number.isFinite(added.createdAt)).toBe(true)
expect(added).toEqual({
type: 'host/session-added', sessionId: createdId, createdAt: added.createdAt, blank: true, cwd: '/tmp/fixture',
})
const list = await api.sessions.list(req({})) const list = await api.sessions.list(req({}))
if (!list.result.ok) throw new Error('list failed') if (!list.result.ok) throw new Error('list failed')
expect(list.result.value.items.some(s => s.sessionId === createdId)).toBe(true) expect(list.result.value.items.some(s => s.sessionId === createdId)).toBe(true)
@@ -701,8 +705,11 @@ describe('createFixtureApi', () => {
await consuming await consuming
// The session lands with the workspace's path as cwd, and the account // The session lands with the workspace's path as cwd, and the account
// write pushes the fresh workspace snapshot after session-added. // write pushes the fresh workspace snapshot after session-added.
expect(seen[0]).toEqual({ const added = seen[0]
type: 'host/session-added', sessionId: id, createdAt: expect.any(Number), blank: true, cwd: '/tmp/fixture', if (added?.type !== 'host/session-added') throw new Error('session-added frame missing')
expect(Number.isFinite(added.createdAt)).toBe(true)
expect(added).toEqual({
type: 'host/session-added', sessionId: id, createdAt: added.createdAt, blank: true, cwd: '/tmp/fixture',
}) })
expect(seen[1]).toMatchObject({ expect(seen[1]).toMatchObject({
type: 'host/workspace-changed', type: 'host/workspace-changed',
@@ -732,8 +739,11 @@ describe('createFixtureApi', () => {
expect(frames[0]).toMatchObject({ expect(frames[0]).toMatchObject({
type: 'host/workspace-changed', workspace: { sessionIds: [preallocated] }, type: 'host/workspace-changed', workspace: { sessionIds: [preallocated] },
}) })
expect(frames[1]).toEqual({ const added = frames[1]
type: 'host/session-added', sessionId: preallocated, createdAt: expect.any(Number), blank: true, if (added?.type !== 'host/session-added') throw new Error('session-added frame missing')
expect(Number.isFinite(added.createdAt)).toBe(true)
expect(added).toEqual({
type: 'host/session-added', sessionId: preallocated, createdAt: added.createdAt, blank: true,
cwd: made.result.value.workspace.path, cwd: made.result.value.workspace.path,
}) })