Selaa lähdekoodia

test(workflow): avoid unbound view builder reference

pku-xht 1 kuukausi sitten
vanhempi
sitoutus
8e3418e925
1 muutettua tiedostoa jossa 3 lisäystä ja 4 poistoa
  1. 3 4
      packages/client/ui-workflow-run/tests/workflow-run.spec.tsx

+ 3 - 4
packages/client/ui-workflow-run/tests/workflow-run.spec.tsx

@@ -227,13 +227,12 @@ describe('workflow-run Conversation Definition', () => {
     const unrelated = matched(at(3, 'turn/start', { turn: 1 }), 'update')
     expect(workflowRunDefinition.update(updateContext, unrelated)).toBe(state)
     expect(workflowRunDefinition.target).toBe('chat')
-    const buildViewNode = workflowRunDefinition.buildViewNode
-    if (buildViewNode === undefined) throw new Error('expected workflow Chat view builder')
-    expect(buildViewNode({
+    expect(workflowRunDefinition.buildViewNode?.({
       ...updateContext, matches: [], start: undefined,
     })).toBeNull()
-    const directNode = buildViewNode(updateContext) as ChatConversationViewNode | null
+    const directNode = workflowRunDefinition.buildViewNode?.(updateContext) as ChatConversationViewNode | null | undefined
     if (directNode === null) throw new Error('expected direct workflow Chat node')
+    if (directNode === undefined) throw new Error('expected workflow Chat view builder')
     expect(directNode.kind).toBe('workflow-run')
     expect((directNode.data as WorkflowRunChatData).status).toBe('running')
   })