test(client): accept session creation timestamps

This commit is contained in:
_Kerman
2026-08-11 16:03:13 +08:00
parent bc390318ac
commit 34e90dc3fe

View File

@@ -264,7 +264,9 @@ 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([{ type: 'host/session-added', sessionId: createdId, blank: true, cwd: '/tmp/fixture' }]) expect(seen).toEqual([{
type: 'host/session-added', sessionId: createdId, createdAt: expect.any(Number), 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)
@@ -699,7 +701,9 @@ 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({ type: 'host/session-added', sessionId: id, blank: true, cwd: '/tmp/fixture' }) expect(seen[0]).toEqual({
type: 'host/session-added', sessionId: id, createdAt: expect.any(Number), blank: true, cwd: '/tmp/fixture',
})
expect(seen[1]).toMatchObject({ expect(seen[1]).toMatchObject({
type: 'host/workspace-changed', type: 'host/workspace-changed',
workspace: { workspaceId: 'fx-ws-fixture', sessionIds: [id, 'fx-alpha', 'fx-beta', 'fx-gamma'] }, workspace: { workspaceId: 'fx-ws-fixture', sessionIds: [id, 'fx-alpha', 'fx-beta', 'fx-gamma'] },
@@ -728,7 +732,10 @@ 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({ type: 'host/session-added', sessionId: preallocated, blank: true, cwd: made.result.value.workspace.path }) expect(frames[1]).toEqual({
type: 'host/session-added', sessionId: preallocated, createdAt: expect.any(Number), blank: true,
cwd: made.result.value.workspace.path,
})
const retried = await api.sessions.create(req({ const retried = await api.sessions.create(req({
workspaceId: made.result.value.workspace.workspaceId, workspaceId: made.result.value.workspace.workspaceId,