Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for IntelliJ 2024.1 #222

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ private JButtonFixture welcomeFrameLink(String label) {
if (UtilsKt.hasAnyComponent(this, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW))) {
return button(byXpath(XPathDefinitions.jBOptionButton(label)), Duration.ofSeconds(2));
}
if (ideaVersion >= 20241 && label.equals("New Project")) {
return button(byXpath(XPathDefinitions.CREATE_NEW_PROJECT), Duration.ofSeconds(2));
}
return button(byXpath(XPathDefinitions.nonOpaquePanel(label)), Duration.ofSeconds(2));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
public class NewProjectFirstPage extends AbstractNewProjectFinalPage {
private final RemoteRobot remoteRobot;
private int projectSdkItemsCount = -1;
private final int ideaVersion;

public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
super(remoteRobot, remoteComponent);
this.remoteRobot = remoteRobot;
this.ideaVersion = UITestRunner.getIdeaVersion().toInt();
}

/**
Expand Down Expand Up @@ -76,7 +78,12 @@ public void setProjectName(String projectName) {
* @param language project language
*/
public void setLanguage(String language) {
findAll(JLabelFixture.class, byXpath(XPathDefinitions.SET_LANGUAGE)).get(0).findText(language).click();
if (ideaVersion >= 20241) {
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
jListFixture.clickItem(language, false);
} else {
findAll(JLabelFixture.class, byXpath(XPathDefinitions.SET_LANGUAGE)).get(0).findText(language).click();
}
}

/**
Expand All @@ -85,7 +92,23 @@ public void setLanguage(String language) {
* @param buildSystem build system type
*/
public void setBuildSystem(String buildSystem) {
find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM)).findText(buildSystem).click();
if (ideaVersion >= 20241) {
find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM_2024_1_AND_NEWER)).findText(buildSystem).click();
} else {
find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM)).findText(buildSystem).click();
}
}

/**
* Get the project SDK JdkComboBox
*
* @return JdkComboBox fixture
*/
public ComboBoxFixture getProjectJdkComboBox() {
if (ideaVersion >= 20241) {
return comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX_PROJECT_WIZARD), Duration.ofSeconds(10));
}
return comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10));
}

/**
Expand All @@ -95,7 +118,7 @@ public void setBuildSystem(String buildSystem) {
*/
public void setProjectSdkIfAvailable(String targetSdkName) {
step("Select the '" + targetSdkName + "' as new project SDK", () -> {
ComboBoxFixture projectJdkComboBox = comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10));
ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox();
String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText());
if (currentlySelectedProjectSdk.contains(targetSdkName)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ private JButtonFixture mainMenuItem(String label) {
CommonContainerFixture cf;
if (remoteRobot.isLinux()) {
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(10));
} else if (remoteRobot.isWin() && ideaVersion.toInt() >= 20241) {
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2024_1_AND_NEWER), Duration.ofSeconds(10));
} else if (remoteRobot.isWin() && ideaVersion.toInt() >= 20222) {
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_AND_NEWER), Duration.ofSeconds(10));
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_TO_2023_2), Duration.ofSeconds(10));
} else if (remoteRobot.isWin() && ideaVersion.toInt() >= 20203) {
cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_3_TO_2022_1), Duration.ofSeconds(10));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class XPathDefinitions {
public static final String MAVEN_TOOL_WINDOW = "//div[@accessiblename='Maven Tool Window']";
public static final String GRADLE_TOOL_WINDOW = "//div[@accessiblename='Gradle Tool Window']";
public static final String LINUX_MAIN_MENU = "//div[@class='LinuxIdeMenuBar']";
public static final String WINDOWS_MAIN_MENU_2022_2_AND_NEWER = "//div[@class='IdeMenuBar']";
public static final String WINDOWS_MAIN_MENU_2024_1_AND_NEWER = "//div[@class='IdeJMenuBar']";
public static final String WINDOWS_MAIN_MENU_2022_2_TO_2023_2 = "//div[@class='IdeMenuBar']";
public static final String WINDOWS_MAIN_MENU_2020_3_TO_2022_1 = "//div[@class='MenuFrameHeader']";
public static final String WINDOWS_MAIN_MENU_2020_2_AND_OLDER = "//div[@class='CustomHeaderMenuBar']";
public static final String IDE_STATUS_BAR = "//div[@class='IdeStatusBarImpl']";
Expand All @@ -49,6 +50,7 @@ public class XPathDefinitions {
public static final String ARTIFACTS_COORDINATES_DIALOG_PANEL = "//div[@class='DialogPanel']/*";
public static final String HEAVY_WEIGHT_WINDOW = "//div[@class='HeavyWeightWindow']";
public static final String JDK_COMBOBOX = "//div[@class='JdkComboBox']";
public static final String JDK_COMBOBOX_PROJECT_WIZARD = "//div[@class='ProjectWizardJdkComboBox']"; // works for IntelliJ Idea 2024.1 and higher
public static final String MY_DIALOG = "//div[@class='MyDialog']";
public static final String TREE = "//div[@class='Tree']";
public static final String TOOLTIP_TEXT_PROJECT = "//div[@tooltiptext='Project']";
Expand Down Expand Up @@ -78,9 +80,11 @@ public class XPathDefinitions {
public static final String REMOVE_PROJECT_BUTTON = "//div[contains(@text.key, 'button.remove')]";
public static final String SET_LANGUAGE = "//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]";
public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]";
public static final String SET_BUILD_SYSTEM_2024_1_AND_NEWER = "//div[@accessiblename='Build system:' and @class='SegmentedButtonComponent']"; // works for IntelliJ Idea 2024.1 and higher
public static final String GET_SET_MODULE_NAME = "//div[@accessiblename='Module name:' and @accessiblename.key='label.project.wizard.new.project.module.name' and @class='JBTextField']";
public static final String GET_SET_CONTENT_ROOT = "//div[@accessiblename='Content root:' and @accessiblename.key='label.project.wizard.new.project.content.root' and @class='ExtendableTextField']";
public static final String GET_SET_MODULE_FILE_LOCATION = "//div[@accessiblename='Module file location:' and @accessiblename.key='label.project.wizard.new.project.module.file.location' and @class='ExtendableTextField']";
public static final String CREATE_NEW_PROJECT = "//div[@defaulticon='createNewProjectTab.svg']"; // works for IntelliJ Idea 2024.1 and higher

private XPathDefinitions() {
throw new UITestException("Utility class with static methods.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public enum IntelliJVersion {
COMMUNITY_V_2022_3("IC-2022.3"),
COMMUNITY_V_2023_1("IC-2023.1"),
COMMUNITY_V_2023_2("IC-2023.2"),
COMMUNITY_V_2024_1("IC-2024.1"),
ULTIMATE_V_2020_2("IU-2020.2"),
ULTIMATE_V_2020_3("IU-2020.3"),
ULTIMATE_V_2021_1("IU-2021.1"),
ULTIMATE_V_2021_2("IU-2021.2"),
ULTIMATE_V_2023_2("IU-2023.2");
ULTIMATE_V_2023_2("IU-2023.2"),
ULTIMATE_V_2024_1("IU-2024.1");

private final String ideaVersionStringRepresentation;
private final int ideaVersionIntRepresentation;
Expand Down
2 changes: 1 addition & 1 deletion src/test-project/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ideaVersion=IC-2023.2
ideaVersion=IC-2024.1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@ExtendWith(ScreenshotAfterTestFailExtension.class)
public class LibraryTestBase {
protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName());
private static final IntelliJVersion ideaVersion = IntelliJVersion.COMMUNITY_V_2023_2;
private static final IntelliJVersion ideaVersion = IntelliJVersion.COMMUNITY_V_2024_1;
protected static RemoteRobot remoteRobot;
protected static int ideaVersionInt = ideaVersion.toInt();
private static boolean intelliJHasStarted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void cancelButtonTest() {
@Test
public void setProjectSdkIfAvailableTest() {
newProjectFirstPage.setProjectSdkIfAvailable("11");
ComboBoxFixture projectJdkComboBox = newProjectFirstPage.find(ComboBoxFixture.class, byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10));
ComboBoxFixture projectJdkComboBox = newProjectFirstPage.getProjectJdkComboBox();
String currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText());
assertTrue(currentlySelectedProjectSdk.contains("11"), "Selected project SDK should be Java 11 but is '" + currentlySelectedProjectSdk + "'");
newProjectFirstPage.setProjectSdkIfAvailable("17");
Expand Down
Loading