Skip to content

Commit cffc5ce

Browse files
authored
test: fix integration tests on windows (#2041)
1 parent 9e4d0af commit cffc5ce

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

integration-tests/q-agentic-chat-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Integration tests for Q Agentic Chat Server",
55
"main": "out/index.js",
66
"scripts": {
7-
"clean": "rm -rf out/ node_modules/ tsconfig.tsbuildinfo .tsbuildinfo",
7+
"clean": "rimraf out/ node_modules/ tsconfig.tsbuildinfo .tsbuildinfo",
88
"compile": "tsc --build && cp -r src/tests/testFixture out/tests/",
99
"test-integ": "npm run compile && mocha --timeout 30000 \"./out/**/*.test.js\" --retries 2"
1010
},
@@ -22,6 +22,7 @@
2222
"jose": "^5.10.0",
2323
"json-rpc-2.0": "^1.7.1",
2424
"mocha": "^11.0.1",
25+
"rimraf": "^3.0.2",
2526
"typescript": "^5.0.0",
2627
"yauzl-promise": "^4.0.0"
2728
}

integration-tests/q-agentic-chat-server/src/tests/agenticChatInteg.test.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { JSONRPCEndpoint, LspClient } from './lspClient'
88
import { pathToFileURL } from 'url'
99
import * as crypto from 'crypto'
1010
import { EncryptionInitialization } from '@aws/lsp-core'
11-
import { authenticateServer, decryptObjectWithKey, encryptObjectWithKey } from './testUtils'
11+
import { authenticateServer, decryptObjectWithKey, encryptObjectWithKey, normalizePath } from './testUtils'
1212
import { ChatParams, ChatResult } from '@aws/language-server-runtimes/protocol'
1313
import * 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
})

integration-tests/q-agentic-chat-server/src/tests/testUtils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { UpdateCredentialsParams } from '@aws/language-server-runtimes/protocol'
22
import * as jose from 'jose'
3+
import * as path from 'path'
34
import { JSONRPCEndpoint } from './lspClient'
45

56
/**
@@ -72,3 +73,12 @@ async function setProfile(endpoint: JSONRPCEndpoint, profileArn: string): Promis
7273
settings: { profileArn },
7374
})
7475
}
76+
77+
/**
78+
* Normalize paths for cross-platform comparison
79+
* @param filePath - The file path to normalize
80+
* @returns Normalized path with consistent casing
81+
*/
82+
export function normalizePath(filePath: string): string {
83+
return path.resolve(filePath).toLowerCase()
84+
}

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)