Skip to content

Commit d83b935

Browse files
committed
test: add Amazon Q /dev E2E tests
1 parent ae69735 commit d83b935

File tree

6 files changed

+525
-1
lines changed

6 files changed

+525
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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.AfterEach
19+
import org.junit.jupiter.api.Assertions.assertTrue
20+
import org.junit.jupiter.api.BeforeEach
21+
import org.junit.jupiter.api.Test
22+
import org.kodein.di.DI
23+
import org.kodein.di.bindSingleton
24+
import software.aws.toolkits.jetbrains.uitests.TestCIServer
25+
import software.aws.toolkits.jetbrains.uitests.clearAwsXmlFile
26+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
27+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
28+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
29+
import java.io.File
30+
import java.io.FileOutputStream
31+
import java.nio.file.Path
32+
import java.nio.file.Paths
33+
34+
class FeatureDevTest {
35+
init {
36+
di = DI {
37+
extend(di)
38+
bindSingleton<CIServer>(overrides = true) { TestCIServer }
39+
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
40+
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString())
41+
}
42+
43+
bindSingleton<ConfigurationStorage>(overrides = true) {
44+
ConfigurationStorage(this, defaults)
45+
}
46+
}
47+
}
48+
49+
@BeforeEach
50+
fun setUp() {
51+
// Setup test environment
52+
setupTestEnvironment()
53+
}
54+
55+
@AfterEach
56+
fun resetTestProject() {
57+
val operationFile = Paths.get("tstData", "FeatureDevE2ETestFolder", "operation.js").toFile()
58+
FileOutputStream(operationFile).channel.truncate(0)
59+
60+
val changelogFile = Paths.get("tstData", "FeatureDevE2ETestFolder", "CHANGELOG.md").toFile()
61+
FileOutputStream(changelogFile).channel.truncate(0)
62+
}
63+
64+
@Test
65+
fun `Accept initial code generation`() {
66+
val testCase = TestCase(
67+
IdeProductProvider.IC,
68+
LocalProjectInfo(
69+
Paths.get("tstData", "FeatureDevE2ETestFolder")
70+
)
71+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
72+
73+
// inject connection
74+
useExistingConnectionForTest()
75+
76+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
77+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
78+
pluginConfigurator.installPluginFromPath(
79+
Path.of(path)
80+
)
81+
}
82+
83+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
84+
updateGeneralSettings()
85+
}.runIdeWithDriver()
86+
.useDriverAndCloseIde {
87+
waitForProjectOpen()
88+
// required wait time for the system to be fully ready
89+
Thread.sleep(30000)
90+
91+
val result = executePuppeteerScript(testAcceptInitalCode)
92+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
93+
}
94+
}
95+
96+
@Test
97+
fun `Iterate code generation`() {
98+
val testCase = TestCase(
99+
IdeProductProvider.IC,
100+
LocalProjectInfo(
101+
Paths.get("tstData", "FeatureDevE2ETestFolder")
102+
)
103+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
104+
105+
// inject connection
106+
useExistingConnectionForTest()
107+
108+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
109+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
110+
pluginConfigurator.installPluginFromPath(
111+
Path.of(path)
112+
)
113+
}
114+
115+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
116+
updateGeneralSettings()
117+
}.runIdeWithDriver()
118+
.useDriverAndCloseIde {
119+
waitForProjectOpen()
120+
// required wait time for the system to be fully ready
121+
Thread.sleep(30000)
122+
123+
val result = executePuppeteerScript(testIterateCodeGen)
124+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
125+
}
126+
}
127+
128+
@Test
129+
fun `Start new code generation`() {
130+
val testCase = TestCase(
131+
IdeProductProvider.IC,
132+
LocalProjectInfo(
133+
Paths.get("tstData", "FeatureDevE2ETestFolder")
134+
)
135+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
136+
137+
// inject connection
138+
useExistingConnectionForTest()
139+
140+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
141+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
142+
pluginConfigurator.installPluginFromPath(
143+
Path.of(path)
144+
)
145+
}
146+
147+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
148+
updateGeneralSettings()
149+
}.runIdeWithDriver()
150+
.useDriverAndCloseIde {
151+
waitForProjectOpen()
152+
// required wait time for the system to be fully ready
153+
Thread.sleep(30000)
154+
155+
val result = executePuppeteerScript(testNewCodeGen)
156+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
157+
}
158+
}
159+
160+
@Test
161+
fun `Accept partial code generation`() {
162+
val testCase = TestCase(
163+
IdeProductProvider.IC,
164+
LocalProjectInfo(
165+
Paths.get("tstData", "FeatureDevE2ETestFolder")
166+
)
167+
).useRelease(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+
// required wait time for the system to be fully ready
185+
Thread.sleep(30000)
186+
187+
val result = executePuppeteerScript(testPartialCodeGen)
188+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
189+
}
190+
}
191+
192+
@Test
193+
fun `Stop and restart code generation`() {
194+
val testCase = TestCase(
195+
IdeProductProvider.IC,
196+
LocalProjectInfo(
197+
Paths.get("tstData", "FeatureDevE2ETestFolder")
198+
)
199+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
200+
201+
// inject connection
202+
useExistingConnectionForTest()
203+
204+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
205+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
206+
pluginConfigurator.installPluginFromPath(
207+
Path.of(path)
208+
)
209+
}
210+
211+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
212+
updateGeneralSettings()
213+
}.runIdeWithDriver()
214+
.useDriverAndCloseIde {
215+
waitForProjectOpen()
216+
// required wait time for the system to be fully ready
217+
Thread.sleep(30000)
218+
219+
val result = executePuppeteerScript(testStopAndRestartCodeGen)
220+
assertTrue(result.contains("Success: /dev ends the conversation successfully."))
221+
}
222+
}
223+
224+
companion object {
225+
@JvmStatic
226+
@AfterAll
227+
fun clearAwsXml() {
228+
clearAwsXmlFile()
229+
}
230+
}
231+
}

0 commit comments

Comments
 (0)