Skip to content

Commit b359f82

Browse files
authored
Remove unsupported message for non-java python languages in /test (#5579)
1 parent 58993bc commit b359f82

File tree

5 files changed

+18
-141
lines changed

5 files changed

+18
-141
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon Q /test: Remove unsupported message for non-java python languages"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,22 @@ class CodeTestChatController(
244244
})
245245
}
246246
.build()
247+
if (!fileInfo.fileInWorkspace) {
248+
val messageContent =
249+
"<span style=\"color: #EE9D28;\">&#9888;<b> I can't generate tests for ${fileInfo.fileName}" +
250+
" because it's outside the project directory.</b><br></span> " +
251+
"I can still provide examples, instructions and code suggestions."
247252

248-
val messageContent = if (fileInfo.fileInWorkspace) {
249-
"<span style=\"color: #EE9D28;\">&#9888;<b> ${fileInfo.fileLanguage.languageId} is not a " +
250-
"language I support specialized unit test generation for at the moment.</b><br></span>The languages " +
251-
"I support now are Python and Java. I can still provide examples, instructions and code suggestions."
252-
} else {
253-
"<span style=\"color: #EE9D28;\">&#9888;<b> I can't generate tests for ${fileInfo.fileName}" +
254-
" because it's outside the project directory.</b><br></span> " +
255-
"I can still provide examples, instructions and code suggestions."
253+
codeTestChatHelper.addNewMessage(
254+
CodeTestChatMessageContent(
255+
message = messageContent,
256+
type = ChatMessageType.Answer,
257+
canBeVoted = false
258+
),
259+
message.tabId,
260+
false
261+
)
256262
}
257-
258-
codeTestChatHelper.addNewMessage(
259-
CodeTestChatMessageContent(
260-
message = messageContent,
261-
type = ChatMessageType.Answer,
262-
canBeVoted = false
263-
),
264-
message.tabId,
265-
false
266-
)
267263
testResponseMessageId = codeTestChatHelper.addAnswer(
268264
CodeTestChatMessageContent(
269265
message = "",

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTest.kt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -157,42 +157,6 @@ class QTestGenerationChatTest {
157157
}
158158
}
159159

160-
@Test
161-
fun `test unsupported language error path from the chat`() {
162-
val testCase = TestCase(
163-
IdeProductProvider.IC,
164-
LocalProjectInfo(
165-
Paths.get("tstData", "qTestGenerationTestProject/")
166-
)
167-
).withVersion(System.getProperty("org.gradle.project.ideProfileName"))
168-
169-
// inject connection
170-
useExistingConnectionForTest()
171-
172-
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
173-
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
174-
pluginConfigurator.installPluginFromPath(
175-
Path.of(path)
176-
)
177-
}
178-
179-
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
180-
updateGeneralSettings()
181-
}.runIdeWithDriver()
182-
.useDriverAndCloseIde {
183-
waitForProjectOpen()
184-
openFile(Paths.get("testModule2", "UnSupportedLanguage.kt").toString())
185-
Thread.sleep(30000)
186-
val result = executePuppeteerScript(unsupportedLanguagePath)
187-
188-
assertThat(result)
189-
.contains(
190-
"new tab opened",
191-
"Test generation complete with expected error"
192-
)
193-
}
194-
}
195-
196160
companion object {
197161
@JvmStatic
198162
@AfterAll

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/testTests/QTestGenerationChatTestScripts.kt

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -247,83 +247,3 @@ val expectedErrorPath = """
247247
}
248248
testNavigation().catch(console.error);
249249
""".trimIndent()
250-
251-
val unsupportedLanguagePath = """
252-
const puppeteer = require('puppeteer');
253-
async function testNavigation() {
254-
const browser = await puppeteer.connect({
255-
browserURL: "http://localhost:9222"
256-
})
257-
try {
258-
const pages = await browser.pages()
259-
//console.log(pages)
260-
for(const page of pages) {
261-
const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root'));
262-
//console.log(contents)
263-
const element = await page.${'$'}('.mynah-chat-prompt-input')
264-
if(element) {
265-
const elements = await page.${'$'}${'$'}('.mynah-chat-command-selector-command');
266-
const attr = await Promise.all(
267-
elements.map(elem => elem.evaluate(el => el.getAttribute('command')))
268-
);
269-
await page.type('.mynah-chat-prompt-input', '/test')
270-
271-
await page.keyboard.press('Enter');
272-
await page.keyboard.press('Enter');
273-
274-
try {
275-
await waitForElementWithText(page, "Q - Test")
276-
console.log("new tab opened")
277-
await page.waitForFunction(
278-
(expectedText) => {
279-
const pageContent = document.body.textContent || '';
280-
return pageContent.includes(expectedText);
281-
},
282-
{
283-
timeout: 300000 // 5 minutes timeout
284-
},
285-
"is not a language I support specialized unit test generation for at the moment."
286-
);
287-
console.log("Test generation complete with expected error")
288-
289-
} catch (e) {
290-
console.log("Element with text not found")
291-
console.log(e)
292-
throw e
293-
}
294-
295-
}
296-
}
297-
} finally {
298-
await browser.close();
299-
}
300-
}
301-
302-
async function waitForElementWithText(page, text) {
303-
await page.waitForFunction(
304-
(expectedText) => {
305-
const elements = document.querySelectorAll('*');
306-
return Array.from(elements).find(element =>
307-
element.textContent?.trim() === expectedText
308-
);
309-
},
310-
{},
311-
text
312-
);
313-
}
314-
315-
async function waitAndGetElementByText(page, text) {
316-
const element = await page.waitForFunction(
317-
(expectedText) => {
318-
const elements = document.querySelectorAll('*');
319-
return Array.from(elements).find(element =>
320-
element.textContent?.trim() === expectedText
321-
);
322-
},
323-
{},
324-
text
325-
);
326-
return element;
327-
}
328-
testNavigation().catch(console.error);
329-
""".trimIndent()

ui-tests-starter/tstData/qTestGenerationTestProject/testModule2/UnSupportedLanguage.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)