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

GHA test project location #204

Closed
wants to merge 9 commits into from
12 changes: 6 additions & 6 deletions .github/workflows/dialogs.information_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
export DISPLAY=:99.0
Expand Down Expand Up @@ -50,10 +50,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src/test-project
Expand Down Expand Up @@ -83,10 +83,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src\test-project
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/dialogs.project_manipulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
export DISPLAY=:99.0
Expand Down Expand Up @@ -50,10 +50,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src/test-project
Expand Down Expand Up @@ -87,6 +87,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Run integration tests
run: |
cd src\test-project
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/dialogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
export DISPLAY=:99.0
Expand Down Expand Up @@ -50,10 +50,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src/test-project
Expand Down Expand Up @@ -83,10 +83,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src\test-project
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/mainidewindow.idestatusbar_screenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
export DISPLAY=:99.0
Expand Down Expand Up @@ -66,10 +66,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src/test-project
Expand Down Expand Up @@ -99,10 +99,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src\test-project
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/mainidewindow.toolwindowspane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
export DISPLAY=:99.0
Expand Down Expand Up @@ -50,10 +50,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src/test-project
Expand Down Expand Up @@ -83,10 +83,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Run integration tests
run: |
cd src\test-project
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
ref: ${{github.event.workflow_run.head_sha}}
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Download artifacts
uses: actions/[email protected]
with:
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ runIdeForUiTests {
systemProperty "robot-server.port", System.getProperty("robot-server.port")
}
```
### STEP #5: Test project location
Developers can specify the location where the test project will be created by providing a system property called `testProjectLocation`. For example:
```
task integrationTest(type: Test) {
...
systemProperties['testProjectLocation'] = '/home/user/IdeaProjects/intellij-ui-test-projects/'
...
}
```
Or add the location as a paramater for gradlew command which runs the test. For example:
```
systemProperties['testProjectLocation'] = project.hasProperty('testProjectLocation') ? project.property('testProjectLocation') : null

./gradlew integrationTest -PtestProjectLocation=${env.HOME}/IdeaProjects/intellij-ui-test-projects/
```

## Start and quit IntelliJ IDEA
Use the following code to start IntelliJ before running the first UI test. The runIde() method not only starts the IDE for UI tests, it also returns reference to the Remote-Robot instance which will be useful later to access UI elements such as buttons, inputs etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,26 @@

import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.data.RemoteComponent;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.fixtures.ComponentFixture;
import com.intellij.remoterobot.fixtures.ContainerFixture;
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.fixtures.HeavyWeightWindowFixture;
import com.intellij.remoterobot.fixtures.JButtonFixture;
import com.intellij.remoterobot.fixtures.JLabelFixture;
import com.intellij.remoterobot.fixtures.JListFixture;
import com.intellij.remoterobot.fixtures.JPopupMenuFixture;
import com.intellij.remoterobot.fixtures.JTreeFixture;
import com.intellij.remoterobot.fixtures.*;
import com.intellij.remoterobot.utils.UtilsKt;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.errors.IdeFatalErrorsDialog;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.information.TipDialog;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.SettingsDialog;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.pages.NotificationsPage;
import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import com.redhat.devtools.intellij.commonuitest.utils.internalerror.IdeInternalErrorUtils;
import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion;
import com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps;
import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.List;
Expand Down Expand Up @@ -96,10 +89,7 @@ public void clickOnLink(String label) {
* Clear the workspace by deleting the content of the IdeaProjects folder and clearing all the projects' links in the 'Welcome to IntelliJ IDEA' dialog
*/
public void clearWorkspace() {
for (int i = 0; i < projectsCount(); i++) {
removeTopProjectFromRecentProjects();
}

// Remove projects on disk
try {
String pathToDirToMakeEmpty = System.getProperty("user.home") + File.separator + "IdeaProjects";
boolean doesProjectDirExists = Files.exists(Paths.get(pathToDirToMakeEmpty));
Expand All @@ -111,6 +101,10 @@ public void clearWorkspace() {
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
// Remove projects from FlatWelcomeFrame's recent projects
for (int i = 0; i < projectsCount(); i++) {
removeTopProjectFromRecentProjects();
}
}

/**
Expand Down Expand Up @@ -156,29 +150,32 @@ public void openSettingsDialog() {
* @return fixture for the 'Tip Of the Day' dialog
*/
public TipDialog openTipDialog() {
if (ideaVersion <= 20202) {
if (ideaVersion <= 20202) { // IJ 2020.2 and older
clickOnLink("Get Help");
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
} else if (ideaVersion <= 20203) {
} else if (ideaVersion == 20203) { // IJ 2020.3
actionLink("Help").click();
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
} else if (ideaVersion <= 20212) {
} else if (ideaVersion <= 20212) { // IJ 2021.1 - IJ 2021.2
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
jListFixture.findText("Learn IntelliJ IDEA").click();
jListFixture.findText(ButtonLabels.LEARN_LABEL).click();
remoteRobot.find(JLabelFixture.class, byXpath(XPathDefinitions.TIP_DIALOG_2)).click();
} else {
} else { // IJ 2021.3 and newer
IdeInternalErrorUtils.clearWindowsErrorsIfTheyAppear(remoteRobot);
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
jTreeFixture.findText("Learn IntelliJ IDEA").click();
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class);
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2));
if (ideaVersion >= 20223) { // learn label for IJ 2022.3 and newer
flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click();
} else { // learn label for IJ 2022.2 and older
flatWelcomeFrame.findText(ButtonLabels.LEARN_INTELLIJ_IDEA_LABEL).click();
}
SharedSteps.waitForComponentByXpath(remoteRobot, 2, 1, byXpath(XPathDefinitions.TIP_DIALOG_2));
flatWelcomeFrame.findText(TIP_OF_THE_DAY).click();
}

return remoteRobot.find(TipDialog.class, Duration.ofSeconds(10));
}

/**
* Open the 'Preferences' dialog
*/
Expand Down Expand Up @@ -254,11 +251,16 @@ private void removeTopProjectFromRecentProjects() {
recentProjects = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)).get(0);
}

// Clicks on X on first recent project to remove it from the recent projects list (visible only when hovered over with cursor)
recentProjects.runJs("const horizontal_offset = component.getWidth()-22;\n" +
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");

// Code for IntelliJ Idea 2020.3 or newer
if (ideaVersion >= 20203) {
if (ideaVersion >= 20231) {
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(2));
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL)
.click();
}
else if (ideaVersion >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
List<JPopupMenuFixture> jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType());
if (!jPopupMenuFixtures.isEmpty()) {
JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ public void closeGradleBuildToolPane() {
public JButtonFixture stripeButton(String label, boolean isPaneOpened) {
if (isPaneOpened) {
if (label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) || label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL)) {
return button(byXpath(XPathDefinitions.toolWindowSvg(label)), Duration.ofSeconds(2));
if (UITestRunner.getIdeaVersionInt() >= 20232) { // Code for IntelliJ version 2023.2 and newer
return button(byXpath(XPathDefinitions.toolWindowButton(label)), Duration.ofSeconds(2));
} else { // Code for IntelliJ versions 2023.1 and older
return button(byXpath(XPathDefinitions.toolWindowSvg(label)), Duration.ofSeconds(2));
}
} else if (label.equals(ButtonLabels.PROJECT_STRIPE_BUTTON_LABEL)) {
return button(byXpath(XPathDefinitions.TOOLTIP_TEXT_PROJECT), Duration.ofSeconds(2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void waitUntilBuildHasFinished() {
*/
public boolean isBuildSuccessful() {
String runConsoleOutput = TextUtils.listOfRemoteTextToString(buildConsole().findAllText());
return runConsoleOutput.contains("BUILD SUCCESS");
return runConsoleOutput.contains("BUILD SUCCESS") || runConsoleOutput.contains("exit code 0");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class ButtonLabels {
public static final String GOT_IT_LABEL = "Got It";
public static final String MORE_SETTINGS = "More Settings";
public static final String ARTIFACT_COORDINATES = "Artifact Coordinates";
public static final String LEARN_INTELLIJ_IDEA_LABEL = "Learn IntelliJ IDEA";
public static final String LEARN_LABEL = "Learn";
public static final String REMOVE_FROM_LIST_LABEL = "Remove From List";

private ButtonLabels() {
throw new UITestException("Utility class with static methods.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ public static String nonOpaquePanel(String label) {
return "//div[@class='NonOpaquePanel'][./div[@text='" + label + "']]";
}

public static String editorTabLabel(String label) {
return "//div[@accessiblename='" + label + "' and @class='EditorTabLabel']";
}

public static String toolWindowSvg(String label) {
return "//div[@disabledicon='toolWindow" + label + ".svg']";
}

public static String toolWindowButton(String label) {
return "//div[@tooltiptext='" + label + "']";
}
}
Loading
Loading