Skip to content

Commit e2ae1aa

Browse files
committed
test: add Amazon Q /dev e2e tests
1 parent f9f19d5 commit e2ae1aa

File tree

4 files changed

+511
-0
lines changed

4 files changed

+511
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.uitests.featureDevTests
5+
6+
import com.intellij.driver.sdk.waitForProjectOpen
7+
import com.intellij.ide.starter.ci.CIServer
8+
import com.intellij.ide.starter.config.ConfigurationStorage
9+
import com.intellij.ide.starter.di.di
10+
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
11+
import com.intellij.ide.starter.ide.IdeProductProvider
12+
import com.intellij.ide.starter.junit5.hyphenateWithClass
13+
import com.intellij.ide.starter.models.TestCase
14+
import com.intellij.ide.starter.project.LocalProjectInfo
15+
import com.intellij.ide.starter.runner.CurrentTestMethod
16+
import com.intellij.ide.starter.runner.Starter
17+
import org.junit.jupiter.api.AfterAll
18+
import org.junit.jupiter.api.Assertions.assertTrue
19+
import org.junit.jupiter.api.BeforeEach
20+
import org.junit.jupiter.api.Test
21+
import org.kodein.di.DI
22+
import org.kodein.di.bindSingleton
23+
import software.aws.toolkits.jetbrains.uitests.TestCIServer
24+
import software.aws.toolkits.jetbrains.uitests.clearAwsXmlFile
25+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
26+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
27+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
28+
import java.io.File
29+
import java.nio.file.Path
30+
import java.nio.file.Paths
31+
32+
class FeatureDevTest {
33+
init {
34+
di = DI {
35+
extend(di)
36+
bindSingleton<CIServer>(overrides = true) { TestCIServer }
37+
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
38+
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString())
39+
}
40+
41+
bindSingleton<ConfigurationStorage>(overrides = true) {
42+
ConfigurationStorage(this, defaults)
43+
}
44+
}
45+
}
46+
47+
@BeforeEach
48+
fun setUp() {
49+
// Setup test environment
50+
setupTestEnvironment()
51+
}
52+
53+
@Test
54+
fun `Accept initial code generation`() {
55+
val testCase = TestCase(
56+
IdeProductProvider.IC,
57+
LocalProjectInfo(
58+
Paths.get("tstData", "FeatureDevE2ETestFolder")
59+
)
60+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
61+
62+
// inject connection
63+
useExistingConnectionForTest()
64+
65+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
66+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
67+
pluginConfigurator.installPluginFromPath(
68+
Path.of(path)
69+
)
70+
}
71+
72+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
73+
updateGeneralSettings()
74+
}.runIdeWithDriver()
75+
.useDriverAndCloseIde {
76+
waitForProjectOpen()
77+
// required wait time for the system to be fully ready
78+
Thread.sleep(30000)
79+
80+
val result = executePuppeteerScript(testAcceptInitalCode)
81+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
82+
}
83+
}
84+
85+
@Test
86+
fun `Iterate code generation`() {
87+
val testCase = TestCase(
88+
IdeProductProvider.IC,
89+
LocalProjectInfo(
90+
Paths.get("tstData", "FeatureDevE2ETestFolder")
91+
)
92+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
93+
94+
// inject connection
95+
useExistingConnectionForTest()
96+
97+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
98+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
99+
pluginConfigurator.installPluginFromPath(
100+
Path.of(path)
101+
)
102+
}
103+
104+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
105+
updateGeneralSettings()
106+
}.runIdeWithDriver()
107+
.useDriverAndCloseIde {
108+
waitForProjectOpen()
109+
// required wait time for the system to be fully ready
110+
Thread.sleep(30000)
111+
112+
val result = executePuppeteerScript(testIterateCodeGen)
113+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
114+
}
115+
}
116+
117+
@Test
118+
fun `Start new code generation`() {
119+
val testCase = TestCase(
120+
IdeProductProvider.IC,
121+
LocalProjectInfo(
122+
Paths.get("tstData", "FeatureDevE2ETestFolder")
123+
)
124+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
125+
126+
// inject connection
127+
useExistingConnectionForTest()
128+
129+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
130+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
131+
pluginConfigurator.installPluginFromPath(
132+
Path.of(path)
133+
)
134+
}
135+
136+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
137+
updateGeneralSettings()
138+
}.runIdeWithDriver()
139+
.useDriverAndCloseIde {
140+
waitForProjectOpen()
141+
// required wait time for the system to be fully ready
142+
Thread.sleep(30000)
143+
144+
val result = executePuppeteerScript(testNewCodeGen)
145+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
146+
}
147+
}
148+
149+
@Test
150+
fun `Accept partial code generation`() {
151+
val testCase = TestCase(
152+
IdeProductProvider.IC,
153+
LocalProjectInfo(
154+
Paths.get("tstData", "FeatureDevE2ETestFolder")
155+
)
156+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
157+
158+
// inject connection
159+
useExistingConnectionForTest()
160+
161+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
162+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
163+
pluginConfigurator.installPluginFromPath(
164+
Path.of(path)
165+
)
166+
}
167+
168+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
169+
updateGeneralSettings()
170+
}.runIdeWithDriver()
171+
.useDriverAndCloseIde {
172+
waitForProjectOpen()
173+
// required wait time for the system to be fully ready
174+
Thread.sleep(30000)
175+
176+
val result = executePuppeteerScript(testPartialCodeGen)
177+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
178+
}
179+
}
180+
181+
@Test
182+
fun `Stop and restart code generation`() {
183+
val testCase = TestCase(
184+
IdeProductProvider.IC,
185+
LocalProjectInfo(
186+
Paths.get("tstData", "FeatureDevE2ETestFolder")
187+
)
188+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
189+
190+
// inject connection
191+
useExistingConnectionForTest()
192+
193+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
194+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
195+
pluginConfigurator.installPluginFromPath(
196+
Path.of(path)
197+
)
198+
}
199+
200+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
201+
updateGeneralSettings()
202+
}.runIdeWithDriver()
203+
.useDriverAndCloseIde {
204+
waitForProjectOpen()
205+
// required wait time for the system to be fully ready
206+
Thread.sleep(30000)
207+
208+
val result = executePuppeteerScript(testStopAndRestartCodeGen)
209+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
210+
}
211+
}
212+
213+
companion object {
214+
@JvmStatic
215+
@AfterAll
216+
fun clearAwsXml() {
217+
clearAwsXmlFile()
218+
}
219+
}
220+
}

0 commit comments

Comments
 (0)