@@ -868,19 +868,15 @@ describe("ChatTextArea", () => {
868868
869869 render ( < ChatTextArea { ...defaultProps } isEditMode = { true } /> )
870870
871- // Should show edit button (codicon-edit)
872- const editButton = screen . getByRole ( "button" , {
873- name : ( _ , element ) => {
874- return element . querySelector ( ".codicon-edit" ) !== null
875- } ,
871+ // Should show save button in edit mode
872+ const saveButton = screen . getByRole ( "button" , {
873+ name : / s a v e / i,
876874 } )
877- expect ( editButton ) . toBeInTheDocument ( )
875+ expect ( saveButton ) . toBeInTheDocument ( )
878876
879- // Should not show send button (codicon-send)
877+ // Should not show send button in edit mode
880878 const sendButton = screen . queryByRole ( "button" , {
881- name : ( _ , element ) => {
882- return element . querySelector ( ".codicon-send" ) !== null
883- } ,
879+ name : / s e n d / i,
884880 } )
885881 expect ( sendButton ) . not . toBeInTheDocument ( )
886882 } )
@@ -895,21 +891,17 @@ describe("ChatTextArea", () => {
895891
896892 render ( < ChatTextArea { ...defaultProps } isEditMode = { false } /> )
897893
898- // Should show send button (codicon-send)
894+ // Should show send button when not in edit mode
899895 const sendButton = screen . getByRole ( "button" , {
900- name : ( _ , element ) => {
901- return element . querySelector ( ".codicon-send" ) !== null
902- } ,
896+ name : / s e n d / i,
903897 } )
904898 expect ( sendButton ) . toBeInTheDocument ( )
905899
906- // Should not show edit button (codicon-edit)
907- const editButton = screen . queryByRole ( "button" , {
908- name : ( _ , element ) => {
909- return element . querySelector ( ".codicon-edit" ) !== null
910- } ,
900+ // Should not show save button when not in edit mode
901+ const saveButton = screen . queryByRole ( "button" , {
902+ name : / s a v e / i,
911903 } )
912- expect ( editButton ) . not . toBeInTheDocument ( )
904+ expect ( saveButton ) . not . toBeInTheDocument ( )
913905 } )
914906
915907 it ( "should show cancel button in edit mode" , ( ) => {
@@ -943,7 +935,7 @@ describe("ChatTextArea", () => {
943935 expect ( cancelButton ) . not . toBeInTheDocument ( )
944936 } )
945937
946- it ( "should call onSend when edit button is clicked" , ( ) => {
938+ it ( "should call onSend when save button is clicked" , ( ) => {
947939 const onSend = vi . fn ( )
948940 ; ( useExtensionState as ReturnType < typeof vi . fn > ) . mockReturnValue ( {
949941 filePaths : [ ] ,
@@ -954,13 +946,11 @@ describe("ChatTextArea", () => {
954946
955947 render ( < ChatTextArea { ...defaultProps } isEditMode = { true } onSend = { onSend } /> )
956948
957- const editButton = screen . getByRole ( "button" , {
958- name : ( _ , element ) => {
959- return element . querySelector ( ".codicon-edit" ) !== null
960- } ,
949+ const saveButton = screen . getByRole ( "button" , {
950+ name : / s a v e / i,
961951 } )
962952
963- fireEvent . click ( editButton )
953+ fireEvent . click ( saveButton )
964954 expect ( onSend ) . toHaveBeenCalledTimes ( 1 )
965955 } )
966956
@@ -981,7 +971,7 @@ describe("ChatTextArea", () => {
981971 expect ( onCancel ) . toHaveBeenCalledTimes ( 1 )
982972 } )
983973
984- it ( "should disable edit button when sendingDisabled is true" , ( ) => {
974+ it ( "should disable save button when sendingDisabled is true" , ( ) => {
985975 ; ( useExtensionState as ReturnType < typeof vi . fn > ) . mockReturnValue ( {
986976 filePaths : [ ] ,
987977 openedTabs : [ ] ,
@@ -991,13 +981,11 @@ describe("ChatTextArea", () => {
991981
992982 render ( < ChatTextArea { ...defaultProps } isEditMode = { true } sendingDisabled = { true } /> )
993983
994- const editButton = screen . getByRole ( "button" , {
995- name : ( _ , element ) => {
996- return element . querySelector ( ".codicon-edit" ) !== null
997- } ,
984+ const saveButton = screen . getByRole ( "button" , {
985+ name : / s a v e / i,
998986 } )
999987
1000- expect ( editButton ) . toBeDisabled ( )
988+ expect ( saveButton ) . toBeDisabled ( )
1001989 } )
1002990
1003991 it ( "should disable cancel button when sendingDisabled is true" , ( ) => {
@@ -1014,7 +1002,7 @@ describe("ChatTextArea", () => {
10141002 expect ( cancelButton ) . toBeDisabled ( )
10151003 } )
10161004
1017- it ( "should have correct tooltip for edit button" , ( ) => {
1005+ it ( "should have correct tooltip for save button" , ( ) => {
10181006 ; ( useExtensionState as ReturnType < typeof vi . fn > ) . mockReturnValue ( {
10191007 filePaths : [ ] ,
10201008 openedTabs : [ ] ,
@@ -1024,17 +1012,16 @@ describe("ChatTextArea", () => {
10241012
10251013 render ( < ChatTextArea { ...defaultProps } isEditMode = { true } /> )
10261014
1027- const editButton = screen . getByRole ( "button" , {
1028- name : ( _ , element ) => {
1029- return element . querySelector ( ".codicon-edit" ) !== null
1030- } ,
1015+ // Look for the save button by its aria-label
1016+ const saveButton = screen . getByRole ( "button" , {
1017+ name : / s a v e / i,
10311018 } )
10321019
10331020 // Check that the button has the correct aria-label (which is used for tooltip)
1034- expect ( editButton ) . toHaveAttribute ( "aria-label" , expect . stringMatching ( / s a v e / i) )
1021+ expect ( saveButton ) . toHaveAttribute ( "aria-label" , expect . stringMatching ( / s a v e / i) )
10351022 } )
10361023
1037- it ( "should position cancel button correctly relative to camera button" , ( ) => {
1024+ it ( "should position cancel button correctly relative to image button" , ( ) => {
10381025 ; ( useExtensionState as ReturnType < typeof vi . fn > ) . mockReturnValue ( {
10391026 filePaths : [ ] ,
10401027 openedTabs : [ ] ,
@@ -1045,22 +1032,21 @@ describe("ChatTextArea", () => {
10451032 const { container } = render ( < ChatTextArea { ...defaultProps } isEditMode = { true } /> )
10461033
10471034 const cancelButton = screen . getByRole ( "button" , { name : / c a n c e l / i } )
1048- const cameraButton = screen . getByRole ( "button" , {
1049- name : ( _ , element ) => {
1050- return element . querySelector ( ".codicon-device-camera" ) !== null
1051- } ,
1035+ // Look for the image button by its aria-label
1036+ const imageButton = screen . getByRole ( "button" , {
1037+ name : / a d d .* i m a g e s / i,
10521038 } )
10531039
10541040 // Both buttons should be in the same container (bottom toolbar)
10551041 const bottomToolbar = container . querySelector ( ".flex.items-center.gap-0\\.5.shrink-0" )
10561042 expect ( bottomToolbar ) . toContainElement ( cancelButton )
1057- expect ( bottomToolbar ) . toContainElement ( cameraButton )
1043+ expect ( bottomToolbar ) . toContainElement ( imageButton )
10581044
1059- // Cancel button should come before camera button in DOM order
1045+ // Cancel button should come before image button in DOM order
10601046 const buttons = bottomToolbar ?. querySelectorAll ( "button" )
10611047 const cancelIndex = Array . from ( buttons || [ ] ) . indexOf ( cancelButton as HTMLButtonElement )
1062- const cameraIndex = Array . from ( buttons || [ ] ) . indexOf ( cameraButton as HTMLButtonElement )
1063- expect ( cancelIndex ) . toBeLessThan ( cameraIndex )
1048+ const imageIndex = Array . from ( buttons || [ ] ) . indexOf ( imageButton as HTMLButtonElement )
1049+ expect ( cancelIndex ) . toBeLessThan ( imageIndex )
10641050 } )
10651051 } )
10661052} )
0 commit comments