From f56ce9d3b1ad33b31a445be8b497d45918643d8e Mon Sep 17 00:00:00 2001 From: hyl64 <78853927+hyl64@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:34:04 +0800 Subject: [PATCH] fix: guard chat file preview rendering when mime type is missing (#35355) Co-authored-by: Stephen Zhou --- .../__tests__/file-item.spec.tsx | 15 +++++++++++++++ .../file-uploader-in-chat-input/file-item.tsx | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/__tests__/file-item.spec.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/__tests__/file-item.spec.tsx index c03f009cee..00dd7d9971 100644 --- a/web/app/components/base/file-uploader/file-uploader-in-chat-input/__tests__/file-item.spec.tsx +++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/__tests__/file-item.spec.tsx @@ -222,6 +222,21 @@ describe('FileItem (chat-input)', () => { expect(document.querySelector('audio')).not.toBeInTheDocument() }) + it('should not throw when file type is missing', () => { + expect(() => { + render( + , + ) + }).not.toThrow() + }) + it('should close video preview', () => { render( { - type.split('/')[0] === 'audio' && canPreview && previewUrl && ( + typeCategory === 'audio' && canPreview && previewUrl && ( { setPreviewUrl('') }} /> ) }