fix: coverage
This commit is contained in:
@@ -78,13 +78,16 @@ class FixtureLocationIndex implements ChatLocationNodeIndex {
|
||||
class FixtureTurnDataStore implements ConversationLocationDataStore<ConversationTurnDataMap> {
|
||||
private readonly values = new Map<string, unknown>()
|
||||
|
||||
get<Key extends keyof ConversationTurnDataMap & string>(
|
||||
get<Key extends Extract<keyof ConversationTurnDataMap, string>>(
|
||||
key: Key,
|
||||
): Readonly<ConversationTurnDataMap[Key]> | undefined {
|
||||
return this.values.get(key) as Readonly<ConversationTurnDataMap[Key]> | undefined
|
||||
}
|
||||
|
||||
set<Key extends keyof ConversationTurnDataMap & string>(key: Key, value: ConversationTurnDataMap[Key]): void {
|
||||
set<Key extends Extract<keyof ConversationTurnDataMap, string>>(
|
||||
key: Key,
|
||||
value: ConversationTurnDataMap[Key],
|
||||
): void {
|
||||
this.values.set(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +181,14 @@ function makeHarness(init?: Partial<ConversationSnapshot>) {
|
||||
if (key !== 'conversation.chat.node') return opts?.fallback ?? null
|
||||
const nodeOwner = owner as RoutedChatNodeOwner
|
||||
const nodeKey = opts?.hookContext as string | undefined
|
||||
const useTurnData = ((dataKey: string) => props.useSession((snapshot) => {
|
||||
const location = nodeKey === undefined ? undefined : snapshot.chat.nodes.get(nodeKey)?.location
|
||||
return location?.kind === 'turn' || location?.kind === 'step'
|
||||
? location.turn.data.get(dataKey as never)
|
||||
: undefined
|
||||
})) as UseChatNodeTurnData
|
||||
const useTurnData = ((dataKey: string) => {
|
||||
return props.useSession((snapshot) => {
|
||||
const location = nodeKey === undefined ? undefined : snapshot.chat.nodes.get(nodeKey)?.location
|
||||
return location?.kind === 'turn' || location?.kind === 'step'
|
||||
? location.turn.data.get(dataKey as never)
|
||||
: undefined
|
||||
})
|
||||
}) as UseChatNodeTurnData
|
||||
const nodeProps = <Kind extends ChatNode['kind']>(): ChatNodeViewProps<Kind> => (
|
||||
{ ...props, ...nodeOwner, useTurnData } as unknown as ChatNodeViewProps<Kind>
|
||||
)
|
||||
@@ -226,7 +228,7 @@ function makeHarness(init?: Partial<ConversationSnapshot>) {
|
||||
case 'unknown':
|
||||
return <UnknownNodeView {...nodeProps<'unknown'>()} />
|
||||
case 'tool-call': {
|
||||
const block = (nodeOwner.node.data as { readonly root: ToolCallBlock }).root
|
||||
const block = nodeOwner.node.data.root
|
||||
const toolName = 'kind' in block ? block.call?.name ?? '' : block.name
|
||||
const tool = {
|
||||
callId: block.callId,
|
||||
@@ -843,7 +845,7 @@ describe('ChatView', () => {
|
||||
mounted()
|
||||
return () => { unmounted() }
|
||||
}, [])
|
||||
const root = (node.data as { readonly root: ToolCallBlock }).root
|
||||
const root = node.data.root
|
||||
return (
|
||||
<div data-testid="stateful-tool" data-state={'kind' in root ? 'settled' : 'running'}>
|
||||
{root.callId}
|
||||
|
||||
Reference in New Issue
Block a user