Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"mergeReports": "ts-node ./scripts/mergeReports.ts"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.289",
"@aws-toolkits/telemetry": "^1.0.293",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q: fix for test generation unsupported languages query"
}
22 changes: 17 additions & 5 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
isCancel ? 'Cancelled' : 'Failed',
session.startTestGenerationRequestId,
performance.now() - session.testGenerationStartTime,
Expand Down Expand Up @@ -456,7 +457,14 @@ export class TestController {
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below.`
}
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
await this.onCodeGeneration(session, message.prompt, tabID, fileName, filePath)
await this.onCodeGeneration(
session,
message.prompt,
tabID,
fileName,
filePath,
workspaceFolder !== undefined
)
} else {
this.messenger.sendCapabilityCard({ tabID })
this.messenger.sendMessage(testGenSummaryMessage(fileName), message.tabID, 'answer-part')
Expand Down Expand Up @@ -722,6 +730,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
'Succeeded',
session.startTestGenerationRequestId,
session.latencyOfTestGeneration,
Expand Down Expand Up @@ -799,20 +808,21 @@ export class TestController {
message: string,
tabID: string,
fileName: string,
filePath: string
filePath: string,
fileInWorkspace: boolean
) {
try {
// TODO: Write this entire gen response to basiccommands and call here.
const editorText = await fs.readFileText(filePath)

const triggerPayload = {
query: `Generate unit tests for the following part of my code: ${message}`,
query: `Generate unit tests for the following part of my code: ${message?.trim() || fileName}`,
Copy link
Contributor

@ctlai95 ctlai95 Jan 14, 2025

Choose a reason for hiding this comment

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

Can you please describe how this fixes the issue in the PR description? (I'm assuming this is the fix)

Before/after screenshots would be helpful as well, if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

codeSelection: undefined,
trigger: ChatTriggerType.ChatMessage,
fileText: editorText,
fileLanguage: session.fileLanguage,
filePath: filePath,
message: `Generate unit tests for the following part of my code: ${message}`,
message: `Generate unit tests for the following part of my code: ${message?.trim() || fileName}`,
matchPolicy: undefined,
codeQuery: undefined,
userIntent: UserIntent.GENERATE_UNIT_TESTS,
Expand All @@ -827,7 +837,8 @@ export class TestController {
tabID,
randomUUID.toString(),
triggerPayload,
fileName
fileName,
fileInWorkspace
)
} finally {
this.messenger.sendChatInputEnabled(tabID, true)
Expand All @@ -843,6 +854,7 @@ export class TestController {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
true,
'Succeeded',
session.startTestGenerationRequestId,
session.latencyOfTestGeneration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class Messenger {
tabID: string,
triggerID: string,
triggerPayload: TriggerPayload,
fileName: string
fileName: string,
fileInWorkspace: boolean
) {
let message = ''
let messageId = response.$metadata.requestId ?? ''
Expand Down Expand Up @@ -277,6 +278,7 @@ export class Messenger {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
false,
fileInWorkspace,
'Cancelled',
messageId,
performance.now() - session.testGenerationStartTime,
Expand All @@ -291,6 +293,7 @@ export class Messenger {
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
false,
fileInWorkspace,
'Succeeded',
messageId,
performance.now() - session.testGenerationStartTime
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/codewhisperer/util/telemetryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class TelemetryHelper {
public sendTestGenerationToolkitEvent(
session: Session,
isSupportedLanguage: boolean,
isFileInWorkspace: boolean,
result: 'Succeeded' | 'Failed' | 'Cancelled',
requestId?: string,
perfClientLatency?: number,
Expand All @@ -90,6 +91,7 @@ export class TelemetryHelper {
cwsprChatProgrammingLanguage: session.fileLanguage ?? 'plaintext',
hasUserPromptSupplied: session.hasUserPromptSupplied,
isSupportedLanguage: isSupportedLanguage,
isFileInWorkspace: isFileInWorkspace,
result: result,
artifactsUploadDuration: artifactsUploadDuration,
buildPayloadBytes: buildPayloadBytes,
Expand Down
Loading