Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 126 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/aws-lsp-codewhisperer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"adm-zip": "^0.5.10",
"archiver": "^7.0.1",
"aws-sdk": "^2.1403.0",
"chokidar": "^4.0.3",
"deepmerge": "^4.3.1",
"diff": "^7.0.0",
"fastest-levenshtein": "^1.0.16",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Will be deleted or merged.
*/

import * as path from 'path'
import {
ChatResponseStream,
CodeWhispererStreaming,
Expand Down Expand Up @@ -36,6 +37,8 @@ import { DEFAULT_HELP_FOLLOW_UP_PROMPT, HELP_MESSAGE } from '../chat/constants'
import { TelemetryService } from '../../shared/telemetry/telemetryService'
import { AmazonQTokenServiceManager } from '../../shared/amazonQServiceManager/AmazonQTokenServiceManager'
import { TabBarController } from './tabBarController'
import { getUserPromptsDirectory } from './context/contextUtils'
import { AdditionalContextProvider } from './context/addtionalContextProvider'

describe('AgenticChatController', () => {
const mockTabId = 'tab-1'
Expand Down Expand Up @@ -97,11 +100,13 @@ describe('AgenticChatController', () => {

let sendMessageStub: sinon.SinonStub
let generateAssistantResponseStub: sinon.SinonStub
let additionalContextProviderStub: sinon.SinonStub
let disposeStub: sinon.SinonStub
let activeTabSpy: {
get: sinon.SinonSpy<[], string | undefined>
set: sinon.SinonSpy<[string | undefined], void>
}
let fsWriteFileStub: sinon.SinonStub
let removeConversationSpy: sinon.SinonSpy
let emitConversationMetricStub: sinon.SinonStub

Expand Down Expand Up @@ -144,13 +149,14 @@ describe('AgenticChatController', () => {
})

testFeatures = new TestFeatures()
fsWriteFileStub = sinon.stub()

testFeatures.workspace.fs = {
...testFeatures.workspace.fs,
getServerDataDirPath: sinon.stub().returns('/mock/server/data/path'),
mkdir: sinon.stub().resolves(),
readFile: sinon.stub().resolves(),
writeFile: sinon.stub().resolves(),
writeFile: fsWriteFileStub.resolves(),
rm: sinon.stub().resolves(),
}

Expand All @@ -161,6 +167,8 @@ describe('AgenticChatController', () => {
addTool: sinon.stub().resolves(),
}

additionalContextProviderStub = sinon.stub(AdditionalContextProvider.prototype, 'getAdditionalContext')
additionalContextProviderStub.resolves([])
// @ts-ignore
const cachedInitializeParams: InitializeParams = {
initializationOptions: {
Expand All @@ -173,6 +181,7 @@ describe('AgenticChatController', () => {
},
},
}
testFeatures.lsp.window.showDocument = sinon.stub()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this stub missing in TestFeatures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I think so

testFeatures.lsp.getClientInitializeParams.returns(cachedInitializeParams)
setCredentials('builderId')

Expand Down Expand Up @@ -1001,6 +1010,25 @@ describe('AgenticChatController', () => {
})
})

describe('onCreatePrompt', () => {
it('should create prompt file with given name', async () => {
const promptName = 'testPrompt'
const expectedPath = path.join(getUserPromptsDirectory(), 'testPrompt.prompt.md')

await chatController.onCreatePrompt({ promptName })

sinon.assert.calledOnceWithExactly(fsWriteFileStub, expectedPath, '', { mode: 0o600 })
})

it('should create default prompt file when no name provided', async () => {
const expectedPath = path.join(getUserPromptsDirectory(), 'default.prompt.md')

await chatController.onCreatePrompt({ promptName: '' })

sinon.assert.calledOnceWithExactly(fsWriteFileStub, expectedPath, '', { mode: 0o600 })
})
})

describe('onInlineChatPrompt', () => {
it('read all the response streams and return compiled results', async () => {
const chatResultPromise = chatController.onInlineChatPrompt(
Expand Down
Loading
Loading