Skip to content

Commit 6ed4a50

Browse files
committed
chore: fix integration tests
Signed-off-by: Stephane Bouchet <[email protected]>
1 parent 9a732e9 commit 6ed4a50

File tree

4 files changed

+52
-49
lines changed

4 files changed

+52
-49
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ jobs:
6767
- name: Archiving tests reports
6868
uses: actions/upload-artifact@v4
6969
with:
70-
name: ${{ matrix.os }}-mainidewindow.idestatusbar-test-reports
70+
name: ${{ matrix.os }}-mainidewindow-idestatusbar-test-reports
7171
path: src/test-project/build/reports/tests/*
7272
if: always()
7373
- name: Archiving screenshots
7474
uses: actions/upload-artifact@v4
7575
with:
76-
name: ${{ matrix.os }}-mainidewindow.idestatusbar-screenshots
76+
name: ${{ matrix.os }}-mainidewindow-idestatusbar-screenshots
7777
path: src/test-project/build/screenshots/*
7878
if: always()
7979
- name: Archiving StepLogger logs
8080
uses: actions/upload-artifact@v4
8181
with:
82-
name: ${{ matrix.os }}-mainidewindow.idestatusbar-steplogger-logs
82+
name: ${{ matrix.os }}-mainidewindow-idestatusbar-steplogger-logs
8383
path: src/test-project/build/test-results/*
8484
if: always()
8585

@@ -119,19 +119,19 @@ jobs:
119119
- name: Archiving tests reports
120120
uses: actions/upload-artifact@v4
121121
with:
122-
name: ${{ matrix.os }}-dialogs_information_settings-test-reports
122+
name: ${{ matrix.os }}-dialogs-information-settings-test-reports
123123
path: src/test-project/build/reports/tests/*
124124
if: always()
125125
- name: Archiving screenshots
126126
uses: actions/upload-artifact@v4
127127
with:
128-
name: ${{ matrix.os }}-dialogs_information_settings-screenshots
128+
name: ${{ matrix.os }}-dialogs-information-settings-screenshots
129129
path: src/test-project/build/screenshots/*
130130
if: always()
131131
- name: Archiving StepLogger logs
132132
uses: actions/upload-artifact@v4
133133
with:
134-
name: ${{ matrix.os }}-dialogs_information_settings-steplogger-logs
134+
name: ${{ matrix.os }}-dialogs-information-settings-steplogger-logs
135135
path: src/test-project/build/test-results/*
136136
if: always()
137137

@@ -177,19 +177,19 @@ jobs:
177177
- name: Archiving tests reports
178178
uses: actions/upload-artifact@v4
179179
with:
180-
name: ${{ matrix.os }}-dialogs_project_manipulation-test-reports
180+
name: ${{ matrix.os }}-dialogs-project-manipulation-test-reports
181181
path: src/test-project/build/reports/tests/*
182182
if: always()
183183
- name: Archiving screenshots
184184
uses: actions/upload-artifact@v4
185185
with:
186-
name: ${{ matrix.os }}-dialogs_project_manipulation-screenshots
186+
name: ${{ matrix.os }}-dialogs-project-manipulation-screenshots
187187
path: src/test-project/build/screenshots/*
188188
if: always()
189189
- name: Archiving StepLogger logs
190190
uses: actions/upload-artifact@v4
191191
with:
192-
name: ${{ matrix.os }}-dialogs_project_manipulation-steplogger-logs
192+
name: ${{ matrix.os }}-dialogs-project-manipulation-steplogger-logs
193193
path: src/test-project/build/test-results/*
194194
if: always()
195195

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

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import java.time.Duration;
3232
import java.util.List;
33+
import java.util.Optional;
3334

3435
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
3536
import static com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step;
@@ -121,21 +122,21 @@ public ComboBoxFixture getProjectJdkComboBox() {
121122
* @param targetSdkName name of the SDK to which will be changed the current settings
122123
*/
123124
public void setProjectSdkIfAvailable(String targetSdkName) {
124-
step("Select the '" + targetSdkName + "' as new project SDK", () -> {
125-
126-
waitFor(
127-
Duration.ofSeconds(20),
128-
Duration.ofSeconds(5),
129-
"Waiting for 'resolving jdk' dialog to disappear.",
130-
() -> "Expected exactly one dialog but found " + remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size(),
131-
() -> remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size() == 1
132-
);
133-
134-
ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox();
135-
String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText());
136-
if (currentlySelectedProjectSdk.contains(targetSdkName)) {
137-
return;
138-
}
125+
step("Select the '" + targetSdkName + "' as new project SDK", () -> {
126+
127+
waitFor(
128+
Duration.ofSeconds(20),
129+
Duration.ofSeconds(5),
130+
"Waiting for 'resolving jdk' dialog to disappear.",
131+
() -> "Expected exactly one dialog but found " + remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size(),
132+
() -> remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size() == 1
133+
);
134+
135+
ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox();
136+
String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText());
137+
if (currentlySelectedProjectSdk.contains(targetSdkName)) {
138+
return;
139+
}
139140

140141
if (UITestRunner.getIdeaVersionInt() >= 20221) {
141142
projectJdkComboBox.click();
@@ -152,17 +153,9 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
152153

153154
CommonContainerFixture parentFixture = waitFor(Duration.ofSeconds(20), Duration.ofSeconds(2), "Wait for the 'Project SDK' list to finish loading all items.", "The project JDK list did not load all items in 20 seconds.", this::didProjectSdkListLoadAllItems);
154155
JPopupMenuFixture projectSdkList = parentFixture.jPopupMenus(byXpath(XPathDefinitions.HEAVY_WEIGHT_WINDOW)).get(0); // issue https://github.com/JetBrains/intellij-ui-test-robot/issues/104
155-
List<RemoteText> sdkItems = projectSdkList.findAllText();
156-
for (RemoteText sdkItem : sdkItems) {
157-
if (sdkItem.getText().contains(targetSdkName)) {
158-
try {
159-
sdkItem.click();
160-
} catch (Exception e) {
161-
// issue #83 in the Remote-Robot framework - https://github.com/JetBrains/intellij-ui-test-robot/issues/83
162-
break;
163-
}
164-
}
165-
}
156+
List<String> sdkItems = projectSdkList.jList().collectItems();
157+
Optional<String> item = sdkItems.stream().filter(s -> s.startsWith(targetSdkName)).findFirst();
158+
item.ifPresent(s -> projectSdkList.jList().clickItem(s, true));
166159
});
167160
}
168161

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ public class XPathDefinitions {
5252
public static final String IDE_ERROR_ICON = "//div[@class='IdeErrorsIcon']";
5353
public static final String BUILD_VIEW_EDITOR = "//div[@accessiblename='Editor']";
5454
public static final String JCOMBOBOX = "//div[@class='JComboBox']";
55+
@Language("XPath")
5556
public static final String MORE_SETTINGS_TITLED_SEPARATOR = "//div[@class='TitledSeparator']/../../*";
57+
@Language("XPath")
5658
public static final String ARTIFACTS_COORDINATES_DIALOG_PANEL = "//div[@class='DialogPanel']/*";
59+
@Language("XPath")
5760
public static final String HEAVY_WEIGHT_WINDOW = "//div[@class='HeavyWeightWindow']";
61+
@Language("XPath")
5862
public static final String JDK_COMBOBOX = "//div[@class='JdkComboBox']";
63+
@Language("XPath")
5964
public static final String JDK_COMBOBOX_PROJECT_WIZARD = "//div[@class='ProjectWizardJdkComboBox']"; // works for IntelliJ Idea 2024.1 and higher
6065
@Language("XPath")
6166
public static final String MY_DIALOG = "//div[@class='MyDialog']";
@@ -84,18 +89,23 @@ public class XPathDefinitions {
8489
public static final String MY_LIST = "//div[@class='MyList']";
8590
public static final String CODE_WITH_ME_JPANEL = "//div[@class='Wrapper'][.//div[@class='JBLabel']]//div[@class='JPanel']";
8691
public static final String BREAD_CRUMBS = "//div[@class='Breadcrumbs']";
92+
@Language("XPath")
8793
public static final String EMPTY_PROJECT = "//div[@visible_text='Empty Project']";
8894
public static final String SINGLE_HEIGHT_LABEL = "//div[@class='SingleHeightLabel']";
8995
public static final String COLLAPSIBLE_TITLED_SEPARATOR = "//div[@class='CollapsibleTitledSeparator']";
9096
public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW = "//div[@class='CollapsibleTitledSeparatorImpl']";
9197
public static final String COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR + "/../*";
9298
public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR_NEW + "/../*";
9399
public static final String EXTENDABLE_TEXT_FIELD = "//div[@class='ExtendableTextField']";
100+
@Language("XPath")
94101
public static final String JBTEXT_FIELD = "//div[@class='JBTextField']";
95102
@Language("XPath")
96103
public static final String REMOVE_PROJECT_BUTTON = "//div[contains(@text.key, 'button.remove')]";
104+
@Language("XPath")
97105
public static final String SET_LANGUAGE = "//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]";
106+
@Language("XPath")
98107
public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]";
108+
@Language("XPath")
99109
public static final String SET_BUILD_SYSTEM_2024_2_AND_NEWER = "//div[@accessiblename='Build system:' and @class='SegmentedButtonComponent']"; // works for IntelliJ Idea 2024.1 and higher
100110
public static final String GET_SET_MODULE_NAME = "//div[@accessiblename='Module name:' and @class='JBTextField']";
101111
public static final String GET_SET_MODULE_NAME_2024_2_AND_NEWER = "//div[@accessiblename='Module name:' and @class='JBTextField']";

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels;
2828
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
2929
import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils;
30-
import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils;
3130
import org.junit.jupiter.api.AfterEach;
3231
import org.junit.jupiter.api.BeforeEach;
3332
import org.junit.jupiter.api.Test;
@@ -38,6 +37,7 @@
3837

3938
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
4039
import static com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils.listOfRemoteTextToString;
40+
import static org.junit.jupiter.api.Assertions.assertEquals;
4141
import static org.junit.jupiter.api.Assertions.assertFalse;
4242
import static org.junit.jupiter.api.Assertions.assertThrows;
4343
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -167,7 +167,7 @@ public void getSetModuleNameTest() {
167167
String newModuleName = currentModuleName + "1";
168168
javaFinalPage.setModuleName(newModuleName);
169169
currentModuleName = javaFinalPage.getModuleName();
170-
assertTrue(currentModuleName.equals(newModuleName), "Currently set module name should be '" + newModuleName + BUT_IS + currentModuleName + "'.");
170+
assertEquals(currentModuleName, newModuleName, "Currently set module name should be '" + newModuleName + BUT_IS + currentModuleName + "'.");
171171
}
172172

173173
@Test
@@ -184,7 +184,7 @@ public void getSetContentRootTest() {
184184
String newContentRoot = currentContentRoot + "1";
185185
javaFinalPage.setContentRoot(newContentRoot);
186186
currentContentRoot = javaFinalPage.getContentRoot();
187-
assertTrue(currentContentRoot.equals(newContentRoot), "Currently set content root location should be '" + newContentRoot + BUT_IS + currentContentRoot + "'.");
187+
assertEquals(currentContentRoot, newContentRoot, "Currently set content root location should be '" + newContentRoot + BUT_IS + currentContentRoot + "'.");
188188
}
189189

190190
@Test
@@ -201,7 +201,7 @@ public void getSetModuleFileLocationTest() {
201201
String newModuleFileLocation = currentModuleFileLocation + "1";
202202
javaFinalPage.setModuleFileLocation(newModuleFileLocation);
203203
currentModuleFileLocation = javaFinalPage.getModuleFileLocation();
204-
assertTrue(currentModuleFileLocation.equals(newModuleFileLocation), "Currently set module file location should be '" + newModuleFileLocation + BUT_IS + currentModuleFileLocation + "'.");
204+
assertEquals(currentModuleFileLocation, newModuleFileLocation, "Currently set module file location should be '" + newModuleFileLocation + BUT_IS + currentModuleFileLocation + "'.");
205205
}
206206

207207
@Test
@@ -213,10 +213,10 @@ public void getSetProjectFormat() {
213213

214214
javaFinalPage.setProjectFormat(AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED);
215215
AbstractNewProjectFinalPage.ProjectFormatType currentlySetProjectFormatType = javaFinalPage.getProjectFormat();
216-
assertTrue(currentlySetProjectFormatType.equals(AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED), "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED + BUT_IS + currentlySetProjectFormatType + "'.");
216+
assertEquals(AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED, currentlySetProjectFormatType, "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED + BUT_IS + currentlySetProjectFormatType + "'.");
217217
javaFinalPage.setProjectFormat(AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED);
218218
currentlySetProjectFormatType = javaFinalPage.getProjectFormat();
219-
assertTrue(currentlySetProjectFormatType.equals(AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED), "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED + BUT_IS + currentlySetProjectFormatType + "'.");
219+
assertEquals(AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED, currentlySetProjectFormatType, "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED + BUT_IS + currentlySetProjectFormatType + "'.");
220220
}
221221

222222
@Test
@@ -343,10 +343,10 @@ public void setProjectSdkIfAvailableTest() {
343343
newProjectFirstPage.setProjectSdkIfAvailable("11");
344344
ComboBoxFixture projectJdkComboBox = newProjectFirstPage.getProjectJdkComboBox();
345345
String currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText());
346-
assertTrue(currentlySelectedProjectSdk.contains("11"), "Selected project SDK should be Java 11 but is '" + currentlySelectedProjectSdk + "'");
346+
assertTrue(currentlySelectedProjectSdk.startsWith("11"), "Selected project SDK should be Java 11 but is '" + currentlySelectedProjectSdk + "'");
347347
newProjectFirstPage.setProjectSdkIfAvailable("17");
348348
currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText());
349-
assertTrue(currentlySelectedProjectSdk.contains("17"), "Selected project SDK should be Java 17 but is '" + currentlySelectedProjectSdk + "'");
349+
assertTrue(currentlySelectedProjectSdk.startsWith("17"), "Selected project SDK should be Java 17 but is '" + currentlySelectedProjectSdk + "'");
350350
}
351351
}
352352

@@ -426,13 +426,13 @@ private void testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectTyp
426426
String newProjectName = currentProjectName + "1";
427427
finalPage.setProjectName(newProjectName);
428428
currentProjectName = finalPage.getProjectName();
429-
assertTrue(currentProjectName.equals(newProjectName), "Currently set project name should be '" + newProjectName + BUT_IS + currentProjectName + "'.");
429+
assertEquals(currentProjectName, newProjectName, "Currently set project name should be '" + newProjectName + BUT_IS + currentProjectName + "'.");
430430

431431
String currentProjectLocation = finalPage.getProjectLocation();
432432
String newProjectLocation = currentProjectLocation + "2";
433433
finalPage.setProjectLocation(newProjectLocation);
434434
currentProjectLocation = finalPage.getProjectLocation();
435-
assertTrue(currentProjectLocation.equals(newProjectLocation), "Currently set project location should be '" + newProjectLocation + BUT_IS + currentProjectLocation + "'.");
435+
assertEquals(currentProjectLocation, newProjectLocation, "Currently set project location should be '" + newProjectLocation + BUT_IS + currentProjectLocation + "'.");
436436
}
437437

438438
private void testOpenArtifactCoordinatesMavenGradle(CreateCloseUtils.NewProjectType newProjectType) {
@@ -484,7 +484,7 @@ private void testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType n
484484
currentValue = mavenGradleFinalPage.getVersion();
485485
break;
486486
}
487-
assertTrue(currentValue.equals(newValue), "Currently set '" + attribute + "' should be '" + newValue + BUT_IS + currentValue + "'.");
487+
assertEquals(currentValue, newValue, "Currently set '" + attribute + "' should be '" + newValue + BUT_IS + currentValue + "'.");
488488
}
489489

490490
private boolean isMoreSettingsOpened(JavaNewProjectFinalPage javaFinalPage) {
@@ -511,15 +511,15 @@ private enum ArtifactCoordinatesAttributes {
511511
ARTIFACT_ID("artifact ID"),
512512
VERSION("version");
513513

514-
private final String textReperentation;
514+
private final String textRepresentation;
515515

516516
ArtifactCoordinatesAttributes(String textRepresentation) {
517-
this.textReperentation = textRepresentation;
517+
this.textRepresentation = textRepresentation;
518518
}
519519

520520
@Override
521521
public String toString() {
522-
return this.textReperentation;
522+
return this.textRepresentation;
523523
}
524524
}
525525
}

0 commit comments

Comments
 (0)