From dd11a99191bed91c0c0513eaa70021a7a9e5893c Mon Sep 17 00:00:00 2001 From: Jalaja Kurubarahalli Date: Thu, 3 Apr 2025 12:58:37 -0700 Subject: [PATCH 1/2] Remove unsupported message for non-java python languages --- .../amazonq/test/e2e/amazonq/testGen.test.ts | 35 ------------------- .../amazonqTest/chat/controller/controller.ts | 8 ++--- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/packages/amazonq/test/e2e/amazonq/testGen.test.ts b/packages/amazonq/test/e2e/amazonq/testGen.test.ts index 0329121a460..21db83fd6e8 100644 --- a/packages/amazonq/test/e2e/amazonq/testGen.test.ts +++ b/packages/amazonq/test/e2e/amazonq/testGen.test.ts @@ -31,19 +31,6 @@ describe('Amazon Q Test Generation', function () { }, ] - const unsupportedLanguages = [ - // move these over to testFiles once these languages are supported - // must be atleast one unsupported language here for testing - { - language: 'typescript', - filePath: 'testGenFolder/src/main/math.ts', - }, - { - language: 'javascript', - filePath: 'testGenFolder/src/main/math.js', - }, - ] - // handles opening the file since /test must be called on an active file async function setupTestDocument(filePath: string, language: string) { const document = await waitUntil(async () => { @@ -125,28 +112,6 @@ describe('Amazon Q Test Generation', function () { }) describe('/test entry', () => { - describe('Unsupported language file', () => { - const { language, filePath } = unsupportedLanguages[0] - - beforeEach(async () => { - await setupTestDocument(filePath, language) - }) - - it(`/test for unsupported language redirects to chat`, async () => { - tab.addChatMessage({ command: '/test' }) - await tab.waitForChatFinishesLoading() - - await waitForChatItems(3) - const unsupportedLanguageMessage = tab.getChatItems()[3] - - assert.deepStrictEqual(unsupportedLanguageMessage.type, 'answer') - assert.deepStrictEqual( - unsupportedLanguageMessage.body, - `I'm sorry, but /test only supports Python and Java
While ${language.charAt(0).toUpperCase() + language.slice(1)} is not supported, I will generate a suggestion below.` - ) - }) - }) - describe('External file out of project', async () => { let testFolder: TestFolder let fileName: string diff --git a/packages/core/src/amazonqTest/chat/controller/controller.ts b/packages/core/src/amazonqTest/chat/controller/controller.ts index cb5cbc2e851..aa677c6409d 100644 --- a/packages/core/src/amazonqTest/chat/controller/controller.ts +++ b/packages/core/src/amazonqTest/chat/controller/controller.ts @@ -548,16 +548,12 @@ export class TestController { */ if (!['java', 'python'].includes(language) || workspaceFolder === undefined) { let unsupportedMessage: string - const unsupportedLanguage = language ? language.charAt(0).toUpperCase() + language.slice(1) : '' if (!workspaceFolder) { // File is outside of workspace unsupportedMessage = `I can't generate tests for ${fileName} because the file is outside of workspace scope.
I can still provide examples, instructions and code suggestions.` - } else if (unsupportedLanguage) { - unsupportedMessage = `I'm sorry, but /test only supports Python and Java
While ${unsupportedLanguage} is not supported, I will generate a suggestion below.` - } else { - unsupportedMessage = `I'm sorry, but /test only supports Python and Java
I will still generate a suggestion below.` + this.messenger.sendMessage(unsupportedMessage, tabID, 'answer') } - this.messenger.sendMessage(unsupportedMessage, tabID, 'answer') + // Keeping this metric as is. TODO - Change to true once we support through other feature session.isSupportedLanguage = false await this.onCodeGeneration( session, From e9bd5021737f6d6290a40370627eb489fb410f29 Mon Sep 17 00:00:00 2001 From: Jalaja Kurubarahalli Date: Fri, 4 Apr 2025 13:39:47 -0700 Subject: [PATCH 2/2] Fix for text scope --- packages/core/src/amazonqTest/chat/controller/controller.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core/src/amazonqTest/chat/controller/controller.ts b/packages/core/src/amazonqTest/chat/controller/controller.ts index aa677c6409d..07a087977d9 100644 --- a/packages/core/src/amazonqTest/chat/controller/controller.ts +++ b/packages/core/src/amazonqTest/chat/controller/controller.ts @@ -547,10 +547,9 @@ export class TestController { For Re:Invent 2024 we are supporting only java and python for unit test generation, rest of the languages shows the similar experience as CWC */ if (!['java', 'python'].includes(language) || workspaceFolder === undefined) { - let unsupportedMessage: string if (!workspaceFolder) { // File is outside of workspace - unsupportedMessage = `I can't generate tests for ${fileName} because the file is outside of workspace scope.
I can still provide examples, instructions and code suggestions.` + const unsupportedMessage = `I can't generate tests for ${fileName} because the file is outside of workspace scope.
I can still provide examples, instructions and code suggestions.` this.messenger.sendMessage(unsupportedMessage, tabID, 'answer') } // Keeping this metric as is. TODO - Change to true once we support through other feature