Skip to content

Commit 80acfd7

Browse files
committed
chore: fix doc telemetry unit test file path mock fail in windows issue
1 parent 9349803 commit 80acfd7

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

packages/core/src/test/amazonqDoc/controller.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,22 @@ describe('Controller - Doc Generation', () => {
139139
codewhispererChat: 'connected',
140140
amazonQ: 'connected',
141141
})
142-
sinon.stub(FileSystem.prototype, 'exists').callsFake(async () => true)
142+
sinon.stub(FileSystem.prototype, 'exists').resolves(false)
143143
getSessionStub = sinon.stub(controllerSetup.sessionStorage, 'getSession').resolves(session)
144144
modifiedReadme = ReadmeBuilder.createReadmeWithRepoStructure()
145145
sinon
146146
.stub(vscode.workspace, 'openTextDocument')
147147
.callsFake(async (options?: string | vscode.Uri | { language?: string; content?: string }) => {
148-
let path = ''
148+
let documentPath = ''
149149
if (typeof options === 'string') {
150-
path = options
150+
documentPath = options
151151
} else if (options && 'path' in options) {
152-
path = options.path
152+
documentPath = options.path
153153
}
154154

155+
const isTempFile = documentPath === 'empty'
155156
return {
156-
getText: () =>
157-
path.includes('/tmp/aws-toolkit-vscode') || path.includes('\\tmp\\aws-toolkit-vscode')
158-
? generatedReadme
159-
: modifiedReadme,
157+
getText: () => (isTempFile ? generatedReadme : modifiedReadme),
160158
} as any
161159
})
162160
})
@@ -232,7 +230,6 @@ describe('Controller - Doc Generation', () => {
232230
})
233231
})
234232
it('should emit generation telemetry for README update', async () => {
235-
await updateFilePaths(session, modifiedReadme, uploadID, docScheme, controllerSetup.workspaceFolder)
236233
await performAction('update', getSessionStub)
237234

238235
const expectedEvent = createExpectedEvent({
@@ -274,7 +271,6 @@ describe('Controller - Doc Generation', () => {
274271
})
275272

276273
it('should emit acceptance telemetry for README update', async () => {
277-
await updateFilePaths(session, modifiedReadme, uploadID, docScheme, controllerSetup.workspaceFolder)
278274
await performAction('update', getSessionStub)
279275
await new Promise((resolve) => setTimeout(resolve, 100))
280276

@@ -295,7 +291,6 @@ describe('Controller - Doc Generation', () => {
295291
})
296292

297293
it('should emit generation telemetry for README edit', async () => {
298-
await updateFilePaths(session, modifiedReadme, uploadID, docScheme, controllerSetup.workspaceFolder)
299294
await performAction('edit', getSessionStub, 'add repository structure section')
300295

301296
const expectedEvent = createExpectedEvent({
@@ -312,7 +307,6 @@ describe('Controller - Doc Generation', () => {
312307
})
313308
})
314309
it('should emit acceptance telemetry for README edit', async () => {
315-
await updateFilePaths(session, modifiedReadme, uploadID, docScheme, controllerSetup.workspaceFolder)
316310
await performAction('edit', getSessionStub, 'add repository structure section')
317311
await new Promise((resolve) => setTimeout(resolve, 100))
318312

0 commit comments

Comments
 (0)