Skip to content

Commit 25c7caf

Browse files
authored
Merge branch 'aws:main' into telemetry
2 parents d6df7be + c28033d commit 25c7caf

File tree

9 files changed

+563
-14
lines changed

9 files changed

+563
-14
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "fix Q chat request timeout"
4+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ kotlin = "2.0.0"
2424
kotlinCoroutines = "1.8.0"
2525
mockito = "5.12.0"
2626
mockitoKotlin = "5.4.0"
27-
mockk = "1.13.10"
27+
mockk = "1.13.17"
2828
nimbus-jose-jwt = "9.40"
2929
node-gradle = "7.0.2"
3030
telemetryGenerator = "1.0.307"

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/ChatConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package software.aws.toolkits.jetbrains.services.cwc
55

66
object ChatConstants {
7-
const val REQUEST_TIMEOUT_MS = 60_000 // 60 seconds
7+
const val REQUEST_TIMEOUT_MS = 180_000 // 180 seconds
88

99
// API Constraints
1010
const val FILE_PATH_SIZE_LIMIT = 4_000 // Maximum length of file paths in characters (actual API limit: 4096)

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/telemetry/PluginResolverTest.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ package software.aws.toolkits.jetbrains.services.telemetry
55

66
import com.intellij.ide.plugins.IdeaPluginDescriptor
77
import com.intellij.ide.plugins.PluginManagerCore
8-
import io.mockk.called
98
import io.mockk.every
109
import io.mockk.junit5.MockKExtension
1110
import io.mockk.mockk
1211
import io.mockk.mockkStatic
1312
import io.mockk.verify
14-
import junit.framework.TestCase.assertEquals
13+
import org.assertj.core.api.Assertions.assertThat
1514
import org.junit.jupiter.api.BeforeEach
1615
import org.junit.jupiter.api.Test
1716
import org.junit.jupiter.api.extension.ExtendWith
@@ -34,7 +33,7 @@ class PluginResolverTest {
3433

3534
val pluginResolver = PluginResolver.fromCurrentThread()
3635

37-
assertEquals(AWSProduct.AMAZON_Q_FOR_JET_BRAINS, pluginResolver.product)
36+
assertThat(pluginResolver.product).isEqualTo(AWSProduct.AMAZON_Q_FOR_JET_BRAINS)
3837
}
3938

4039
@Test
@@ -46,7 +45,7 @@ class PluginResolverTest {
4645

4746
val pluginResolver = PluginResolver.fromCurrentThread()
4847

49-
assertEquals(AWSProduct.AWS_TOOLKIT_FOR_JET_BRAINS, pluginResolver.product)
48+
assertThat(pluginResolver.product).isEqualTo(AWSProduct.AWS_TOOLKIT_FOR_JET_BRAINS)
5049
}
5150

5251
@Test
@@ -58,7 +57,7 @@ class PluginResolverTest {
5857

5958
val pluginResolver = PluginResolver.fromCurrentThread()
6059

61-
assertEquals("1.2.3", pluginResolver.version)
60+
assertThat(pluginResolver.version).isEqualTo("1.2.3")
6261
}
6362

6463
@Test
@@ -70,7 +69,7 @@ class PluginResolverTest {
7069

7170
val pluginResolver = PluginResolver.fromCurrentThread()
7271

73-
assertEquals("unknown", pluginResolver.version)
72+
assertThat(pluginResolver.version).isEqualTo("unknown")
7473
}
7574

7675
@Test
@@ -89,8 +88,8 @@ class PluginResolverTest {
8988
val pluginResolver = PluginResolver.fromStackTrace(mockStackTrace)
9089
every { PluginManagerCore.getPluginDescriptorOrPlatformByClassName(any()) } returns pluginDescriptor
9190

92-
assertEquals(AWSProduct.AMAZON_Q_FOR_JET_BRAINS, pluginResolver.product)
93-
assertEquals("1.2.3", pluginResolver.version)
91+
assertThat(pluginResolver.product).isEqualTo(AWSProduct.AMAZON_Q_FOR_JET_BRAINS)
92+
assertThat(pluginResolver.version).isEqualTo("1.2.3")
9493

9594
verify {
9695
PluginManagerCore.getPluginDescriptorOrPlatformByClassName("software.aws.toolkits.plugins.amazonq.bar")
@@ -105,11 +104,11 @@ class PluginResolverTest {
105104
)
106105
val pluginResolver = PluginResolver.fromStackTrace(mockStackTrace)
107106

108-
assertEquals(AWSProduct.AWS_TOOLKIT_FOR_JET_BRAINS, pluginResolver.product)
109-
assertEquals("unknown", pluginResolver.version)
107+
assertThat(pluginResolver.product).isEqualTo(AWSProduct.AWS_TOOLKIT_FOR_JET_BRAINS)
108+
assertThat(pluginResolver.version).isEqualTo("unknown")
110109

111-
verify {
112-
PluginManagerCore.getPlugin(any())?.wasNot(called)
110+
verify(exactly = 0) {
111+
PluginManagerCore.getPlugin(any())
113112
}
114113
}
115114
}
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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.testTests
5+
6+
import com.intellij.driver.sdk.openFile
7+
import com.intellij.driver.sdk.waitForProjectOpen
8+
import com.intellij.ide.starter.ci.CIServer
9+
import com.intellij.ide.starter.config.ConfigurationStorage
10+
import com.intellij.ide.starter.di.di
11+
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
12+
import com.intellij.ide.starter.ide.IdeProductProvider
13+
import com.intellij.ide.starter.junit5.hyphenateWithClass
14+
import com.intellij.ide.starter.models.TestCase
15+
import com.intellij.ide.starter.project.LocalProjectInfo
16+
import com.intellij.ide.starter.runner.CurrentTestMethod
17+
import com.intellij.ide.starter.runner.Starter
18+
import org.junit.jupiter.api.AfterAll
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.nio.file.Path
31+
import java.nio.file.Paths
32+
33+
class QTestGenerationChatTest {
34+
init {
35+
di = DI {
36+
extend(di)
37+
bindSingleton<CIServer>(overrides = true) { TestCIServer }
38+
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
39+
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString())
40+
}
41+
42+
bindSingleton<ConfigurationStorage>(overrides = true) {
43+
ConfigurationStorage(this, defaults)
44+
}
45+
}
46+
}
47+
48+
@BeforeEach
49+
fun setUp() {
50+
setupTestEnvironment()
51+
}
52+
53+
@Test
54+
fun `can run a test from the chat`() {
55+
val testCase = TestCase(
56+
IdeProductProvider.IC,
57+
LocalProjectInfo(
58+
Paths.get("tstData", "qTestGenerationTestProject")
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+
val result = executePuppeteerScript(testNoFilePathScript)
80+
assertTrue(result.contains("new tab opened"))
81+
assertTrue(result.contains("a source file open right now that I can generate a test for"))
82+
}
83+
}
84+
85+
@Test
86+
fun `test happy path from the chat`() {
87+
val testCase = TestCase(
88+
IdeProductProvider.IC,
89+
LocalProjectInfo(
90+
Paths.get("tstData", "qTestGenerationTestProject/")
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+
openFile(Paths.get("testModule1", "HappyPath.java").toString())
110+
Thread.sleep(30000)
111+
val result = executePuppeteerScript(testHappyPathScript)
112+
assertTrue(result.contains("new tab opened"))
113+
assertTrue(result.contains("View Diff opened"))
114+
assertTrue(result.contains("Result Accepted"))
115+
assertTrue(result.contains("Unit test generation completed."))
116+
}
117+
}
118+
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+
183+
companion object {
184+
@JvmStatic
185+
@AfterAll
186+
fun clearAwsXml() {
187+
clearAwsXmlFile()
188+
}
189+
}
190+
}

0 commit comments

Comments
 (0)