test(web): assert the whole turn/end reason in the Cordis lifecycle

The assertion compared a rebuilt object that carried only reason.kind,
so a failing turn reported "expected { kind: 'error' }" with no payload.
TurnEndReasonMap is merge-extensible and several variants carry the only
record of why the turn ended: error holds LlmFailure (message, code) and
aborted holds its TurnEndCancelCause.

Compare the reason itself. completed declares kind as its only field, so
the passing path is unchanged, and any failure prints the full variant
payload without a per-variant branch.
This commit is contained in:
Chinesezjc
2026-08-13 20:56:05 +08:00
parent fb82698709
commit 3a46bd6798

View File

@@ -47,8 +47,7 @@ function assertCompleteCordisLifecycle(events: readonly SessionEvent[]): void {
(event): event is Extract<SessionEvent, { type: 'turn/end' }> => event.type === 'turn/end', (event): event is Extract<SessionEvent, { type: 'turn/end' }> => event.type === 'turn/end',
) )
const reason = turnEnd?.data.reason const reason = turnEnd?.data.reason
const reasonSummary = { kind: reason?.kind } expect(reason).toEqual({ kind: 'completed' })
expect(reasonSummary).toEqual({ kind: 'completed' })
const calls = events.filter( const calls = events.filter(
(event): event is Extract<SessionEvent, { type: 'tool/call' }> => event.type === 'tool/call', (event): event is Extract<SessionEvent, { type: 'tool/call' }> => event.type === 'tool/call',