Skip to content

Commit 34a37fb

Browse files
committed
fix: fix failing tests
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 6278f60 commit 34a37fb

File tree

22 files changed

+123
-107
lines changed

22 files changed

+123
-107
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ tasks {
4343

4444
jacocoTestReport {
4545
executionData.setFrom(fileTree(layout.buildDirectory).include("/jacoco/*.exec"))
46-
//classDirectories.setFrom(instrumentCode)
4746
reports {
4847
xml.required = true
4948
}

src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
package com.redhat.devtools.intellij.commonuitest;
1212

1313
import com.intellij.remoterobot.RemoteRobot;
14-
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
1514
import com.intellij.remoterobot.stepsProcessing.StepLogger;
1615
import com.intellij.remoterobot.stepsProcessing.StepWorker;
1716
import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException;
1817
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
1918
import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion;
19+
import com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps;
2020

2121
import java.io.File;
2222
import java.io.FileOutputStream;
@@ -154,7 +154,7 @@ public static RemoteRobot getRemoteRobot() {
154154
public static RemoteRobot getRemoteRobotConnection(int port) {
155155
return step("Create an instance of the RemoteRobot listening on port " + port, () -> {
156156
RemoteRobot remoteRobot = new RemoteRobot("http://127.0.0.1:" + port);
157-
waitFor(Duration.ofSeconds(30), Duration.ofMillis(500), () -> remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.FLAT_WELCOME_FRAME)).isShowing());
157+
SharedSteps.waitForComponentByXpath(remoteRobot,30, 200, byXpath(XPathDefinitions.FLAT_WELCOME_FRAME));
158158
return remoteRobot;
159159
});
160160
}

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ public class FlatWelcomeFrame extends CommonContainerFixture {
6161
private static final String PROJECTS_BUTTON = "Projects";
6262
private static final String TIP_OF_THE_DAY = "Tip of the Day";
6363
private final RemoteRobot remoteRobot;
64-
private final int ideaVersion;
64+
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
6565

6666
public FlatWelcomeFrame(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
6767
super(remoteRobot, remoteComponent);
6868
this.remoteRobot = remoteRobot;
69-
this.ideaVersion = UITestRunner.getIdeaVersion().toInt();
7069
}
7170

7271
/**
@@ -93,7 +92,7 @@ public void openProject(String projectName) {
9392
*/
9493
public void clickOnLink(String label) {
9594
// Code for IntelliJ IDEA 2020.3 or newer
96-
if (ideaVersion >= 20203) {
95+
if (ideaVersionInt >= 20203) {
9796
welcomeFrameLink(label).click();
9897
}
9998
// Code for IntelliJ IDEA 2020.2 or earlier
@@ -150,11 +149,11 @@ public void clearExceptions() {
150149
* Open the 'Preferences' dialog
151150
*/
152151
public void openSettingsDialog() {
153-
if (ideaVersion <= 20202) {
152+
if (ideaVersionInt <= 20202) {
154153
clickOnLink("Configure");
155154
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
156155
heavyWeightWindowFixture.findText("Preferences").click();
157-
} else if (ideaVersion <= 20212) {
156+
} else if (ideaVersionInt <= 20212) {
158157
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
159158
jListFixture.clickItem("Customize", false);
160159
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
@@ -205,20 +204,20 @@ private void resizeWelcomeWindow() {
205204
* @return fixture for the 'Tip Of the Day' dialog
206205
*/
207206
public TipDialog openTipDialog() {
208-
if (ideaVersion >= 20211) {
207+
if (ideaVersionInt >= 20211) {
209208
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2));
210-
if (ideaVersion >= 20223) { // COMMUNITY_V_2022_3 and higher version have different labels for Learn button
209+
if (ideaVersionInt >= 20223) { // COMMUNITY_V_2022_3 and higher version have different labels for Learn button
211210
flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click();
212211
} else {
213212
flatWelcomeFrame.findText(ButtonLabels.LEARN_INTELLIJ_IDEA_LABEL).click();
214213
}
215-
SharedSteps.waitForComponentByXpath(remoteRobot, 2, 1, byXpath(XPathDefinitions.TIP_DIALOG_2));
214+
SharedSteps.waitForComponentByXpath(remoteRobot, 2, 200, byXpath(XPathDefinitions.TIP_DIALOG_2));
216215
flatWelcomeFrame.findText(TIP_OF_THE_DAY).click();
217-
} else if (ideaVersion <= 20202) {
216+
} else if (ideaVersionInt <= 20202) {
218217
clickOnLink("Get Help");
219218
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
220219
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
221-
} else if (ideaVersion == 20203) { // IJ 2020.3
220+
} else if (ideaVersionInt == 20203) { // IJ 2020.3
222221
actionLink("Help").click();
223222
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
224223
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
@@ -254,17 +253,17 @@ public void preventTipDialogFromOpening() {
254253
* Switch to the 'Projects' page of flat welcome frame
255254
*/
256255
public void switchToProjectsPage() {
257-
if (ideaVersion >= 20213) {
256+
if (ideaVersionInt >= 20213) {
258257
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
259258
jTreeFixture.findText(PROJECTS_BUTTON).click();
260-
} else if (ideaVersion >= 20203) {
259+
} else if (ideaVersionInt >= 20203) {
261260
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
262261
jListFixture.clickItem(PROJECTS_BUTTON, false);
263262
}
264263
}
265264

266265
private int projectsCount() {
267-
if (ideaVersion >= 20222) {
266+
if (ideaVersionInt >= 20222) {
268267
try {
269268
JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
270269
return projects.findAllText().size() / 2;
@@ -287,7 +286,7 @@ private JButtonFixture welcomeFrameLink(String label) {
287286
if (UtilsKt.hasAnyComponent(this, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW))) {
288287
return button(byXpath(XPathDefinitions.jBOptionButton(label)), Duration.ofSeconds(2));
289288
}
290-
if (ideaVersion >= 20241 && label.equals("New Project")) {
289+
if (ideaVersionInt >= 20241 && label.equals("New Project")) {
291290
return button(byXpath(XPathDefinitions.CREATE_NEW_PROJECT), Duration.ofSeconds(2));
292291
}
293292
return button(byXpath(XPathDefinitions.nonOpaquePanel(label)), Duration.ofSeconds(2));
@@ -299,7 +298,7 @@ private ComponentFixture ideErrorsIcon() {
299298

300299
private void removeTopProjectFromRecentProjects() {
301300
ComponentFixture recentProjects;
302-
if (ideaVersion >= 20222) {
301+
if (ideaVersionInt >= 20222) {
303302
recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
304303
} else {
305304
recentProjects = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)).get(0);
@@ -309,14 +308,14 @@ private void removeTopProjectFromRecentProjects() {
309308
recentProjects.runJs("const horizontal_offset = component.getWidth()-22;\n" +
310309
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");
311310

312-
if (ideaVersion >= 20231) {
311+
if (ideaVersionInt >= 20231) {
313312
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10));
314313
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL).click();
315-
} else if (ideaVersion >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
314+
} else if (ideaVersionInt >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
316315
List<JPopupMenuFixture> jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType());
317316
if (!jPopupMenuFixtures.isEmpty()) {
318317
JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0);
319-
if (ideaVersion >= 20222) {
318+
if (ideaVersionInt >= 20222) {
320319
contextMenu.select("Remove from Recent Projects" + '\u2026');
321320
button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click();
322321
} else {

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/navigation/SearchEverywherePopup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void activateTab(String tabName) {
6767
* @param cmdToEnter command that will be invoked using the search field
6868
*/
6969
public void invokeCmd(String cmdToEnter) {
70-
JTextFieldFixture searchField = textField(JTextFieldFixture.Companion.byType(), Duration.ofSeconds(10));
70+
JTextFieldFixture searchField = textField(JTextFieldFixture.Companion.byType(), Duration.ofSeconds(2));
7171
searchField.click();
7272
searchField.setText(cmdToEnter);
7373
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "The search in the Search Everywhere popup did not finish in 30 seconds.", () -> didSearchFinish(cmdToEnter));

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
@DefaultXpath(by = "MyDialog type", xpath = XPathDefinitions.DIALOG_ROOT_PANE)
3636
@FixtureName(name = "New Project Dialog")
3737
public abstract class AbstractNewProjectFinalPage extends CommonContainerFixture {
38+
39+
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
40+
3841
protected AbstractNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
3942
super(remoteRobot, remoteComponent);
4043
}
@@ -45,7 +48,7 @@ protected AbstractNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull
4548
* @return currently set new project name
4649
*/
4750
public String getProjectName() {
48-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
51+
if (ideaVersionInt >= 20221) {
4952
return textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).getText();
5053
} else {
5154
return textFields(JTextFieldFixture.Companion.byType()).get(0).getText();
@@ -58,7 +61,7 @@ public String getProjectName() {
5861
* @param projectName name of the new project
5962
*/
6063
public void setProjectName(String projectName) {
61-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
64+
if (ideaVersionInt >= 20221) {
6265
textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).setText(projectName);
6366
} else {
6467
textFields(JTextFieldFixture.Companion.byType()).get(0).setText(projectName);
@@ -71,7 +74,7 @@ public void setProjectName(String projectName) {
7174
* @return currently set new project location
7275
*/
7376
public String getProjectLocation() {
74-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
77+
if (ideaVersionInt >= 20221) {
7578
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).getText();
7679
} else {
7780
return textFields(JTextFieldFixture.Companion.byType()).get(1).getText();
@@ -84,7 +87,7 @@ public String getProjectLocation() {
8487
* @param projectLocation project location of the new project
8588
*/
8689
public void setProjectLocation(String projectLocation) {
87-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
90+
if (ideaVersionInt >= 20221) {
8891
find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD )).setText(projectLocation);
8992
} else {
9093
textFields(JTextFieldFixture.Companion.byType()).get(1).setText(projectLocation);
@@ -96,7 +99,7 @@ public void setProjectLocation(String projectLocation) {
9699
*/
97100
public void openAdvanceSettings() {
98101
if (!isAdvancedSettingsOpened()) {
99-
if (UITestRunner.getIdeaVersionInt() >= 20222) {
102+
if (ideaVersionInt >= 20222) {
100103
find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click();
101104
} else {
102105
find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click();
@@ -109,7 +112,7 @@ public void openAdvanceSettings() {
109112
*/
110113
public void closeAdvanceSettings() {
111114
if (isAdvancedSettingsOpened()) {
112-
if (UITestRunner.getIdeaVersionInt() >= 20222) {
115+
if (ideaVersionInt >= 20222) {
113116
find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click();
114117
} else {
115118
find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click();
@@ -120,7 +123,7 @@ public void closeAdvanceSettings() {
120123
private boolean isAdvancedSettingsOpened() {
121124
List<ComponentFixture> cf;
122125

123-
if (UITestRunner.getIdeaVersionInt() >= 20222) {
126+
if (ideaVersionInt >= 20222) {
124127
cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS));
125128
} else {
126129
cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS));

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
@DefaultXpath(by = "MyDialog type", xpath = XPathDefinitions.DIALOG_ROOT_PANE)
3737
@FixtureName(name = "New Project Dialog")
3838
public class JavaNewProjectFinalPage extends AbstractNewProjectFinalPage {
39+
40+
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
41+
3942
public JavaNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
4043
super(remoteRobot, remoteComponent);
4144
}
@@ -70,10 +73,10 @@ public void closeMoreSettings() {
7073
* @return name of the module currently inserted in the input field
7174
*/
7275
public String getModuleName() {
73-
if (UITestRunner.getIdeaVersionInt() >= 20242) {
76+
if (ideaVersionInt >= 20242) {
7477
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).getText();
7578
}
76-
else if (UITestRunner.getIdeaVersionInt() >= 20221) {
79+
else if (ideaVersionInt >= 20221) {
7780
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText();
7881
} else {
7982
return textField("Module name:", true).getText();
@@ -86,10 +89,10 @@ else if (UITestRunner.getIdeaVersionInt() >= 20221) {
8689
* @param moduleName name of the module that will be set into the input field
8790
*/
8891
public void setModuleName(String moduleName) {
89-
if (UITestRunner.getIdeaVersionInt() >= 20242) {
92+
if (ideaVersionInt >= 20242) {
9093
find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).setText(moduleName);
9194
}
92-
else if (UITestRunner.getIdeaVersionInt() >= 20221) {
95+
else if (ideaVersionInt >= 20221) {
9396
find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName);
9497
} else {
9598
textField("Module name:", true).setText(moduleName);
@@ -102,7 +105,7 @@ else if (UITestRunner.getIdeaVersionInt() >= 20221) {
102105
* @return location of the content root currently inserted in the input field
103106
*/
104107
public String getContentRoot() {
105-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
108+
if (ideaVersionInt >= 20221) {
106109
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).getText();
107110
} else {
108111
return textField("Content root:", true).getText();
@@ -115,7 +118,7 @@ public String getContentRoot() {
115118
* @param contentRoot location of the content root that will be set into the input field
116119
*/
117120
public void setContentRoot(String contentRoot) {
118-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
121+
if (ideaVersionInt >= 20221) {
119122
find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).setText(contentRoot);
120123
} else {
121124
textField("Content root:", true).setText(contentRoot);
@@ -128,7 +131,7 @@ public void setContentRoot(String contentRoot) {
128131
* @return location of the module file currently inserted in the input field
129132
*/
130133
public String getModuleFileLocation() {
131-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
134+
if (ideaVersionInt >= 20221) {
132135
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).getText();
133136
} else {
134137
return textField("Module file location:", true).getText();
@@ -141,7 +144,7 @@ public String getModuleFileLocation() {
141144
* @param moduleFileLocation location of the module file that will be set into the input field
142145
*/
143146
public void setModuleFileLocation(String moduleFileLocation) {
144-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
147+
if (ideaVersionInt >= 20221) {
145148
find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).setText(moduleFileLocation);
146149
} else {
147150
textField("Module file location:", true).setText(moduleFileLocation);

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@
4848
public class NewProjectFirstPage extends AbstractNewProjectFinalPage {
4949
protected final RemoteRobot remoteRobot;
5050
private boolean isProjectSdkItemsLoaded = false;
51-
private final int ideaVersion;
51+
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
5252

5353
public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
5454
super(remoteRobot, remoteComponent);
5555
this.remoteRobot = remoteRobot;
56-
this.ideaVersion = UITestRunner.getIdeaVersion().toInt();
5756
}
5857

5958
/**
@@ -85,7 +84,7 @@ public JTextFieldFixture getProjectNameTextField() {
8584
* @param language project language
8685
*/
8786
public void setLanguage(String language) {
88-
if (ideaVersion >= 20241) {
87+
if (ideaVersionInt >= 20241) {
8988
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
9089
jListFixture.clickItem(language, false);
9190
} else {
@@ -99,7 +98,7 @@ public void setLanguage(String language) {
9998
* @param buildSystem build system type
10099
*/
101100
public void setBuildSystem(String buildSystem) {
102-
if (ideaVersion >= 20241) {
101+
if (ideaVersionInt >= 20241) {
103102
find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM_2024_2_AND_NEWER)).findText(buildSystem).click();
104103
} else {
105104
find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM)).findText(buildSystem).click();
@@ -112,7 +111,7 @@ public void setBuildSystem(String buildSystem) {
112111
* @return JdkComboBox fixture
113112
*/
114113
public ComboBoxFixture getProjectJdkComboBox() {
115-
if (ideaVersion >= 20241) {
114+
if (ideaVersionInt >= 20241) {
116115
return comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX_PROJECT_WIZARD), Duration.ofSeconds(10));
117116
}
118117
return comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10));
@@ -140,7 +139,7 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
140139
return;
141140
}
142141

143-
if (UITestRunner.getIdeaVersionInt() >= 20221) {
142+
if (ideaVersionInt >= 20221) {
144143
projectJdkComboBox.click();
145144
boolean popupOpenedPermanently = false;
146145
try {

0 commit comments

Comments
 (0)