@@ -900,27 +900,14 @@ describe("webviewMessageHandler - terminalProfile", () => {
900900describe ( "webviewMessageHandler - requestTerminalProfiles" , ( ) => {
901901 beforeEach ( ( ) => {
902902 vi . clearAllMocks ( )
903- vi . spyOn ( Terminal , "resolveProfilePath" ) . mockImplementation ( ( profilePath ) => {
904- const candidates = Array . isArray ( profilePath ) ? profilePath : [ profilePath ]
905- const value = candidates . find (
906- ( candidate ) =>
907- typeof candidate === "string" && candidate . trim ( ) . length > 0 && ! candidate . includes ( "missing" ) ,
908- )
909- return typeof value === "string" ? value . trim ( ) : undefined
910- } )
911903 } )
912904
913905 afterEach ( ( ) => {
914906 vi . restoreAllMocks ( )
915907 } )
916908
917- it ( "posts sorted path-resolvable profile names for the active platform" , async ( ) => {
918- const mockGet = vi . fn ( ) . mockReturnValue ( {
919- "Git Bash" : { path : "C:\\Git\\bin\\bash.exe" } ,
920- bash : { path : "/bin/bash" } ,
921- PowerShell : { source : "PowerShell" } , // source-only — must be excluded
922- } )
923- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
909+ it ( "posts available profile names" , async ( ) => {
910+ vi . spyOn ( Terminal , "getAvailableProfileNames" ) . mockReturnValue ( [ "Git Bash" , "bash" ] )
924911
925912 await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
926913
@@ -930,23 +917,8 @@ describe("webviewMessageHandler - requestTerminalProfiles", () => {
930917 } )
931918 } )
932919
933- it ( "excludes source-only profiles that have no path field" , async ( ) => {
934- const mockGet = vi . fn ( ) . mockReturnValue ( {
935- PowerShell : { source : "PowerShell" } ,
936- "Windows PowerShell" : { source : "PowerShell" } ,
937- } )
938- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
939-
940- await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
941-
942- expect ( mockClineProvider . postMessageToWebview ) . toHaveBeenCalledWith ( {
943- type : "terminalProfiles" ,
944- profiles : [ ] ,
945- } )
946- } )
947-
948- it ( "posts an empty array when getConfiguration throws" , async ( ) => {
949- vi . mocked ( vscode . workspace . getConfiguration ) . mockImplementation ( ( ) => {
920+ it ( "posts an empty array when profile discovery throws" , async ( ) => {
921+ vi . spyOn ( Terminal , "getAvailableProfileNames" ) . mockImplementation ( ( ) => {
950922 throw new Error ( "config error" )
951923 } )
952924
@@ -957,65 +929,6 @@ describe("webviewMessageHandler - requestTerminalProfiles", () => {
957929 profiles : [ ] ,
958930 } )
959931 } )
960-
961- it ( "posts an empty array when no profiles are configured" , async ( ) => {
962- const mockGet = vi . fn ( ) . mockReturnValue ( undefined )
963- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
964-
965- await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
966-
967- expect ( mockClineProvider . postMessageToWebview ) . toHaveBeenCalledWith ( {
968- type : "terminalProfiles" ,
969- profiles : [ ] ,
970- } )
971- } )
972-
973- it ( "excludes profiles with empty or whitespace-only path strings" , async ( ) => {
974- const mockGet = vi . fn ( ) . mockReturnValue ( {
975- empty : { path : "" } ,
976- whitespace : { path : " " } ,
977- valid : { path : "/bin/bash" } ,
978- } )
979- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
980-
981- await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
982-
983- expect ( mockClineProvider . postMessageToWebview ) . toHaveBeenCalledWith ( {
984- type : "terminalProfiles" ,
985- profiles : [ "valid" ] ,
986- } )
987- } )
988-
989- it ( "excludes profiles with path arrays containing only empty or whitespace strings" , async ( ) => {
990- const mockGet = vi . fn ( ) . mockReturnValue ( {
991- emptyArray : { path : [ ] } ,
992- whitespaceArray : { path : [ "" , " " ] } ,
993- valid : { path : [ "/bin/bash" , "/usr/bin/bash" ] } ,
994- } )
995- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
996-
997- await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
998-
999- expect ( mockClineProvider . postMessageToWebview ) . toHaveBeenCalledWith ( {
1000- type : "terminalProfiles" ,
1001- profiles : [ "valid" ] ,
1002- } )
1003- } )
1004-
1005- it ( "excludes profiles whose executable cannot be resolved" , async ( ) => {
1006- const mockGet = vi . fn ( ) . mockReturnValue ( {
1007- missing : { path : "/missing/bash" } ,
1008- valid : { path : "/bin/bash" } ,
1009- } )
1010- vi . mocked ( vscode . workspace . getConfiguration ) . mockReturnValue ( { get : mockGet } as any )
1011-
1012- await webviewMessageHandler ( mockClineProvider , { type : "requestTerminalProfiles" } )
1013-
1014- expect ( mockClineProvider . postMessageToWebview ) . toHaveBeenCalledWith ( {
1015- type : "terminalProfiles" ,
1016- profiles : [ "valid" ] ,
1017- } )
1018- } )
1019932} )
1020933
1021934describe ( "webviewMessageHandler - openTerminalProfilePicker" , ( ) => {
0 commit comments