Skip to content

Commit b22d62b

Browse files
committed
Adding additional test cases and fixed for comments
1 parent 76e1af3 commit b22d62b

File tree

6 files changed

+258
-45
lines changed

6 files changed

+258
-45
lines changed
+68-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package software.aws.toolkits.jetbrains.uitests.chatTests.qTestGeneration
4+
package software.aws.toolkits.jetbrains.uitests.testTests
55

66
import com.intellij.driver.sdk.openFile
77
import com.intellij.driver.sdk.waitForProjectOpen
@@ -55,7 +55,7 @@ class QTestGenerationChatTest {
5555
val testCase = TestCase(
5656
IdeProductProvider.IC,
5757
LocalProjectInfo(
58-
Paths.get("tstData", "Hello")
58+
Paths.get("tstData", "qTestGenerationTestProject")
5959
)
6060
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
6161

@@ -87,7 +87,7 @@ class QTestGenerationChatTest {
8787
val testCase = TestCase(
8888
IdeProductProvider.IC,
8989
LocalProjectInfo(
90-
Paths.get("tstData", "Hello/")
90+
Paths.get("tstData", "qTestGenerationTestProject/")
9191
)
9292
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
9393

@@ -106,8 +106,7 @@ class QTestGenerationChatTest {
106106
}.runIdeWithDriver()
107107
.useDriverAndCloseIde {
108108
waitForProjectOpen()
109-
openFile(Paths.get("Example.java").toString())
110-
// required wait time for the system to be fully ready
109+
openFile(Paths.get("testModule1", "HappyPath.java").toString())
111110
Thread.sleep(30000)
112111
val result = executePuppeteerScript(testHappyPathScript)
113112
assertTrue(result.contains("new tab opened"))
@@ -117,6 +116,70 @@ class QTestGenerationChatTest {
117116
}
118117
}
119118

119+
@Test
120+
fun `test expected error path from the chat`() {
121+
val testCase = TestCase(
122+
IdeProductProvider.IC,
123+
LocalProjectInfo(
124+
Paths.get("tstData", "qTestGenerationTestProject/")
125+
)
126+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
127+
128+
// inject connection
129+
useExistingConnectionForTest()
130+
131+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
132+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
133+
pluginConfigurator.installPluginFromPath(
134+
Path.of(path)
135+
)
136+
}
137+
138+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
139+
updateGeneralSettings()
140+
}.runIdeWithDriver()
141+
.useDriverAndCloseIde {
142+
waitForProjectOpen()
143+
openFile(Paths.get("testModule1", "ErrorPath.java").toString())
144+
Thread.sleep(30000)
145+
val result = executePuppeteerScript(expectedErrorPath)
146+
assertTrue(result.contains("new tab opened"))
147+
assertTrue(result.contains("Test generation complete with expected error"))
148+
}
149+
}
150+
151+
@Test
152+
fun `test unsupported language error path from the chat`() {
153+
val testCase = TestCase(
154+
IdeProductProvider.IC,
155+
LocalProjectInfo(
156+
Paths.get("tstData", "qTestGenerationTestProject/")
157+
)
158+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
159+
160+
// inject connection
161+
useExistingConnectionForTest()
162+
163+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
164+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
165+
pluginConfigurator.installPluginFromPath(
166+
Path.of(path)
167+
)
168+
}
169+
170+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
171+
updateGeneralSettings()
172+
}.runIdeWithDriver()
173+
.useDriverAndCloseIde {
174+
waitForProjectOpen()
175+
openFile(Paths.get("testModule2", "UnSupportedLanguage.kt").toString())
176+
Thread.sleep(30000)
177+
val result = executePuppeteerScript(unsupportedLanguagePath)
178+
assertTrue(result.contains("new tab opened"))
179+
assertTrue(result.contains("Test generation complete with expected error"))
180+
}
181+
}
182+
120183
companion object {
121184
@JvmStatic
122185
@AfterAll

0 commit comments

Comments
 (0)