@@ -8,7 +8,7 @@ import { JSONRPCEndpoint, LspClient } from './lspClient'
88import { pathToFileURL } from 'url'
99import * as crypto from 'crypto'
1010import { EncryptionInitialization } from '@aws/lsp-core'
11- import { authenticateServer , decryptObjectWithKey , encryptObjectWithKey } from './testUtils'
11+ import { authenticateServer , decryptObjectWithKey , encryptObjectWithKey , normalizePath } from './testUtils'
1212import { ChatParams , ChatResult } from '@aws/language-server-runtimes/protocol'
1313import * as fs from 'fs'
1414
@@ -172,7 +172,9 @@ describe('Q Agentic Chat Server Integration Tests', async () => {
172172 msg => msg . type === 'tool' && msg . fileList ?. rootFolderTitle === '1 file read'
173173 )
174174 expect ( fsReadMessage ) . to . exist
175- expect ( fsReadMessage ?. fileList ?. filePaths ) . to . include . members ( [ path . join ( rootPath , 'test.py' ) ] )
175+ const expectedPath = path . join ( rootPath , 'test.py' )
176+ const actualPaths = fsReadMessage ?. fileList ?. filePaths ?. map ( normalizePath ) || [ ]
177+ expect ( actualPaths ) . to . include . members ( [ normalizePath ( expectedPath ) ] )
176178 expect ( fsReadMessage ?. messageId ?. startsWith ( 'tooluse_' ) ) . to . be . true
177179 } )
178180
@@ -192,7 +194,8 @@ describe('Q Agentic Chat Server Integration Tests', async () => {
192194 msg => msg . type === 'tool' && msg . fileList ?. rootFolderTitle === '1 directory listed'
193195 )
194196 expect ( listDirectoryMessage ) . to . exist
195- expect ( listDirectoryMessage ?. fileList ?. filePaths ) . to . include . members ( [ rootPath ] )
197+ const actualPaths = listDirectoryMessage ?. fileList ?. filePaths ?. map ( normalizePath ) || [ ]
198+ expect ( actualPaths ) . to . include . members ( [ normalizePath ( rootPath ) ] )
196199 expect ( listDirectoryMessage ?. messageId ?. startsWith ( 'tooluse_' ) ) . to . be . true
197200 } )
198201
@@ -216,12 +219,17 @@ describe('Q Agentic Chat Server Integration Tests', async () => {
216219 expect ( executeBashMessage ?. body ) . to . include ( 'test.ts' )
217220 } )
218221
219- it ( 'waits for user acceptance when executing mutable bash commands' , async ( ) => {
222+ it ( 'waits for user acceptance when executing mutable bash commands' , async function ( ) {
223+ const command =
224+ process . platform === 'win32'
225+ ? 'echo %date% > timestamp.txt && echo "Timestamp saved"'
226+ : 'date > timestamp.txt && echo "Timestamp saved"'
227+
220228 const encryptedMessage = await encryptObjectWithKey < ChatParams > (
221229 {
222230 tabId,
223231 prompt : {
224- prompt : `Run this command using the executeBash tool: \`date > timestamp.txt && echo "Timestamp saved" \`` ,
232+ prompt : `Run this command using the executeBash tool: \`${ command } \`` ,
225233 } ,
226234 } ,
227235 encryptionKey
@@ -367,6 +375,7 @@ describe('Q Agentic Chat Server Integration Tests', async () => {
367375 )
368376 expect ( fileSearchMessage ) . to . exist
369377 expect ( fileSearchMessage ?. messageId ?. startsWith ( 'tooluse_' ) ) . to . be . true
370- expect ( fileSearchMessage ?. fileList ?. filePaths ) . to . include . members ( [ rootPath ] )
378+ const actualPaths = fileSearchMessage ?. fileList ?. filePaths ?. map ( normalizePath ) || [ ]
379+ expect ( actualPaths ) . to . include . members ( [ normalizePath ( rootPath ) ] )
371380 } )
372381} )
0 commit comments