Skip to content

Commit b1bdc35

Browse files
authored
feat(amazonq): remove "unsupported" message for other languages in /test #6935
## Problem In /test feature, test generation in languages other than Java and Python display message that they were not supported. Tests are generated for all languages, so this message needs to be removed. ## Solution Removed message to the user that /test only supports Python and Java
1 parent 413ce4b commit b1bdc35

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

packages/amazonq/test/e2e/amazonq/testGen.test.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ describe('Amazon Q Test Generation', function () {
3131
},
3232
]
3333

34-
const unsupportedLanguages = [
35-
// move these over to testFiles once these languages are supported
36-
// must be atleast one unsupported language here for testing
37-
{
38-
language: 'typescript',
39-
filePath: 'testGenFolder/src/main/math.ts',
40-
},
41-
{
42-
language: 'javascript',
43-
filePath: 'testGenFolder/src/main/math.js',
44-
},
45-
]
46-
4734
// handles opening the file since /test must be called on an active file
4835
async function setupTestDocument(filePath: string, language: string) {
4936
const document = await waitUntil(async () => {
@@ -125,28 +112,6 @@ describe('Amazon Q Test Generation', function () {
125112
})
126113

127114
describe('/test entry', () => {
128-
describe('Unsupported language file', () => {
129-
const { language, filePath } = unsupportedLanguages[0]
130-
131-
beforeEach(async () => {
132-
await setupTestDocument(filePath, language)
133-
})
134-
135-
it(`/test for unsupported language redirects to chat`, async () => {
136-
tab.addChatMessage({ command: '/test' })
137-
await tab.waitForChatFinishesLoading()
138-
139-
await waitForChatItems(3)
140-
const unsupportedLanguageMessage = tab.getChatItems()[3]
141-
142-
assert.deepStrictEqual(unsupportedLanguageMessage.type, 'answer')
143-
assert.deepStrictEqual(
144-
unsupportedLanguageMessage.body,
145-
`<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${language.charAt(0).toUpperCase() + language.slice(1)} is not supported, I will generate a suggestion below.`
146-
)
147-
})
148-
})
149-
150115
describe('External file out of project', async () => {
151116
let testFolder: TestFolder
152117
let fileName: string

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,17 +547,12 @@ export class TestController {
547547
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
548548
*/
549549
if (!['java', 'python'].includes(language) || workspaceFolder === undefined) {
550-
let unsupportedMessage: string
551-
const unsupportedLanguage = language ? language.charAt(0).toUpperCase() + language.slice(1) : ''
552550
if (!workspaceFolder) {
553551
// File is outside of workspace
554-
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I can't generate tests for ${fileName}</b> because the file is outside of workspace scope.<br></span> I can still provide examples, instructions and code suggestions.`
555-
} else if (unsupportedLanguage) {
556-
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${unsupportedLanguage} is not supported, I will generate a suggestion below.`
557-
} else {
558-
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.`
552+
const unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I can't generate tests for ${fileName}</b> because the file is outside of workspace scope.<br></span> I can still provide examples, instructions and code suggestions.`
553+
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
559554
}
560-
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
555+
// Keeping this metric as is. TODO - Change to true once we support through other feature
561556
session.isSupportedLanguage = false
562557
await this.onCodeGeneration(
563558
session,

0 commit comments

Comments
 (0)