@@ -1057,4 +1057,86 @@ describe("ChatTextArea", () => {
10571057 expect ( apiConfigDropdown ) . toHaveAttribute ( "disabled" )
10581058 } )
10591059 } )
1060+
1061+ describe ( "send button visibility" , ( ) => {
1062+ it ( "should show send button when there are images but no text" , ( ) => {
1063+ const { container } = render (
1064+ < ChatTextArea
1065+ { ...defaultProps }
1066+ inputValue = ""
1067+ selectedImages = { [ "data:image/png;base64,test1" , "data:image/png;base64,test2" ] }
1068+ /> ,
1069+ )
1070+
1071+ // Find the send button by looking for the button with SendHorizontal icon
1072+ const buttons = container . querySelectorAll ( "button" )
1073+ const sendButton = Array . from ( buttons ) . find (
1074+ ( button ) => button . querySelector ( ".lucide-send-horizontal" ) !== null ,
1075+ )
1076+
1077+ expect ( sendButton ) . toBeInTheDocument ( )
1078+
1079+ // Check that the button is visible (has opacity-100 class when content exists)
1080+ expect ( sendButton ) . toHaveClass ( "opacity-100" )
1081+ expect ( sendButton ) . toHaveClass ( "pointer-events-auto" )
1082+ expect ( sendButton ) . not . toHaveClass ( "opacity-0" )
1083+ expect ( sendButton ) . not . toHaveClass ( "pointer-events-none" )
1084+ } )
1085+
1086+ it ( "should hide send button when there is no text and no images" , ( ) => {
1087+ const { container } = render ( < ChatTextArea { ...defaultProps } inputValue = "" selectedImages = { [ ] } /> )
1088+
1089+ // Find the send button by looking for the button with SendHorizontal icon
1090+ const buttons = container . querySelectorAll ( "button" )
1091+ const sendButton = Array . from ( buttons ) . find (
1092+ ( button ) => button . querySelector ( ".lucide-send-horizontal" ) !== null ,
1093+ )
1094+
1095+ expect ( sendButton ) . toBeInTheDocument ( )
1096+
1097+ // Check that the button is hidden (has opacity-0 class when no content)
1098+ expect ( sendButton ) . toHaveClass ( "opacity-0" )
1099+ expect ( sendButton ) . toHaveClass ( "pointer-events-none" )
1100+ expect ( sendButton ) . not . toHaveClass ( "opacity-100" )
1101+ expect ( sendButton ) . not . toHaveClass ( "pointer-events-auto" )
1102+ } )
1103+
1104+ it ( "should show send button when there is text but no images" , ( ) => {
1105+ const { container } = render ( < ChatTextArea { ...defaultProps } inputValue = "Some text" selectedImages = { [ ] } /> )
1106+
1107+ // Find the send button by looking for the button with SendHorizontal icon
1108+ const buttons = container . querySelectorAll ( "button" )
1109+ const sendButton = Array . from ( buttons ) . find (
1110+ ( button ) => button . querySelector ( ".lucide-send-horizontal" ) !== null ,
1111+ )
1112+
1113+ expect ( sendButton ) . toBeInTheDocument ( )
1114+
1115+ // Check that the button is visible
1116+ expect ( sendButton ) . toHaveClass ( "opacity-100" )
1117+ expect ( sendButton ) . toHaveClass ( "pointer-events-auto" )
1118+ } )
1119+
1120+ it ( "should show send button when there is both text and images" , ( ) => {
1121+ const { container } = render (
1122+ < ChatTextArea
1123+ { ...defaultProps }
1124+ inputValue = "Some text"
1125+ selectedImages = { [ "data:image/png;base64,test1" ] }
1126+ /> ,
1127+ )
1128+
1129+ // Find the send button by looking for the button with SendHorizontal icon
1130+ const buttons = container . querySelectorAll ( "button" )
1131+ const sendButton = Array . from ( buttons ) . find (
1132+ ( button ) => button . querySelector ( ".lucide-send-horizontal" ) !== null ,
1133+ )
1134+
1135+ expect ( sendButton ) . toBeInTheDocument ( )
1136+
1137+ // Check that the button is visible
1138+ expect ( sendButton ) . toHaveClass ( "opacity-100" )
1139+ expect ( sendButton ) . toHaveClass ( "pointer-events-auto" )
1140+ } )
1141+ } )
10601142} )
0 commit comments