Skip to content

Commit 6ccab34

Browse files
author
Gaurav Gandhi
committed
update tstData to test
1 parent dfae94a commit 6ccab34

File tree

11 files changed

+268
-3
lines changed

11 files changed

+268
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class UpdateReadmeWithLatestChangesFlowTest {
6060
val testCase = TestCase(
6161
IdeProductProvider.IC,
6262
LocalProjectInfo(
63-
Paths.get("tstData", "qdoc", "updateFlow")
63+
Paths.get("tstData", "qdoc")
6464
)
6565
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
6666

@@ -93,7 +93,7 @@ class UpdateReadmeWithLatestChangesFlowTest {
9393
val testCase = TestCase(
9494
IdeProductProvider.IC,
9595
LocalProjectInfo(
96-
Paths.get("tstData", "qdoc", "updateFlow")
96+
Paths.get("tstData", "qdoc")
9797
)
9898
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
9999

@@ -126,7 +126,7 @@ class UpdateReadmeWithLatestChangesFlowTest {
126126
val testCase = TestCase(
127127
IdeProductProvider.IC,
128128
LocalProjectInfo(
129-
Paths.get("tstData", "qdoc", "updateFlow")
129+
Paths.get("tstData", "qdoc")
130130
)
131131
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
132132

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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
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.docTests.scripts.updateReadmeSpecificChangesTestScript
28+
import software.aws.toolkits.jetbrains.uitests.executePuppeteerScript
29+
import software.aws.toolkits.jetbrains.uitests.setupTestEnvironment
30+
import software.aws.toolkits.jetbrains.uitests.useExistingConnectionForTest
31+
import java.io.File
32+
import java.nio.file.Path
33+
import java.nio.file.Paths
34+
35+
class UpdateReadmeWithSpecificChangesFlowTest {
36+
37+
init {
38+
di = DI {
39+
extend(di)
40+
bindSingleton<CIServer>(overrides = true) { TestCIServer }
41+
val defaults = ConfigurationStorage.instance().defaults.toMutableMap().apply {
42+
put("LOG_ENVIRONMENT_VARIABLES", (!System.getenv("CI").toBoolean()).toString())
43+
}
44+
45+
bindSingleton<ConfigurationStorage>(overrides = true) {
46+
ConfigurationStorage(this, defaults)
47+
}
48+
}
49+
}
50+
51+
@BeforeEach
52+
fun setUp() {
53+
// Setup test environment
54+
setupTestEnvironment()
55+
}
56+
57+
@Test
58+
fun `Make changes button leads to UPDATE with specific changes flow`() {
59+
val testCase = TestCase(
60+
IdeProductProvider.IC,
61+
LocalProjectInfo(
62+
Paths.get("tstData", "qdoc", "updateFlow")
63+
)
64+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
65+
66+
// inject connection
67+
useExistingConnectionForTest()
68+
69+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
70+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
71+
pluginConfigurator.installPluginFromPath(
72+
Path.of(path)
73+
)
74+
}
75+
76+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
77+
updateGeneralSettings()
78+
}.runIdeWithDriver()
79+
.useDriverAndCloseIde {
80+
waitForProjectOpen()
81+
// required wait time for the system to be fully ready
82+
Thread.sleep(30000)
83+
84+
val result = executePuppeteerScript(updateReadmeSpecificChangesMakeChangesFlowTestScript)
85+
assertTrue(result.contains("Test Successful"))
86+
assertFalse(result.contains("Error: Test Failed"))
87+
}
88+
}
89+
90+
@Test
91+
fun `UpdateReadme with specific changes returns an updated Readme`() {
92+
val testCase = TestCase(
93+
IdeProductProvider.IC,
94+
LocalProjectInfo(
95+
Paths.get("tstData", "qdoc", "updateFlow")
96+
)
97+
).useRelease(System.getProperty("org.gradle.project.ideProfileName"))
98+
99+
// inject connection
100+
useExistingConnectionForTest()
101+
102+
Starter.newContext(CurrentTestMethod.hyphenateWithClass(), testCase).apply {
103+
System.getProperty("ui.test.plugins").split(File.pathSeparator).forEach { path ->
104+
pluginConfigurator.installPluginFromPath(
105+
Path.of(path)
106+
)
107+
}
108+
109+
copyExistingConfig(Paths.get("tstData", "configAmazonQTests"))
110+
updateGeneralSettings()
111+
}.runIdeWithDriver()
112+
.useDriverAndCloseIde {
113+
waitForProjectOpen()
114+
// required wait time for the system to be fully ready
115+
Thread.sleep(30000)
116+
117+
val result = executePuppeteerScript(updateReadmeSpecificChangesTestScript)
118+
assertTrue(result.contains("Test Successful"))
119+
assertFalse(result.contains("Error: Test Failed"))
120+
val readmePath = Paths.get("tstData", "qdoc", "updateFlow", "README.md")
121+
val readme = File(readmePath.toUri())
122+
assertTrue(readme.exists())
123+
assertTrue(readme.readText().contains("## Programming Languages"))
124+
}
125+
}
126+
127+
companion object {
128+
@JvmStatic
129+
@AfterAll
130+
fun clearAwsXml() {
131+
clearAwsXmlFile()
132+
}
133+
}
134+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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.scripts
5+
6+
// language=TS
7+
val updateReadmeSpecificChangesMakeChangesFlowScript = """
8+
9+
const puppeteer = require('puppeteer');
10+
11+
async function testNavigation() {
12+
const browser = await puppeteer.connect({
13+
browserURL: 'http://localhost:9222'
14+
});
15+
16+
try {
17+
18+
const pages = await browser.pages();
19+
20+
for(const page of pages) {
21+
const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root'));
22+
23+
const element = await page.${'$'}('.mynah-chat-prompt-input');
24+
if(element) {
25+
26+
console.log('Typing /doc in the chat window');
27+
28+
await page.type('.mynah-chat-prompt-input', '/doc');
29+
await page.keyboard.press('Enter');
30+
31+
console.log('Attempting to find and click Update an existing README button');
32+
await findAndClickButton(page, 'Update an existing README', true, 10000);
33+
console.log('Attempting to find and click Make a specific change button');
34+
await findAndClickButton(page, 'Make a specific change', true, 10000);
35+
console.log('Attempting to find and click Yes button to confirm option');
36+
await findAndClickButton(page, 'Yes', true, 10000);
37+
38+
console.log('Typing specific change instructions in the chat window');
39+
await page.type('.mynah-chat-prompt-input', 'Add new section titled Programming Languages which describes the programming languages and version of programming language used in this project.');
40+
await page.keyboard.press('Enter');
41+
42+
console.log('Waiting for updated README to be generated');
43+
await new Promise(resolve => setTimeout(resolve, 90000));
44+
console.log('Attempting to find and click Make changes button');
45+
await findAndClickButton(page, 'Make changes', true, 10000);
46+
47+
if (!makeChangeText) {
48+
console.log('Error: Test Failed');
49+
console.log('Unable to find placeholder description test in Make Changes flow');
50+
} else {
51+
console.log('Found expected placeholder text for Make Changes flow');
52+
console.log('Test Successful');
53+
}
54+
55+
}
56+
}
57+
58+
} finally {
59+
await browser.close();
60+
}
61+
}
62+
63+
testNavigation().catch((error) => {
64+
console.log('Error: Test Failed');
65+
console.error(error);
66+
});
67+
68+
""".trimIndent()
69+
70+
// language=TS
71+
val updateReadmeSpecificChangesScript = """
72+
73+
const puppeteer = require('puppeteer');
74+
75+
async function testNavigation() {
76+
const browser = await puppeteer.connect({
77+
browserURL: 'http://localhost:9222'
78+
});
79+
80+
try {
81+
82+
const pages = await browser.pages();
83+
84+
for(const page of pages) {
85+
const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root'));
86+
87+
const element = await page.${'$'}('.mynah-chat-prompt-input');
88+
89+
if(element) {
90+
91+
console.log('Typing /doc in the chat window');
92+
93+
await page.type('.mynah-chat-prompt-input', '/doc');
94+
await page.keyboard.press('Enter');
95+
96+
console.log('Attempting to find and click Update an existing README button');
97+
await findAndClickButton(page, 'Update an existing README', true, 10000);
98+
console.log('Attempting to find and click Make a specific change button');
99+
await findAndClickButton(page, 'Make a specific change', true, 10000);
100+
console.log('Attempting to find and click Yes button to confirm option');
101+
await findAndClickButton(page, 'Yes', true, 10000);
102+
103+
console.log('Typing specific change instructions in the chat window');
104+
await page.type('.mynah-chat-prompt-input', 'Add new section titled Programming Languages which describes the programming languages and version of programming language used in this project.');
105+
await page.keyboard.press('Enter');
106+
107+
console.log('Waiting for updated README to be generated');
108+
await new Promise(resolve => setTimeout(resolve, 90000));
109+
110+
console.log('Attempting to find and click Accept button');
111+
await findAndClickButton(page, 'Accept', true, 10000);
112+
113+
// find and confirm the updated readme
114+
115+
}
116+
}
117+
118+
} finally {
119+
await browser.close();
120+
}
121+
}
122+
123+
testNavigation().catch((error) => {
124+
console.log('Error: Test Failed');
125+
console.error(error);
126+
});
127+
128+
""".trimIndent()
129+
130+
val updateReadmeSpecificChangesMakeChangesFlowTestScript = updateReadmeSpecificChangesMakeChangesFlowScript.plus(findAndClickButtonScript)
131+
val updateReadmeSpecificChangesTestScript = updateReadmeSpecificChangesScript.plus(findAndClickButtonScript)
File renamed without changes.

0 commit comments

Comments
 (0)