Skip to content

fix(amazonq): Added end to end UI tests for /test workflow. #5476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ toolkitVersion=3.62-SNAPSHOT
publishToken=
publishChannel=

ideProfileName=2025.1
ideProfileName=2024.3

remoteRobotPort=8080

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,153 @@ class QTestGenerationChatTest {
setupTestEnvironment()
}

@Test
fun `test method not found error handling`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testMethodNotFoundErrorScript)
assertThat(result)
.contains(
"new tab opened",
"Error message displayed correctly",
"Input field re-enabled after error",
)
}
}

@Test
fun `test cancel button during test generation`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testCancelButtonScript)
assertThat(result)
.contains(
"new tab opened",
"Progress bar text displayed",
"Cancel button found",
"Cancel button clicked",
"Test generation cancelled successfully",
"Input field re-enabled after cancellation",
)
}
}

@Test
fun `test documentation generation error handling`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testDocumentationErrorScript)
assertThat(result)
.contains(
"new tab opened",
"Error message displayed correctly",
"Input field re-enabled after error",
)
}
}

@Test
fun `test remove function error handling`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testRemoveFunctionErrorScript)
assertThat(result)
.contains(
"new tab opened",
"Error message displayed correctly",
"Input field re-enabled after error",
)
}
}

@Test
fun `can run a test from the chat`() {
val testCase = TestCase(
Expand Down Expand Up @@ -193,6 +340,116 @@ class QTestGenerationChatTest {
}
}

@Test
fun `test reject path from the chat`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testRejectPathScript)
assertThat(result)
.contains(
"new tab opened",
"View Diff opened",
"Result Reject",
"Unit test generation completed.",
"Input field re-enabled after rejection",
)
}
}

@Test
fun `test NL error from the chat`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testNLErrorPathScript)
assertThat(result)
.contains(
"new tab opened",
"Command entered: /test /something/",
"Error message displayed correctly"
)
}
}

@Test
fun `test progress bar during test generation`() {
val testCase = TestCase(
IdeProductProvider.IC,
LocalProjectInfo(
Paths.get("tstData", "qTestGenerationTestProject/")
)
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))

// inject connection
useExistingConnectionForTest()

Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
pluginConfigurator.installPluginFromPath(
Path.of(path)
)
}

copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
updateGeneralSettings()
}.runIdeWithDriver()
.useDriverAndCloseIde {
waitForProjectOpen()
openFile(Paths.get("testModule1", "HappyPath.java").toString())
Thread.sleep(30000)
val result = executePuppeteerScript(testProgressBarScript)
assertThat(result)
.contains(
"new tab opened",
"Progress bar text displayed",
"Test generation completed successfully"
)
}
}

companion object {
@JvmStatic
@AfterAll
Expand Down
Loading
Loading