Skip to content

Commit 3b29ce7

Browse files
authored
fix: fix for 2023.3 use case (#351)
* fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> * fix: fix for 2023.3 use case Signed-off-by: Stephane Bouchet <[email protected]> --------- Signed-off-by: Stephane Bouchet <[email protected]>
1 parent ce1e750 commit 3b29ce7

File tree

10 files changed

+171
-16
lines changed

10 files changed

+171
-16
lines changed

.github/workflows/validate.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Sonar
2+
on:
3+
workflow_run:
4+
workflows: [Java CI with Gradle]
5+
types:
6+
- completed
7+
jobs:
8+
validate_versions:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
IJ:
14+
- 2020.2
15+
- 2020.3
16+
- 2021.1
17+
- 2021.2
18+
- 2021.3
19+
- 2022.1
20+
- 2022.2
21+
- 2022.3
22+
- 2023.1
23+
- 2023.2
24+
- 2023.3
25+
- 2024.1
26+
- 2024.2
27+
- 2024.3
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: 11
35+
distribution: 'temurin'
36+
cache: 'gradle'
37+
- name: Set up JDK 17
38+
uses: actions/setup-java@v4
39+
with:
40+
java-version: 17
41+
distribution: 'temurin'
42+
cache: 'gradle'
43+
- name: Run integration tests
44+
run: |
45+
cd src/test-project
46+
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none -PcommunityIdeaVersion=${{ matrix.IJ }}
47+
- name: Archiving tests reports
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: linux-test-reports-${{ matrix.IJ }}
51+
path: src/test-project/build/reports/tests/*
52+
if: always()
53+
- name: Archiving screenshots
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: linux-screenshots-${{ matrix.IJ }}
57+
path: src/test-project/build/screenshots/*
58+
if-no-files-found: ignore
59+
if: always()
60+
- name: Archiving StepLogger logs
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: linux-steplogger-logs-${{ matrix.IJ }}
64+
path: src/test-project/build/test-results/*
65+
if: always()

gradle/verification-metadata.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<trusted-key id="2E3A1AFFE42B5F53AF19F780BCF4173966770193" group="org.jetbrains"/>
1313
<trusted-key id="A413F67D71BEEC23ADD0CE0ACB43338E060CF9FA" group="org.jacoco"/>
1414
<trusted-key id="60200AC4AE761F1614D6C46766D68DAA073BE985" group="org.slf4j"/>
15+
<trusted-key id="73B03597B892A329DC9B0F43CF84722DFC242EB9" group="org.easytesting"/>
1516
<trusted-key id="6A30D7A614899833CE2F5FA3CEE8B79520334B30" group="org.assertj" version="2.2.1"/>
1617
<trusted-key id="A778FDE933A96DDA827840D8E2B3D84202B812D9" group="org.assertj" version="2.2.7"/>
1718
<trusted-key id="A5BD02B93E7A40482EB1D66A5F69AD087600B22C" group="org.ow2.asm" name="asm-bom" version="9.5"/>
@@ -116,6 +117,21 @@
116117
<sha256 value="0e946f486b972c080fc229f65373d15104af6674c630fd9f125c4fd72120773b" origin="Generated by Gradle" reason="Artifact is not signed"/>
117118
</artifact>
118119
</component>
120+
<component group="org.jacoco" name="org.jacoco.build" version="0.8.9">
121+
<artifact name="org.jacoco.build-0.8.9.pom">
122+
<sha256 value="02678f267cdaa23ff51772ad1f033a1f3ff5741cc10d444740bd4834d47583b3" origin="Generated by Gradle" reason="Artifact is not signed"/>
123+
</artifact>
124+
</component>
125+
<component group="org.jacoco" name="org.jacoco.core" version="0.8.9">
126+
<artifact name="org.jacoco.core-0.8.9.pom">
127+
<sha256 value="5404f7052765a64374d275367fd9485bb5996b369113c89a8557d8f024810f02" origin="Generated by Gradle"/>
128+
</artifact>
129+
</component>
130+
<component group="org.jacoco" name="org.jacoco.report" version="0.8.9">
131+
<artifact name="org.jacoco.report-0.8.9.pom">
132+
<sha256 value="81e413bdde52bc70ae63f5cb14e524e5691532db7779b55d5899ee5c0b6fb871" origin="Generated by Gradle"/>
133+
</artifact>
134+
</component>
119135
<component group="org.jetbrains" name="annotations" version="13.0">
120136
<artifact name="annotations-13.0.jar">
121137
<sha256 value="ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -129,6 +145,11 @@
129145
<sha256 value="f13df2e4caf1febce567667e7c378101a0331d53d1324d6e2dfe3aecfb1f7774" origin="Generated by Gradle" reason="Artifact is not signed"/>
130146
</artifact>
131147
</component>
148+
<component group="org.junit" name="junit-bom" version="5.12.2">
149+
<artifact name="junit-bom-5.12.2.pom">
150+
<sha256 value="cef80fec86454f6806bfb0df24669b5c6f32e2cb728539ea859f47dfdc9bbc17" origin="Generated by Gradle" reason="Artifact is not signed"/>
151+
</artifact>
152+
</component>
132153
<component group="org.junit" name="junit-bom" version="5.5.2">
133154
<artifact name="junit-bom-5.5.2.pom">
134155
<sha256 value="5a49562a4704541e69d4ee316cd7eaf711cddb7cad5d0f886bf8a1fe98d6a9c5" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -147,6 +168,14 @@
147168
<sha256 value="f19afe0923b01935c40f2e7e96d66037e2008b7017917cc7051338377849618e" origin="Generated by Gradle" reason="Artifact is not signed"/>
148169
</artifact>
149170
</component>
171+
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.12.2">
172+
<artifact name="junit-jupiter-api-5.12.2.jar">
173+
<sha256 value="0b9ca728e4bcd9adc57f29deb9556ff9ed5e08b4e8843b875aba4e4e3e04f092" origin="Generated by Gradle" reason="Artifact is not signed"/>
174+
</artifact>
175+
<artifact name="junit-jupiter-api-5.12.2.pom">
176+
<sha256 value="566282166489bd40b12c3507b995e48f8e025e09a05e7d16dd2b98dc642cf7de" origin="Generated by Gradle" reason="Artifact is not signed"/>
177+
</artifact>
178+
</component>
150179
<component group="org.junit.platform" name="junit-platform-commons" version="1.11.3">
151180
<artifact name="junit-platform-commons-1.11.3.jar">
152181
<sha256 value="be262964b0b6b48de977c61d4f931df8cf61e80e750cc3f3a0a39cdd21c1008c" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -155,6 +184,14 @@
155184
<sha256 value="816ebd3244a770d915d9c1d40d3b4651fe348f42f89b7cb7ebd0dee209c52040" origin="Generated by Gradle" reason="Artifact is not signed"/>
156185
</artifact>
157186
</component>
187+
<component group="org.junit.platform" name="junit-platform-commons" version="1.12.2">
188+
<artifact name="junit-platform-commons-1.12.2.jar">
189+
<sha256 value="e683a01e85dfabea520c056ac6015a6162756e602ec653c0da85e233f0afbc18" origin="Generated by Gradle" reason="Artifact is not signed"/>
190+
</artifact>
191+
<artifact name="junit-platform-commons-1.12.2.pom">
192+
<sha256 value="4f2b8a9065c909c6892d8622d553b6ab0a70321624499e3b69c1289f59ecc077" origin="Generated by Gradle" reason="Artifact is not signed"/>
193+
</artifact>
194+
</component>
158195
<component group="org.opentest4j" name="opentest4j" version="1.3.0">
159196
<artifact name="opentest4j-1.3.0.jar">
160197
<sha256 value="48e2df636cab6563ced64dcdff8abb2355627cb236ef0bf37598682ddf742f1b" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -163,6 +200,11 @@
163200
<sha256 value="9bf7cffc410f3e8372c2522578df9ca56d9d43bd937e30948706c232a943b355" origin="Generated by Gradle" reason="Artifact is not signed"/>
164201
</artifact>
165202
</component>
203+
<component group="org.ow2" name="ow2" version="1.5.1">
204+
<artifact name="ow2-1.5.1.pom">
205+
<sha256 value="321ddbb7ee6fe4f53dea6b4cd6db74154d6bfa42391c1f763b361b9f485acf05" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
206+
</artifact>
207+
</component>
166208
<component group="org.ow2.asm" name="asm" version="9.5">
167209
<artifact name="asm-9.5.jar">
168210
<sha256 value="b62e84b5980729751b0458c534cf1366f727542bb8d158621335682a460f0353" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -174,6 +216,7 @@
174216
<component group="org.ow2.asm" name="asm-bom" version="9.5">
175217
<artifact name="asm-bom-9.5.pom">
176218
<pgp value="A5BD02B93E7A40482EB1D66A5F69AD087600B22C"/>
219+
<sha256 value="71756b35dd837db638806f00f4077e8bb35fe8d80bd674e8141a307c811635bf" origin="Generated by Gradle"/>
177220
</artifact>
178221
</component>
179222
<component group="org.ow2.asm" name="asm-commons" version="9.5">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersion, int port) {
8080
ProcessBuilder pb;
8181

8282
if (ideaVersion.toInt() < 20242) {
83-
pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + ideaVersion, "-Drobot-server.port=" + port);
83+
pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformTypeVersion[1], "-Drobot-server.port=" + port);
8484
} else {
8585
pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-Drobot-server.port=" + port, "-PplatformType=" + platformTypeVersion[0], "-PplatformVersion=" + platformTypeVersion[1]);
8686
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,21 @@ 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+
invokeSearch(cmdToEnter, true);
71+
}
72+
73+
public void searchText(String searchString){
74+
invokeSearch(searchString, false);
75+
}
76+
77+
private void invokeSearch(String searchText, boolean invoke){
7078
JTextFieldFixture searchField = textField(JTextFieldFixture.Companion.byType(), Duration.ofSeconds(2));
7179
searchField.click();
72-
searchField.setText(cmdToEnter);
73-
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "The search in the Search Everywhere popup did not finish in 30 seconds.", () -> didSearchFinish(cmdToEnter));
74-
new Keyboard(remoteRobot).hotKey(KeyEvent.VK_ENTER);
80+
searchField.setText(searchText);
81+
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "the search dialog in the Search Everywhere popup to load in 30 seconds.", () -> didSearchFinish(searchText));
82+
if(invoke){
83+
new Keyboard(remoteRobot).hotKey(KeyEvent.VK_ENTER);
84+
}
7585
}
7686

7787
private boolean didSearchFinish(String cmdToInvoke) {

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public void maximizeIdeWindow() {
7878
* Close the currently opened project
7979
*/
8080
public void closeProject() {
81-
if (remoteRobot.isWin()) {
82-
new MenuBar(remoteRobot).navigateTo("File", "Close Project");
83-
} else {
81+
if (remoteRobot.isMac()) {
8482
invokeCmdUsingSearchEverywherePopup("Close Project");
83+
} else {
84+
new MenuBar(remoteRobot).navigateTo("File", "Close Project");
8585
}
8686
IdeInternalErrorUtils.clearWindowsErrorsIfTheyAppear(remoteRobot);
8787
remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)).runJs("const horizontal_offset = component.getWidth()/2;\n" +
@@ -98,6 +98,11 @@ public void invokeCmdUsingSearchEverywherePopup(String cmdToInvoke) {
9898
searchEverywherePopup.invokeCmd(cmdToInvoke);
9999
}
100100

101+
public void searchEverywhere(String searchString) {
102+
SearchEverywherePopup searchEverywherePopup = openSearchEverywherePopup();
103+
searchEverywherePopup.searchText(searchString);
104+
}
105+
101106
private SearchEverywherePopup openSearchEverywherePopup() {
102107
try {
103108
find(ActionButtonFixture.class, byXpath("//div[@myicon='search.svg']"), Duration.ofSeconds(5)).click();

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/idestatusbar/IdeStatusBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void waitUntilAllBgTasksFinish() {
6767
* Wait until all the background tasks finish
6868
*/
6969
public void waitUntilAllBgTasksFinish(int timeout) {
70-
waitFor(Duration.ofSeconds(timeout), Duration.ofSeconds(10), "The background tasks did not finish in " + timeout + " seconds.", this::didAllBgTasksFinish);
70+
waitFor(Duration.ofSeconds(timeout), Duration.ofSeconds(10), "the background tasks to finish in " + timeout + " seconds.", this::didAllBgTasksFinish);
7171
}
7272

7373
private boolean didProjectImportFinish() {

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
import com.intellij.remoterobot.RemoteRobot;
1414
import com.intellij.remoterobot.fixtures.ActionButtonFixture;
1515
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
16+
import com.intellij.remoterobot.fixtures.ComponentFixture;
1617
import com.intellij.remoterobot.fixtures.JButtonFixture;
1718
import com.intellij.remoterobot.fixtures.JPopupMenuFixture;
19+
import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText;
20+
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
1821
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
22+
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.MainIdeWindow;
1923
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
24+
import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils;
25+
import org.jetbrains.annotations.NotNull;
2026

2127
import java.time.Duration;
2228
import java.util.List;
29+
import java.util.Optional;
2330

2431
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
2532
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor;
@@ -35,6 +42,7 @@ public class MenuBar {
3542

3643
public MenuBar(RemoteRobot remoteRobot) {
3744
this.remoteRobot = remoteRobot;
45+
checkVisibility();
3846
}
3947

4048
/**
@@ -60,7 +68,7 @@ public void navigateTo(String... path) {
6068

6169
// Wait for the JPopupMenuFixture to appear
6270
waitFor(Duration.ofSeconds(5), Duration.ofSeconds(1), "JPopupMenu to appear", () ->
63-
!remoteRobot.findAll(JPopupMenuFixture.class, JPopupMenuFixture.Companion.byType()).isEmpty()
71+
!remoteRobot.findAll(JPopupMenuFixture.class, JPopupMenuFixture.Companion.byType()).isEmpty()
6472
);
6573
}
6674

@@ -83,7 +91,11 @@ private JButtonFixture mainMenuItem(String label) {
8391
if (remoteRobot.isMac()) {
8492
return null;
8593
}
94+
return getMainMenu().button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(10));
95+
}
8696

97+
@NotNull
98+
public CommonContainerFixture getMainMenu() {
8799
CommonContainerFixture cf;
88100
if (remoteRobot.isLinux() && ideaVersionInt <= 20242) {
89101
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(10));
@@ -96,7 +108,25 @@ private JButtonFixture mainMenuItem(String label) {
96108
} else {
97109
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_2_AND_OLDER), Duration.ofSeconds(10));
98110
}
111+
return cf;
112+
}
99113

100-
return cf.button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(10));
114+
private void checkVisibility() {
115+
// check menu already visible
116+
try {
117+
getMainMenu();
118+
} catch (WaitForConditionTimeoutException e) {
119+
// not visible
120+
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
121+
mainIdeWindow.searchEverywhere("Appearance");
122+
ComponentFixture appearanceDialog = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='SearchEverywhereUI']"));
123+
List<RemoteText> items = appearanceDialog.findAllText();
124+
Optional<RemoteText> item = items.stream().filter(remoteText -> remoteText.getText().equals("View | Appearance: Main Menu")).findFirst();
125+
if (item.isPresent()) {
126+
item.get().click();
127+
} else {
128+
ScreenshotUtils.takeScreenshot(remoteRobot, "Can't find 'Appearance' Main menu item");
129+
}
130+
}
101131
}
102132
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class XPathDefinitions {
137137
@Language("XPath")
138138
public static final String SET_LANGUAGE = "//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]";
139139
@Language("XPath")
140-
public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]";
140+
public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@visible_text='IntelliJ']]";
141141
@Language("XPath")
142142
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
143143
@Language("XPath")

src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
*/
4040
public class CreateCloseUtils {
4141

42+
static final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
43+
4244
/**
4345
* Create new project with given project name according to given project type
4446
*
@@ -50,8 +52,6 @@ public static void createNewProject(RemoteRobot remoteRobot, String projectName,
5052
NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot);
5153
NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10));
5254

53-
final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
54-
5555
if (ideaVersionInt >= 20221) {
5656
newProjectFirstPage.selectNewProjectType("New Project");
5757
newProjectFirstPage.setLanguage("Java");
@@ -119,8 +119,10 @@ public static void createEmptyProject(RemoteRobot remoteRobot, String projectNam
119119
public static void waitAfterOpeningProject(RemoteRobot remoteRobot) {
120120
IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10));
121121
ideStatusBar.waitUntilProjectImportIsComplete();
122-
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
123-
mainIdeWindow.maximizeIdeWindow();
122+
if (ideaVersionInt > 20233) {
123+
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
124+
mainIdeWindow.maximizeIdeWindow();
125+
}
124126
ideStatusBar.waitUntilAllBgTasksFinish(500);
125127
CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot);
126128
}

src/test-project/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
33
plugins {
44
id("java")
55
id("jacoco")
6-
id("org.jetbrains.intellij.platform") version ("2.2.1")
6+
id("org.jetbrains.intellij.platform") version ("2.6.0")
77
}
88

99
group = "com.redhat.devtools.intellij"

0 commit comments

Comments
 (0)