@@ -20,7 +20,7 @@ jest.mock('./useFlowNodes', () => ({
2020} ) )
2121
2222let mockNodes : ReturnType < typeof makeFlowNode > [ ] = [ ]
23- let mockAvailableNodes : { name : string ; inputs ?: { name : string } [ ] } [ ] = [ ]
23+ let mockAvailableNodes : { name : string ; inputs ?: { name : string } [ ] ; credential ?: { name : string ; type : string } } [ ] = [ ]
2424
2525describe ( 'useOpenNodeEditor' , ( ) => {
2626 beforeEach ( ( ) => {
@@ -112,6 +112,31 @@ describe('useOpenNodeEditor', () => {
112112 )
113113 } )
114114
115+ it ( 'should prepend credential param to inputParams when schema has credential' , ( ) => {
116+ mockAvailableNodes = [
117+ {
118+ name : 'llmAgentflow' ,
119+ inputs : [ { name : 'model' } ] ,
120+ credential : { name : 'credential' , type : 'credential' }
121+ }
122+ ]
123+ const { result } = renderHook ( ( ) => useOpenNodeEditor ( ) )
124+ result . current . openNodeEditor ( 'node-1' )
125+
126+ expect ( mockOpenEditDialog ) . toHaveBeenCalledWith ( 'node-1' , expect . objectContaining ( { name : 'llmAgentflow' } ) , [
127+ { name : 'credential' , type : 'credential' } ,
128+ { name : 'model' }
129+ ] )
130+ } )
131+
132+ it ( 'should not prepend credential when schema has no credential' , ( ) => {
133+ mockAvailableNodes = [ { name : 'llmAgentflow' , inputs : [ { name : 'model' } ] } ]
134+ const { result } = renderHook ( ( ) => useOpenNodeEditor ( ) )
135+ result . current . openNodeEditor ( 'node-1' )
136+
137+ expect ( mockOpenEditDialog ) . toHaveBeenCalledWith ( 'node-1' , expect . objectContaining ( { name : 'llmAgentflow' } ) , [ { name : 'model' } ] )
138+ } )
139+
115140 it ( 'should open dialog with empty inputs when schema has no inputs' , ( ) => {
116141 mockAvailableNodes = [ { name : 'llmAgentflow' } ] // no inputs property
117142 const { result } = renderHook ( ( ) => useOpenNodeEditor ( ) )
0 commit comments