Skip to content

Commit

Permalink
fix(UITest): fix for unstable tests & minor improvements
Browse files Browse the repository at this point in the history
fix(UITest): fix for unstable tests & minor improvements
  • Loading branch information
martinszuc authored Sep 5, 2024
2 parents 9808e78 + c340e7a commit f97a253
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private void removeTopProjectFromRecentProjects() {
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");

if (ideaVersion >= 20231) {
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(2));
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10));
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL)
.click();
} else if (ideaVersion >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
Expand Down
2 changes: 2 additions & 0 deletions src/test-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ test {

tasks.register('integrationUITestUltimate', Test) {
dependsOn copyKey
group = 'verification'
systemProperties['task.name'] = 'integrationUITestUltimate'
systemProperties['intellij_debug'] = 'true'
useJUnitPlatform()
}

tasks.register('integrationUITest', Test) {
systemProperties['intellij_debug'] = 'true'
group = 'verification'
useJUnitPlatform()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,26 @@ public void hideAllPopups() {

@Test
public void isItemPresentTest() {
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, PROJECT_NAME + ".iml");
assertTrue(isItemPresent, "The file '" + PROJECT_NAME + ".iml' should be present in the project on location '" + PROJECT_NAME + "/" + PROJECT_NAME + ".iml' but is not.");
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, "src", "Main");
assertTrue(isItemPresent, "The file 'Main' should be present in the project on location 'src/Main' but is not.");
}

@Test
public void openFileTest() {
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
projectExplorer.openFile(PROJECT_NAME, ".gitignore");
if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+
String projectLabelXpath = "//div[@accessiblename='" + PROJECT_NAME + ".iml' and @class='EditorTabLabel']//div[@class='ActionPanel']";
String projectLabelXpath = "//div[@accessiblename='.gitignore' and @class='EditorTabLabel']//div[@class='ActionPanel']";
try { // Verify file is opened by finding its tab in the editor
remoteRobot.find(ComponentFixture.class, byXpath(projectLabelXpath));
} catch (Exception e) {
fail("The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
fail("The '.gitignore' file should be opened but is not.");
}
} else {
List<ContainerFixture> cfs = remoteRobot.findAll(ContainerFixture.class, byXpath(XPathDefinitions.SINGLE_HEIGHT_LABEL));
ContainerFixture cf = cfs.get(cfs.size() - 1);
String allText = TextUtils.listOfRemoteTextToString(cf.findAllText());
boolean isFileOpened = allText.contains(PROJECT_NAME + ".iml");
assertTrue(isFileOpened, "The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
boolean isFileOpened = allText.contains(".gitignore");
assertTrue(isFileOpened, "The '.gitignore' file should be opened but is not.");
}
}

Expand All @@ -117,12 +117,16 @@ public void openViewsPopupTest() {

@Test
public void selectOpenedFileTest() {
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
projectExplorer.expandAll();
projectExplorer.openFile(PROJECT_NAME, "src", "Main");
projectExplorer.projectViewTree().clickRow(0);
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
projectExplorer.selectOpenedFile();
SharedSteps.waitForComponentByXpath(remoteRobot,3,1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
assertTrue(projectExplorer.projectViewTree().isPathSelected(projectExplorer.projectViewTree().getValueAtRow(0), PROJECT_NAME + ".iml"), "The file '" + PROJECT_NAME + ".xml' should be selected but is not.");
SharedSteps.waitForComponentByXpath(remoteRobot, 3, 1, byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG));
assertTrue(projectExplorer.projectViewTree().isPathSelected(
projectExplorer.projectViewTree().getValueAtRow(0), "src", "Main"),
"The file 'Main' should be selected but is not."
);
}

@Test
Expand Down

0 comments on commit f97a253

Please sign in to comment.