@@ -440,6 +440,59 @@ describe('ChatInput', () => {
440440 ) ;
441441 } ) ;
442442
443+ it ( 'should reject files with unsupported MIME types' , ( ) => {
444+ const onFilesSelected = jest . fn ( ) ;
445+ const { container } = render (
446+ < ChatInput { ...defaultProps } onFilesSelected = { onFilesSelected } />
447+ ) ;
448+
449+ const exe = new File ( [ 'binary' ] , 'malware.exe' , { type : 'application/x-msdownload' } ) ;
450+ selectFiles ( container , [ exe ] ) ;
451+
452+ expect ( onFilesSelected ) . not . toHaveBeenCalled ( ) ;
453+ expect ( mockAddWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'malware.exe' ) ) ;
454+ } ) ;
455+
456+ it ( 'should accept files matched by extension when MIME type is empty' , ( ) => {
457+ const onFilesSelected = jest . fn ( ) ;
458+ const { container } = render (
459+ < ChatInput { ...defaultProps } onFilesSelected = { onFilesSelected } />
460+ ) ;
461+
462+ // Linux browsers often report empty MIME type
463+ const file = new File ( [ '{"key":"val"}' ] , 'data.json' , { type : '' } ) ;
464+ selectFiles ( container , [ file ] ) ;
465+
466+ expect ( onFilesSelected ) . toHaveBeenCalledWith ( [ file ] ) ;
467+ } ) ;
468+
469+ it ( 'should reject files with unsupported extension and empty MIME type' , ( ) => {
470+ const onFilesSelected = jest . fn ( ) ;
471+ const { container } = render (
472+ < ChatInput { ...defaultProps } onFilesSelected = { onFilesSelected } />
473+ ) ;
474+
475+ const file = new File ( [ 'data' ] , 'image.png' , { type : '' } ) ;
476+ selectFiles ( container , [ file ] ) ;
477+
478+ expect ( onFilesSelected ) . not . toHaveBeenCalled ( ) ;
479+ expect ( mockAddWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'image.png' ) ) ;
480+ } ) ;
481+
482+ it ( 'should keep valid files and reject unsupported files in a mixed selection' , ( ) => {
483+ const onFilesSelected = jest . fn ( ) ;
484+ const { container } = render (
485+ < ChatInput { ...defaultProps } onFilesSelected = { onFilesSelected } />
486+ ) ;
487+
488+ const good = new File ( [ 'hello' ] , 'notes.txt' , { type : 'text/plain' } ) ;
489+ const bad = new File ( [ 'binary' ] , 'photo.jpg' , { type : 'image/jpeg' } ) ;
490+ selectFiles ( container , [ good , bad ] ) ;
491+
492+ expect ( onFilesSelected ) . toHaveBeenCalledWith ( [ good ] ) ;
493+ expect ( mockAddWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'photo.jpg' ) ) ;
494+ } ) ;
495+
443496 it ( 'should truncate file list to remaining capacity' , ( ) => {
444497 const onFilesSelected = jest . fn ( ) ;
445498 const { container } = render (
0 commit comments