This commit is contained in:
Yufeng He 2026-06-26 01:52:09 +08:00 committed by GitHub
commit 26efca4b4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -92,6 +92,13 @@ describe('chat/chat/utils.ts', () => {
expect(result.files2[0]).toHaveProperty('processed', true)
})
it('handles an empty multiFiles array without throwing', () => {
const inputs = { files1: [] }
const inputsForm = [{ variable: 'files1', type: InputVarType.multiFiles as string }]
const result = getProcessedInputs(inputs, inputsForm as InputForm[])
expect(result.files1).toEqual([])
})
it('processes jsonObject parsing correct json', () => {
const inputs = {
json1: '{"key": "value"}',

View File

@ -47,7 +47,7 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
processedInputs[item.variable] = getProcessedFiles([inputValue])[0]
}
else if (item.type === InputVarType.multiFiles) {
if ('transfer_method' in inputValue[0])
if (inputValue[0] && 'transfer_method' in inputValue[0])
processedInputs[item.variable] = inputValue.map(processInputFileFromServer)
else
processedInputs[item.variable] = getProcessedFiles(inputValue)