Skip to content

Commit 2eab7af

Browse files
authored
Fix UI tests running wrong IDE variant (#3042)
1 parent b0aa824 commit 2eab7af

File tree

6 files changed

+42
-16
lines changed

6 files changed

+42
-16
lines changed

ui-tests/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import software.aws.toolkits.gradle.jacoco.RemoteCoverage.Companion.enableRemote
55
// SPDX-License-Identifier: Apache-2.0
66

77
val remoteRobotPort: String by project
8+
val ideProfileName: String by project
89

910
repositories {
1011
maven { url = uri("https://cache-redirector.jetbrains.com/intellij-dependencies") }
@@ -44,6 +45,7 @@ tasks.register<Test>("uiTestCore") {
4445
dependsOn(":jetbrains-core:buildPlugin")
4546
inputs.files(":jetbrains-core:buildPlugin")
4647

48+
systemProperty("org.gradle.project.ideProfileName", ideProfileName)
4749
systemProperty("robot-server.port", remoteRobotPort)
4850
systemProperty("junit.jupiter.extensions.autodetection.enabled", true)
4951

ui-tests/tst/software/aws/toolkits/jetbrains/uitests/fixtures/AwsExplorer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ open class AwsExplorer(
3838
remoteRobot: RemoteRobot,
3939
remoteComponent: RemoteComponent
4040
) : CommonContainerFixture(remoteRobot, remoteComponent) {
41-
fun explorerTree() = find<JTreeFixture>(byXpath("//div[@class='Tree']")).also { it.waitUntilLoaded() }
41+
fun explorerTree() = find<JTreeFixture>(byXpath("//div[@class='Tree']"), timeout = Duration.ofSeconds(5)).also { it.waitUntilLoaded() }
4242

4343
fun openExplorerActionMenu(vararg path: String) {
4444
explorerTree().rightClickPath(*path)

ui-tests/tst/software/aws/toolkits/jetbrains/uitests/fixtures/FixtureExtensions.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@ import com.intellij.remoterobot.fixtures.JTextFieldFixture
1111
import com.intellij.remoterobot.search.locators.byXpath
1212
import com.intellij.remoterobot.stepsProcessing.step
1313
import com.intellij.remoterobot.utils.keyboard
14+
import org.intellij.lang.annotations.Language
1415
import java.time.Duration
1516

1617
fun ContainerFixture.pressOk() = findAndClick("//div[@text='OK']")
1718
fun ContainerFixture.pressDelete() = findAndClick("//div[@text='Delete']")
1819
fun ContainerFixture.pressCancel() = findAndClick("//div[@text='Cancel']")
1920

20-
fun ContainerFixture.findAndClick(xPath: String) = findByXpath(xPath).click()
21+
fun ContainerFixture.findAndClick(@Language("XPath") xPath: String) = findByXpath(xPath).click()
2122
fun ContainerFixture.findByXpath(xPath: String) = find<ComponentFixture>(byXpath(xPath), Duration.ofSeconds(5))
2223

2324
fun ContainerFixture.fillSingleTextField(text: String) = step("Fill single text field with $text") {
24-
find<JTextFieldFixture>(byXpath("//div[@class='JTextField']"), Duration.ofSeconds(5)).text = text
25+
find<JTextFieldFixture>(byXpath("//div[@class='JTextField']"), Duration.ofSeconds(5)).setTextWithoutFocus(text)
26+
}
27+
28+
// swing robot appears to have issues acquiring focus on MATE desktop with some dialog windows
29+
// org.assertj.swing.exception.ActionFailedException: Focus change to javax.swing.JTextField[name=null, text='', enabled=true, visible=true, showing=true] failed focus owner: Null Component (js#8)
30+
fun JTextFieldFixture.setTextWithoutFocus(text: String) = apply {
31+
runJs("component.setText('$text')")
2532
}
2633

2734
fun ContainerFixture.fillSearchTextField(text: String) = step("Fill search text field with $text") {
@@ -46,7 +53,7 @@ fun ContainerFixture.clearSearchTextField() = step("Clear search text field") {
4653
}
4754

4855
fun ContainerFixture.fillDeletionAndConfirm() = step("Fill in delete me and delete") {
49-
find<JTextFieldFixture>(byXpath("//div[@accessiblename='Delete confirmation box']"), Duration.ofSeconds(5)).text = "delete me"
56+
find<JTextFieldFixture>(byXpath("//div[@accessiblename='Delete confirmation box']"), Duration.ofSeconds(5)).setTextWithoutFocus("delete me")
5057
pressOk()
5158
}
5259

ui-tests/tst/software/aws/toolkits/jetbrains/uitests/fixtures/JTreeFixture.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ fun JTreeFixture.waitUntilLoaded() {
211211
step("waiting for loading text to go away...") {
212212
Pause.pause(100)
213213
waitFor(duration = Duration.ofMinutes(1)) {
214-
// Do not use hasText(String) https://github.com/JetBrains/intellij-ui-test-robot/issues/10
215-
!hasText { txt -> txt.text == "loading..." }
214+
// FIX_WHEN_MIN_IS_213: changed to unicode ellipses in IDEA-270680
215+
!hasText("loading...") && !hasText("loading…")
216216
}
217217
Pause.pause(100)
218218
}

ui-tests/tst/software/aws/toolkits/jetbrains/uitests/fixtures/WelcomeFrame.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ class WelcomeFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) :
3737
}
3838

3939
fun selectTab(tabName: String) {
40-
jList(byXpath("//div[@accessiblename='Welcome screen categories']")).clickItem(tabName)
40+
// TODO: FIX_WHEN_MIN_IS_213
41+
try {
42+
find<JTreeFixture>(JTreeFixture.byType()).clickRowWithText(tabName, fullMatch = false)
43+
} catch (e: Exception) {
44+
// <2021.3
45+
jList(byXpath("//div[@accessiblename='Welcome screen categories']")).clickItem(tabName)
46+
}
4147
}
4248

4349
fun openFolder(path: Path) {

ui-tests/tst/software/aws/toolkits/jetbrains/uitests/tests/SamRunConfigTest.kt

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package software.aws.toolkits.jetbrains.uitests.tests
55

66
import com.intellij.remoterobot.fixtures.ComboBoxFixture
7+
import com.intellij.remoterobot.fixtures.ComponentFixture
78
import com.intellij.remoterobot.fixtures.ContainerFixture
89
import com.intellij.remoterobot.fixtures.JListFixture
910
import com.intellij.remoterobot.search.locators.byXpath
@@ -53,7 +54,7 @@ class SamRunConfigTest {
5354

5455
idea {
5556
waitForBackgroundTasks()
56-
findAndClick("//div[@accessiblename='Add Configuration...']")
57+
findAndClick("//div[contains(@accessiblename,'Add Configuration')]")
5758
step("Create and populate template based run configuration") {
5859
addRunConfig()
5960
step("Populate run configuration") {
@@ -75,7 +76,7 @@ class SamRunConfigTest {
7576
step("Validate template run configuration was saved and loads properly") {
7677
step("Reopen the run configuration") {
7778
findAndClick("//div[@accessiblename='[Local] SomeFunction']")
78-
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations...")
79+
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations", fullMatch = false)
7980
}
8081
step("Assert the same function is selected") {
8182
assertThat(functionModel().selectedText()).isEqualTo("SomeFunction")
@@ -94,10 +95,13 @@ class SamRunConfigTest {
9495
step("Setup handler based run configuration") {
9596
step("Reopen the run configuration menu") {
9697
findAndClick("//div[@accessiblename='[Local] SomeFunction']")
97-
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations...")
98+
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations", fullMatch = false)
9899
}
99100
addRunConfig()
100-
find<ComboBoxFixture>(byXpath("(//div[@text='Runtime:']/following-sibling::div[@class='ComboBox'])[1]")).selectItem("java11")
101+
find<ComboBoxFixture>(
102+
byXpath("(//div[@text='Runtime:']/following-sibling::div[@class='ComboBox'])[1]"),
103+
Duration.ofSeconds(10)
104+
).selectItem("java11")
101105
findAndClick("//div[@class='HandlerPanel']")
102106
keyboard { enterText("helloworld.App::handleRequest") }
103107
findAndClick("//div[@class='MyEditorTextField']")
@@ -107,10 +111,11 @@ class SamRunConfigTest {
107111
step("Validate handler run configuration was saved and loads properly") {
108112
step("Reopen the run configuration") {
109113
findAndClick("//div[@accessiblename='[Local] App.handleRequest']")
110-
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations...")
114+
find<JListFixture>(byXpath("//div[@class='MyList']")).clickItem("Edit Configurations", fullMatch = false)
115+
waitForConfigurationLoad()
111116
}
112117
step("Assert the same handler is selected") {
113-
val fixture = findRunDialog().find<ContainerFixture>(byXpath("//div[@class='HandlerPanel']"))
118+
val fixture = find<ContainerFixture>(byXpath("//div[@class='HandlerPanel']"))
114119
assertThat(fixture.findAllText().joinToString("") { it.text }).isEqualTo("helloworld.App::handleRequest")
115120
}
116121
// We might want to assert no errors here in the future. However, since we do not import the project, we don't
@@ -121,15 +126,21 @@ class SamRunConfigTest {
121126
}
122127
}
123128

124-
private fun ContainerFixture.functionModel(): ComboBoxFixture =
125-
find(byXpath("//div[@class='TextFieldWithBrowseButton']/following-sibling::div[@class='ComboBox']"))
129+
private fun ContainerFixture.waitForConfigurationLoad() = find<ComponentFixture>(byXpath("//div[@text='Configuration']"), Duration.ofSeconds(10))
126130

127-
private fun ContainerFixture.findRunDialog() = find<DialogFixture>(DialogFixture.byTitleContains("Run"), Duration.ofSeconds(5))
131+
private fun ContainerFixture.functionModel(): ComboBoxFixture {
132+
waitForConfigurationLoad()
133+
return find(byXpath("//div[@class='TextFieldWithBrowseButton']/following-sibling::div[@class='ComboBox']"))
134+
}
135+
136+
private fun ContainerFixture.findRunDialog() = find<DialogFixture>(DialogFixture.byTitleContains("Run"), Duration.ofSeconds(10))
128137

129138
private fun ContainerFixture.addRunConfig() {
130139
step("Add a local run configuration") {
131140
findRunDialog().findAndClick("//div[@accessiblename='Add New Configuration']")
132141
find<JTreeFixture>(byXpath("//div[@accessiblename='WizardTree' and @class='MyTree']")).clickPath("AWS Lambda", "Local")
142+
// wait for run config panel to render
143+
waitForConfigurationLoad()
133144
}
134145
}
135146
}

0 commit comments

Comments
 (0)