From 64ef1f06423c651c1d8b0a26d319892507e832fb Mon Sep 17 00:00:00 2001 From: Jalaja Kurubarahalli Date: Tue, 15 Apr 2025 14:09:12 -0700 Subject: [PATCH] Remove unsupported message for non-java python languages in /test --- ...-f49ee314-0987-45cd-84fe-d852e67c8723.json | 4 + .../controller/CodeTestChatController.kt | 32 ++++---- .../testTests/QTestGenerationChatTest.kt | 36 --------- .../QTestGenerationChatTestScripts.kt | 80 ------------------- .../testModule2/UnSupportedLanguage.kt | 7 -- 5 files changed, 18 insertions(+), 141 deletions(-) create mode 100644 .changes/next-release/feature-f49ee314-0987-45cd-84fe-d852e67c8723.json delete mode 100644 ui-tests-starter/tstData/qTestGenerationTestProject/testModule2/UnSupportedLanguage.kt diff --git a/.changes/next-release/feature-f49ee314-0987-45cd-84fe-d852e67c8723.json b/.changes/next-release/feature-f49ee314-0987-45cd-84fe-d852e67c8723.json new file mode 100644 index 00000000000..7c43d5fe26d --- /dev/null +++ b/.changes/next-release/feature-f49ee314-0987-45cd-84fe-d852e67c8723.json @@ -0,0 +1,4 @@ +{ + "type" : "feature", + "description" : "Amazon Q /test: Remove unsupported message for non-java python languages" +} \ No newline at end of file diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt index 2e8c9be12a7..a03a5b3176e 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt @@ -244,26 +244,22 @@ class CodeTestChatController( }) } .build() + if (!fileInfo.fileInWorkspace) { + val messageContent = + " I can't generate tests for ${fileInfo.fileName}" + + " because it's outside the project directory.
" + + "I can still provide examples, instructions and code suggestions." - val messageContent = if (fileInfo.fileInWorkspace) { - " ${fileInfo.fileLanguage.languageId} is not a " + - "language I support specialized unit test generation for at the moment.
The languages " + - "I support now are Python and Java. I can still provide examples, instructions and code suggestions." - } else { - " I can't generate tests for ${fileInfo.fileName}" + - " because it's outside the project directory.
" + - "I can still provide examples, instructions and code suggestions." + codeTestChatHelper.addNewMessage( + CodeTestChatMessageContent( + message = messageContent, + type = ChatMessageType.Answer, + canBeVoted = false + ), + message.tabId, + false + ) } - - codeTestChatHelper.addNewMessage( - CodeTestChatMessageContent( - message = messageContent, - type = ChatMessageType.Answer, - canBeVoted = false - ), - message.tabId, - false - ) testResponseMessageId = codeTestChatHelper.addAnswer( CodeTestChatMessageContent( message = "", diff --git a/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTest.kt b/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTest.kt index d836b0f5304..2b61093a6df 100644 --- a/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTest.kt +++ b/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTest.kt @@ -157,42 +157,6 @@ class QTestGenerationChatTest { } } - @Test - fun `test unsupported language error path from the chat`() { - val testCase = TestCase( - IdeProductProvider.IC, - LocalProjectInfo( - Paths.get("tstData", "qTestGenerationTestProject/") - ) - ).withVersion(System.getProperty("org.gradle.project.ideProfileName")) - - // inject connection - useExistingConnectionForTest() - - Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply { - System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path -> - pluginConfigurator.installPluginFromPath( - Path.of(path) - ) - } - - copyExistingConfig(Paths.get("tstData", "configAmazonQTests")) - updateGeneralSettings() - }.runIdeWithDriver() - .useDriverAndCloseIde { - waitForProjectOpen() - openFile(Paths.get("testModule2", "UnSupportedLanguage.kt").toString()) - Thread.sleep(30000) - val result = executePuppeteerScript(unsupportedLanguagePath) - - assertThat(result) - .contains( - "new tab opened", - "Test generation complete with expected error" - ) - } - } - companion object { @JvmStatic @AfterAll diff --git a/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTestScripts.kt b/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTestScripts.kt index 50c7522849a..5651269fdde 100644 --- a/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTestScripts.kt +++ b/ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTestScripts.kt @@ -247,83 +247,3 @@ val expectedErrorPath = """ } testNavigation().catch(console.error); """.trimIndent() - -val unsupportedLanguagePath = """ - const puppeteer = require('puppeteer'); - async function testNavigation() { - const browser = await puppeteer.connect({ - browserURL: "http://localhost:9222" - }) - try { - const pages = await browser.pages() - //console.log(pages) - for(const page of pages) { - const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root')); - //console.log(contents) - const element = await page.${'$'}('.mynah-chat-prompt-input') - if(element) { - const elements = await page.${'$'}${'$'}('.mynah-chat-command-selector-command'); - const attr = await Promise.all( - elements.map(elem => elem.evaluate(el => el.getAttribute('command'))) - ); - await page.type('.mynah-chat-prompt-input', '/test') - - await page.keyboard.press('Enter'); - await page.keyboard.press('Enter'); - - try { - await waitForElementWithText(page, "Q - Test") - console.log("new tab opened") - await page.waitForFunction( - (expectedText) => { - const pageContent = document.body.textContent || ''; - return pageContent.includes(expectedText); - }, - { - timeout: 300000 // 5 minutes timeout - }, - "is not a language I support specialized unit test generation for at the moment." - ); - console.log("Test generation complete with expected error") - - } catch (e) { - console.log("Element with text not found") - console.log(e) - throw e - } - - } - } - } finally { - await browser.close(); - } - } - - async function waitForElementWithText(page, text) { - await page.waitForFunction( - (expectedText) => { - const elements = document.querySelectorAll('*'); - return Array.from(elements).find(element => - element.textContent?.trim() === expectedText - ); - }, - {}, - text - ); - } - - async function waitAndGetElementByText(page, text) { - const element = await page.waitForFunction( - (expectedText) => { - const elements = document.querySelectorAll('*'); - return Array.from(elements).find(element => - element.textContent?.trim() === expectedText - ); - }, - {}, - text - ); - return element; - } - testNavigation().catch(console.error); -""".trimIndent() diff --git a/ui-tests-starter/tstData/qTestGenerationTestProject/testModule2/UnSupportedLanguage.kt b/ui-tests-starter/tstData/qTestGenerationTestProject/testModule2/UnSupportedLanguage.kt deleted file mode 100644 index e5186767647..00000000000 --- a/ui-tests-starter/tstData/qTestGenerationTestProject/testModule2/UnSupportedLanguage.kt +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -class UnSupportedLanguage { - // test method for Q Test Generation. - fun multiply(num1: Double, num2: Double): Double = num1 * num2 -}