test: replace tuple casts with structural lifecycle assertions in command specs

Two aggregate-typecheck errors the package-level tsc -b (rootDir=src) never
saw: the commands spec's two-tuple as-cast over the lifecycle slice
(TS2352, host aggregate) becomes a plain commandId projection, and the
fixture spec still read the deleted result member off the pure-admission
execute value (TS2339, client aggregate) — the matched bit is now asserted
as the whole response shape.
This commit is contained in:
imccyu
2026-07-27 23:06:52 +08:00
parent 4ddec0ba2f
commit 4fcfcf32d5
2 files changed
+5 -4

No files matched your search

@@ -76,8 +76,8 @@ describe('createFixtureApi commands/skills', () => {
for (const line of ['/nope', 'plain text', '/']) {
const response = await api.commands.execute(req({ sessionId: sid('fx-alpha'), line }), signal)
if (!response.result.ok) throw new Error('execute failed')
expect(response.result.value.matched).toBe(false)
expect(response.result.value.result).toBeUndefined()
// Pure admission value: the matched bit is the whole response shape.
expect(response.result.value).toEqual({ matched: false })
}
})
+3 -2
View File
@@ -307,8 +307,9 @@ describe('CommandService', () => {
{ type: 'command/run', data: { name: 'deploy', line: '/deploy now', source: { kind: 'user' } } },
{ type: 'command/done', data: { kind: 'success', text: 'deployed' } },
])
const [run, done] = lifecycle as [{ data: { commandId: string } }, { data: { commandId: string } }]
expect(run.data.commandId).toBe(done.data.commandId)
const ids = lifecycle.map(event => (event.data as { commandId: string }).commandId)
expect(ids[0]).toBeTruthy()
expect(ids[0]).toBe(ids[1])
// Zero-step wrap: the pair stays turn-enclosed on an idle log.
expect(agent.session.events.map(event => event.type)).toEqual([
'turn/start', 'command/run', 'turn/end',