Skip to content

Commit 85656bc

Browse files
author
Gaurav Gandhi
committed
separate out test cases into individual tests
1 parent 8cc8c6d commit 85656bc

File tree

5 files changed

+292
-110
lines changed

5 files changed

+292
-110
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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.docTests.updateReadmeTests.UpdateReadmeLatestChanges
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.assertFalse
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.docTests.scripts.updateReadmeLatestChangesMakeChangesFlowTestScript
27+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
28+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
29+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
30+
import java.io.File
31+
import java.nio.file.Path
32+
import java.nio.file.Paths
33+
34+
class MakeChangesFlowTest {
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+
@Test
56+
fun `Make Changes button leads to UPDATE with specific changes flow`() {
57+
val testCase = TestCase(
58+
IdeProductProvider.IC,
59+
LocalProjectInfo(
60+
Paths.get("tstData", "qdoc", "updateFlow")
61+
)
62+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
63+
64+
// inject connection
65+
useExistingConnectionForTest()
66+
67+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
68+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
69+
pluginConfigurator.installPluginFromPath(
70+
Path.of(path)
71+
)
72+
}
73+
74+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
75+
updateGeneralSettings()
76+
}.runIdeWithDriver()
77+
.useDriverAndCloseIde {
78+
waitForProjectOpen()
79+
// required wait time for the system to be fully ready
80+
Thread.sleep(30000)
81+
82+
val result = executePuppeteerScript(updateReadmeLatestChangesMakeChangesFlowTestScript)
83+
assertTrue(result.contains("Test Successful"))
84+
assertFalse(result.contains("Error: Test Failed"))
85+
}
86+
}
87+
88+
companion object {
89+
@JvmStatic
90+
@AfterAll
91+
fun clearAwsXml() {
92+
clearAwsXmlFile()
93+
}
94+
}
95+
}
96+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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.docTests.updateReadmeTests.UpdateReadmeLatestChanges
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.assertFalse
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.docTests.scripts.updateReadmeLatestChangesConfirmOptionsTestScript
27+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
28+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
29+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
30+
import java.io.File
31+
import java.nio.file.Path
32+
import java.nio.file.Paths
33+
34+
class PromptedToConfirmFolderTest {
35+
36+
init {
37+
di = DI {
38+
extend(di)
39+
bindSingleton<CIServer>(overrides = true) { TestCIServer }
40+
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
41+
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString())
42+
}
43+
44+
bindSingleton<ConfigurationStorage>(overrides = true) {
45+
ConfigurationStorage(this, defaults)
46+
}
47+
}
48+
}
49+
50+
@BeforeEach
51+
fun setUp() {
52+
// Setup test environment
53+
setupTestEnvironment()
54+
}
55+
56+
@Test
57+
fun `Prompted to confirm selected folder`() {
58+
val testCase = TestCase(
59+
IdeProductProvider.IC,
60+
LocalProjectInfo(
61+
Paths.get("tstData", "qdoc", "updateFlow")
62+
)
63+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
64+
65+
// inject connection
66+
useExistingConnectionForTest()
67+
68+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
69+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
70+
pluginConfigurator.installPluginFromPath(
71+
Path.of(path)
72+
)
73+
}
74+
75+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
76+
updateGeneralSettings()
77+
}.runIdeWithDriver()
78+
.useDriverAndCloseIde {
79+
waitForProjectOpen()
80+
// required wait time for the system to be fully ready
81+
Thread.sleep(30000)
82+
83+
val result = executePuppeteerScript(updateReadmeLatestChangesConfirmOptionsTestScript)
84+
assertTrue(result.contains("Test Successful"))
85+
assertFalse(result.contains("Error: Test Failed"))
86+
}
87+
}
88+
89+
companion object {
90+
@JvmStatic
91+
@AfterAll
92+
fun clearAwsXml() {
93+
clearAwsXmlFile()
94+
}
95+
}
96+
}
97+

ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/UpdateReadmeWithLatestChangesFlowTest.kt ui-tests-starter/tst-243+/software/aws/toolkits/jetbrains/uitests/docTests/updateReadmeTests/UpdateReadmeLatestChanges/UpdateReadmeLatestChangesTest.kt

+2-72
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.docTests
4+
package software.aws.toolkits.jetbrains.uitests.docTests.updateReadmeTests.UpdateReadmeLatestChanges
55

66
import com.intellij.driver.sdk.waitForProjectOpen
77
import com.intellij.ide.starter.ci.CIServer
@@ -15,16 +15,13 @@ import com.intellij.ide.starter.project.LocalProjectInfo
1515
import com.intellij.ide.starter.runner.CurrentTestMethod
1616
import com.intellij.ide.starter.runner.Starter
1717
import org.junit.jupiter.api.AfterAll
18-
import org.junit.jupiter.api.Assertions.assertFalse
1918
import org.junit.jupiter.api.Assertions.assertTrue
2019
import org.junit.jupiter.api.BeforeEach
2120
import org.junit.jupiter.api.Test
2221
import org.kodein.di.DI
2322
import org.kodein.di.bindSingleton
2423
import software.aws.toolkits.jetbrains.uitests.TestCIServer
2524
import software.aws.toolkits.jetbrains.uitests.clearAwsXmlFile
26-
import software.aws.toolkits.jetbrains.uitests.docTests.scripts.updateReadmeLatestChangesConfirmOptionsTestScript
27-
import software.aws.toolkits.jetbrains.uitests.docTests.scripts.updateReadmeLatestChangesMakeChangesFlowTestScript
2825
import software.aws.toolkits.jetbrains.uitests.docTests.scripts.updateReadmeLatestChangesTestScript
2926
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
3027
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
@@ -33,8 +30,7 @@ import java.io.File
3330
import java.nio.file.Path
3431
import java.nio.file.Paths
3532

36-
class UpdateReadmeWithLatestChangesFlowTest {
37-
33+
class UpdateReadmeLatestChangesTest {
3834
init {
3935
di = DI {
4036
extend(di)
@@ -55,72 +51,6 @@ class UpdateReadmeWithLatestChangesFlowTest {
5551
setupTestEnvironment()
5652
}
5753

58-
@Test
59-
fun `Prompted to confirm selected folder`() {
60-
val testCase = TestCase(
61-
IdeProductProvider.IC,
62-
LocalProjectInfo(
63-
Paths.get("tstData", "qdoc", "updateFlow")
64-
)
65-
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
66-
67-
// inject connection
68-
useExistingConnectionForTest()
69-
70-
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
71-
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
72-
pluginConfigurator.installPluginFromPath(
73-
Path.of(path)
74-
)
75-
}
76-
77-
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
78-
updateGeneralSettings()
79-
}.runIdeWithDriver()
80-
.useDriverAndCloseIde {
81-
waitForProjectOpen()
82-
// required wait time for the system to be fully ready
83-
Thread.sleep(30000)
84-
85-
val result = executePuppeteerScript(updateReadmeLatestChangesConfirmOptionsTestScript)
86-
assertTrue(result.contains("Test Successful"))
87-
assertFalse(result.contains("Error: Test Failed"))
88-
}
89-
}
90-
91-
@Test
92-
fun `Make Changes button leads to UPDATE with specific changes flow`() {
93-
val testCase = TestCase(
94-
IdeProductProvider.IC,
95-
LocalProjectInfo(
96-
Paths.get("tstData", "qdoc", "updateFlow")
97-
)
98-
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
99-
100-
// inject connection
101-
useExistingConnectionForTest()
102-
103-
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
104-
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
105-
pluginConfigurator.installPluginFromPath(
106-
Path.of(path)
107-
)
108-
}
109-
110-
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
111-
updateGeneralSettings()
112-
}.runIdeWithDriver()
113-
.useDriverAndCloseIde {
114-
waitForProjectOpen()
115-
// required wait time for the system to be fully ready
116-
Thread.sleep(30000)
117-
118-
val result = executePuppeteerScript(updateReadmeLatestChangesMakeChangesFlowTestScript)
119-
assertTrue(result.contains("Test Successful"))
120-
assertFalse(result.contains("Error: Test Failed"))
121-
}
122-
}
123-
12454
@Test
12555
fun `UpdateReadme with latest changes returns an updated Readme`() {
12656
val testCase = TestCase(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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.docTests.updateReadmeTests.UpdateReadmeSpecificChanges
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.assertFalse
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.docTests.scripts.updateReadmeSpecificChangesMakeChangesFlowTestScript
27+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
28+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
29+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
30+
import java.io.File
31+
import java.nio.file.Path
32+
import java.nio.file.Paths
33+
34+
class MakeChangesFlowTest {
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+
@Test
56+
fun `Make changes button leads to UPDATE with specific changes flow`() {
57+
val testCase = TestCase(
58+
IdeProductProvider.IC,
59+
LocalProjectInfo(
60+
Paths.get("tstData", "qdoc", "updateFlow")
61+
)
62+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
63+
64+
// inject connection
65+
useExistingConnectionForTest()
66+
67+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
68+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
69+
pluginConfigurator.installPluginFromPath(
70+
Path.of(path)
71+
)
72+
}
73+
74+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
75+
updateGeneralSettings()
76+
}.runIdeWithDriver()
77+
.useDriverAndCloseIde {
78+
waitForProjectOpen()
79+
// required wait time for the system to be fully ready
80+
Thread.sleep(30000)
81+
82+
val result = executePuppeteerScript(updateReadmeSpecificChangesMakeChangesFlowTestScript)
83+
assertTrue(result.contains("Test Successful"))
84+
assertFalse(result.contains("Error: Test Failed"))
85+
}
86+
}
87+
88+
companion object {
89+
@JvmStatic
90+
@AfterAll
91+
fun clearAwsXml() {
92+
clearAwsXmlFile()
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)